KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > stream > ObjectOutputStreamAdapter


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9
10 package org.jboss.util.stream;
11
12 import java.io.IOException JavaDoc;
13 import java.io.ObjectOutputStream JavaDoc;
14
15 import org.jboss.util.NullArgumentException;
16
17 /**
18  * An <code>ObjectOutputStream</code> wrapping adapter.
19  *
20  * <h3>Concurrency</h3>
21  * This class is <b>not</b> synchronized.
22  *
23  * @version <tt>$Revision: 1.1 $</tt>
24  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
25  */

26 public abstract class ObjectOutputStreamAdapter
27    extends ObjectOutputStream JavaDoc
28 {
29    /** Nested object output stream */
30    protected ObjectOutputStream JavaDoc out;
31    
32    /**
33     * Construct a new ObjectOutputStreamAdapter.
34     *
35     * @param out An ObjectOutputStream stream.
36     *
37     * @throws IOException Any exception thrown by the underlying
38     * OutputStream.
39     * @throws IllegalArgumentException Out is null.
40     */

41    public ObjectOutputStreamAdapter(ObjectOutputStream JavaDoc out)
42       throws IOException JavaDoc
43    {
44       super(); // allow calls to writeObjectOverride()
45

46       if (out == null)
47          throw new NullArgumentException("out");
48
49       this.out = out;
50    }
51
52    protected void writeObjectOverride(Object JavaDoc obj) throws IOException JavaDoc {
53       out.writeObject(obj);
54    }
55
56    public void useProtocolVersion(int version) throws IOException JavaDoc {
57       out.useProtocolVersion(version);
58    }
59
60    public void defaultWriteObject() throws IOException JavaDoc {
61       out.defaultWriteObject();
62    }
63
64    public ObjectOutputStream.PutField JavaDoc putFields() throws IOException JavaDoc {
65       return out.putFields();
66    }
67
68    public void writeFields() throws IOException JavaDoc {
69       out.writeFields();
70    }
71
72    public void reset() throws IOException JavaDoc {
73       out.reset();
74    }
75
76    public void write(int data) throws IOException JavaDoc {
77       out.write(data);
78    }
79
80    public void write(byte b[]) throws IOException JavaDoc {
81       out.write(b);
82    }
83
84    public void write(byte b[], int off, int len) throws IOException JavaDoc {
85       out.write(b, off, len);
86    }
87
88    public void flush() throws IOException JavaDoc {
89       out.flush();
90    }
91
92    public void close() throws IOException JavaDoc {
93       out.close();
94    }
95
96    public void writeBoolean(boolean data) throws IOException JavaDoc {
97       out.writeBoolean(data);
98    }
99
100    public void writeByte(int data) throws IOException JavaDoc {
101       out.writeByte(data);
102    }
103
104    public void writeShort(int data) throws IOException JavaDoc {
105       out.writeShort(data);
106    }
107
108    public void writeChar(int data) throws IOException JavaDoc {
109       out.writeChar(data);
110    }
111
112    public void writeInt(int data) throws IOException JavaDoc {
113       out.writeInt(data);
114    }
115
116    public void writeLong(long data) throws IOException JavaDoc {
117       out.writeLong(data);
118    }
119
120    public void writeFloat(float data) throws IOException JavaDoc {
121       out.writeFloat(data);
122    }
123
124    public void writeDouble(double data) throws IOException JavaDoc {
125       out.writeDouble(data);
126    }
127
128    public void writeBytes(String JavaDoc data) throws IOException JavaDoc {
129       out.writeBytes(data);
130    }
131
132    public void writeChars(String JavaDoc data) throws IOException JavaDoc {
133       out.writeChars(data);
134    }
135
136    public void writeUTF(String JavaDoc s) throws IOException JavaDoc {
137       out.writeUTF(s);
138    }
139 }
140
Popular Tags