samples/delegatingwriter/src/org/apidesign/delegatingwriter/AltBufferedWriter.java
changeset 63 cbba5b31d11c
parent 61 59df94cee246
child 64 7b26c64804c2
     1.1 --- a/samples/delegatingwriter/src/org/apidesign/delegatingwriter/AltBufferedWriter.java	Sat Jun 14 09:53:03 2008 +0200
     1.2 +++ b/samples/delegatingwriter/src/org/apidesign/delegatingwriter/AltBufferedWriter.java	Sat Jun 14 09:53:04 2008 +0200
     1.3 @@ -20,6 +20,10 @@
     1.4      private final Writer out;
     1.5      private final Behaviour behaviour;
     1.6      
     1.7 +    public AltBufferedWriter(Writer out) {
     1.8 +        // behave exactly like BufferedWriter in 1.5 behaves
     1.9 +        this(out, Behaviour.DELEGATE_TO_SUPER);
    1.10 +    }
    1.11      public AltBufferedWriter(Writer out, Behaviour behaviour) {
    1.12          super(out);
    1.13          this.out = out;
    1.14 @@ -37,8 +41,10 @@
    1.15          }
    1.16      }
    1.17      
    1.18 -    // BEGIN: writer.throw
    1.19      public Writer appendThrowException(CharSequence csq) throws IOException {
    1.20 +        /* in case of real code, this would be part of the regular append method BEGIN: writer.throw
    1.21 +    public Writer append(CharSequence csq) throws IOException {
    1.22 +        /* thrown an exception as this method is new and subclasses need to override it */
    1.23          throw new UnsupportedOperationException();
    1.24      }
    1.25      // END: writer.throw
    1.26 @@ -58,7 +64,7 @@
    1.27      
    1.28      public Writer appendDelegateToUnderlaying(CharSequence csq) throws IOException {
    1.29          // BEGIN: writer.delegateout
    1.30 -        // efficient, yet dangerous delegation skipping methods known to 
    1.31 +        // efficient, yet dangerous delegation skipping methods unknown to 
    1.32          // subclasses that used version 1.4
    1.33          out.append(csq);
    1.34          return this;