|
20 | 20 | import java.io.OutputStream; |
21 | 21 |
|
22 | 22 | /** |
23 | | - * Data written to this stream is forwarded to a stream that has been associated |
24 | | - * with this thread. |
| 23 | + * Data written to this stream is forwarded to a stream that has been associated with this thread. |
25 | 24 | * |
26 | 25 | * @version $Id$ |
27 | 26 | */ |
28 | | -public class DemuxOutputStream |
29 | | - extends OutputStream |
30 | | -{ |
| 27 | +public class DemuxOutputStream extends OutputStream { |
31 | 28 | private final InheritableThreadLocal<OutputStream> m_streams = new InheritableThreadLocal<OutputStream>(); |
32 | 29 |
|
33 | 30 | /** |
34 | 31 | * Bind the specified stream to the current thread. |
35 | 32 | * |
36 | | - * @param output the stream to bind |
| 33 | + * @param output |
| 34 | + * the stream to bind |
37 | 35 | * @return the OutputStream that was previously active |
38 | 36 | */ |
39 | | - public OutputStream bindStream( final OutputStream output ) |
40 | | - { |
| 37 | + public OutputStream bindStream(final OutputStream output) { |
41 | 38 | final OutputStream stream = m_streams.get(); |
42 | | - m_streams.set( output ); |
| 39 | + m_streams.set(output); |
43 | 40 | return stream; |
44 | 41 | } |
45 | 42 |
|
46 | 43 | /** |
47 | 44 | * Closes stream associated with current thread. |
48 | 45 | * |
49 | | - * @throws IOException if an error occurs |
| 46 | + * @throws IOException |
| 47 | + * if an error occurs |
50 | 48 | */ |
51 | 49 | @Override |
52 | | - public void close() |
53 | | - throws IOException |
54 | | - { |
| 50 | + public void close() throws IOException { |
55 | 51 | final OutputStream output = m_streams.get(); |
56 | | - if( null != output ) |
57 | | - { |
| 52 | + if (null != output) { |
58 | 53 | output.close(); |
59 | 54 | } |
60 | 55 | } |
61 | 56 |
|
62 | 57 | /** |
63 | 58 | * Flushes stream associated with current thread. |
64 | 59 | * |
65 | | - * @throws IOException if an error occurs |
| 60 | + * @throws IOException |
| 61 | + * if an error occurs |
66 | 62 | */ |
67 | 63 | @Override |
68 | | - public void flush() |
69 | | - throws IOException |
70 | | - { |
| 64 | + public void flush() throws IOException { |
71 | 65 | final OutputStream output = m_streams.get(); |
72 | | - if( null != output ) |
73 | | - { |
| 66 | + if (null != output) { |
74 | 67 | output.flush(); |
75 | 68 | } |
76 | 69 | } |
77 | 70 |
|
78 | 71 | /** |
79 | 72 | * Writes byte to stream associated with current thread. |
80 | 73 | * |
81 | | - * @param ch the byte to write to stream |
82 | | - * @throws IOException if an error occurs |
| 74 | + * @param ch |
| 75 | + * the byte to write to stream |
| 76 | + * @throws IOException |
| 77 | + * if an error occurs |
83 | 78 | */ |
84 | 79 | @Override |
85 | | - public void write( final int ch ) |
86 | | - throws IOException |
87 | | - { |
| 80 | + public void write(final int ch) throws IOException { |
88 | 81 | final OutputStream output = m_streams.get(); |
89 | | - if( null != output ) |
90 | | - { |
91 | | - output.write( ch ); |
| 82 | + if (null != output) { |
| 83 | + output.write(ch); |
92 | 84 | } |
93 | 85 | } |
94 | 86 | } |
0 commit comments