01: package vicazh.hyperpool.stream;
02:
03: import java.io.*;
04:
05: /**
06: * This class is the superclass of all streams
07: *
08: * @author Victor Zhigunov
09: * @version 0.4.0
10: */
11: public class Stream extends NullStream {
12: public Stream() {
13: }
14:
15: /**
16: * The parent connection
17: */
18: public Connection connection;
19:
20: /**
21: * @param connection
22: * parent connection
23: * @param outputstream
24: * linked output stream
25: */
26: public Stream(Connection connection, OutputStream outputstream) {
27: super (outputstream);
28: this .connection = connection;
29: }
30:
31: public void write(int b) throws IOException {
32: super .write(b);
33: if (outputstream == null)
34: throw new BreakException();
35: outputstream.write(b);
36: }
37:
38: public void close() throws IOException {
39: if (outputstream == null)
40: return;
41: super .close();
42: connection.close(this );
43: }
44:
45: public boolean isReverse() {
46: OutputStream stream = outputstream;
47: while (stream != null
48: && stream instanceof vicazh.hyperpool.stream.NullStream) {
49: if (stream instanceof Stream)
50: return ((Stream) stream).isReverse();
51: stream = ((vicazh.hyperpool.stream.NullStream) stream).outputstream;
52: }
53: return false;
54: }
55: }
|