author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:53:06 +0200 | |
changeset 65 | 4db7ceebd2b3 |
child 66 | 8379bb7c0dff |
permissions | -rw-r--r-- |
jtulach@65 | 1 |
package api; |
jtulach@65 | 2 |
|
jtulach@65 | 3 |
import java.io.IOException; |
jtulach@65 | 4 |
|
jtulach@65 | 5 |
/** Fixing the problem caused by mixing subclassing and delegation in |
jtulach@65 | 6 |
* the <code>java.io.BufferedWriter</code> |
jtulach@65 | 7 |
* |
jtulach@65 | 8 |
* @author Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jtulach@65 | 9 |
*/ |
jtulach@65 | 10 |
public final class Writer { |
jtulach@65 | 11 |
private final Impl impl; |
jtulach@65 | 12 |
|
jtulach@65 | 13 |
private Writer(Impl impl) { |
jtulach@65 | 14 |
this.impl = impl; |
jtulach@65 | 15 |
} |
jtulach@65 | 16 |
public final void write(int c) throws IOException { |
jtulach@65 | 17 |
impl.write(new CharSeq(c)); |
jtulach@65 | 18 |
} |
jtulach@65 | 19 |
|
jtulach@65 | 20 |
public final void write(char cbuf[]) throws IOException { |
jtulach@65 | 21 |
impl.write(new CharSeq(cbuf, 0, cbuf.length)); |
jtulach@65 | 22 |
} |
jtulach@65 | 23 |
public final void write(char cbuf[], int off, int len) throws IOException { |
jtulach@65 | 24 |
impl.write(new CharSeq(cbuf, off, len)); |
jtulach@65 | 25 |
} |
jtulach@65 | 26 |
public final void write(String str) throws IOException { |
jtulach@65 | 27 |
impl.write(str); |
jtulach@65 | 28 |
} |
jtulach@65 | 29 |
public final void write(String str, int off, int len) throws IOException { |
jtulach@65 | 30 |
impl.write(str.subSequence(off, off + len)); |
jtulach@65 | 31 |
} |
jtulach@65 | 32 |
|
jtulach@65 | 33 |
|
jtulach@65 | 34 |
|
jtulach@65 | 35 |
public static interface Impl { |
jtulach@65 | 36 |
public void write(CharSequence seq) throws IOException; |
jtulach@65 | 37 |
} |
jtulach@65 | 38 |
|
jtulach@65 | 39 |
|
jtulach@65 | 40 |
|
jtulach@65 | 41 |
} |