KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > io > ObjectStreamConstants


1 /*
2  * @(#)ObjectStreamConstants.java 1.34 04/01/12
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.io;
9
10 /**
11  * Constants written into the Object Serialization Stream.
12  *
13  * @author unascribed
14  * @version 1.34, 01/12/04
15  * @since JDK 1.1
16  */

17 public interface ObjectStreamConstants {
18
19     /**
20      * Magic number that is written to the stream header.
21      */

22     final static short STREAM_MAGIC = (short)0xaced;
23
24     /**
25      * Version number that is written to the stream header.
26      */

27     final static short STREAM_VERSION = 5;
28
29     /* Each item in the stream is preceded by a tag
30      */

31
32     /**
33      * First tag value.
34      */

35     final static byte TC_BASE = 0x70;
36
37     /**
38      * Null object reference.
39      */

40     final static byte TC_NULL = (byte)0x70;
41
42     /**
43      * Reference to an object already written into the stream.
44      */

45     final static byte TC_REFERENCE = (byte)0x71;
46
47     /**
48      * new Class Descriptor.
49      */

50     final static byte TC_CLASSDESC = (byte)0x72;
51
52     /**
53      * new Object.
54      */

55     final static byte TC_OBJECT = (byte)0x73;
56
57     /**
58      * new String.
59      */

60     final static byte TC_STRING = (byte)0x74;
61
62     /**
63      * new Array.
64      */

65     final static byte TC_ARRAY = (byte)0x75;
66
67     /**
68      * Reference to Class.
69      */

70     final static byte TC_CLASS = (byte)0x76;
71
72     /**
73      * Block of optional data. Byte following tag indicates number
74      * of bytes in this block data.
75      */

76     final static byte TC_BLOCKDATA = (byte)0x77;
77
78     /**
79      * End of optional block data blocks for an object.
80      */

81     final static byte TC_ENDBLOCKDATA = (byte)0x78;
82
83     /**
84      * Reset stream context. All handles written into stream are reset.
85      */

86     final static byte TC_RESET = (byte)0x79;
87     
88     /**
89      * long Block data. The long following the tag indicates the
90      * number of bytes in this block data.
91      */

92     final static byte TC_BLOCKDATALONG= (byte)0x7A;
93     
94     /**
95      * Exception during write.
96      */

97     final static byte TC_EXCEPTION = (byte)0x7B;
98
99     /**
100      * Long string.
101      */

102     final static byte TC_LONGSTRING = (byte)0x7C;
103
104     /**
105      * new Proxy Class Descriptor.
106      */

107     final static byte TC_PROXYCLASSDESC = (byte)0x7D;
108
109     /**
110      * new Enum constant.
111      */

112     final static byte TC_ENUM = (byte)0x7E;
113
114     /**
115      * Last tag value.
116      */

117     final static byte TC_MAX = (byte)0x7E;
118
119     /**
120      * First wire handle to be assigned.
121      */

122     final static int baseWireHandle = 0x7e0000;
123
124
125     /******************************************************/
126     /* Bit masks for ObjectStreamClass flag.*/
127
128     /**
129      * Bit mask for ObjectStreamClass flag. Indicates a Serializable class
130      * defines its own writeObject method.
131      */

132     final static byte SC_WRITE_METHOD = 0x01;
133
134     /**
135      * Bit mask for ObjectStreamClass flag. Indicates Externalizable data
136      * written in Block Data mode.
137      * Added for PROTOCOL_VERSION_2.
138      *
139      * @see #PROTOCOL_VERSION_2
140      * @since 1.2
141      */

142     final static byte SC_BLOCK_DATA = 0x08;
143
144     /**
145      * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
146      */

147     final static byte SC_SERIALIZABLE = 0x02;
148
149     /**
150      * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
151      */

152     final static byte SC_EXTERNALIZABLE = 0x04;
153
154     /**
155      * Bit mask for ObjectStreamClass flag. Indicates class is an enum type.
156      */

157     final static byte SC_ENUM = 0x10;
158
159     
160     /* *******************************************************************/
161     /* Security permissions */
162
163     /**
164      * Enable substitution of one object for another during
165      * serialization/deserialization.
166      *
167      * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
168      * @see java.io.ObjectInputStream#enableResolveObject(boolean)
169      * @since 1.2
170      */

171     final static SerializablePermission JavaDoc SUBSTITUTION_PERMISSION =
172                            new SerializablePermission JavaDoc("enableSubstitution");
173
174     /**
175      * Enable overriding of readObject and writeObject.
176      *
177      * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
178      * @see java.io.ObjectInputStream#readObjectOverride()
179      * @since 1.2
180      */

181     final static SerializablePermission JavaDoc SUBCLASS_IMPLEMENTATION_PERMISSION =
182                     new SerializablePermission JavaDoc("enableSubclassImplementation");
183    /**
184     * A Stream Protocol Version. <p>
185     *
186     * All externalizable data is written in JDK 1.1 external data
187     * format after calling this method. This version is needed to write
188     * streams containing Externalizable data that can be read by
189     * pre-JDK 1.1.6 JVMs.
190     *
191     * @see java.io.ObjectOutputStream#useProtocolVersion(int)
192     * @since 1.2
193     */

194     public final static int PROTOCOL_VERSION_1 = 1;
195
196     
197    /**
198     * A Stream Protocol Version. <p>
199     *
200     * This protocol is written by JVM 1.2.
201     *
202     * Externalizable data is written in block data mode and is
203     * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
204     * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can
205     * read this format change.
206     *
207     * Enables writing a nonSerializable class descriptor into the
208     * stream. The serialVersionUID of a nonSerializable class is
209     * set to 0L.
210     *
211     * @see java.io.ObjectOutputStream#useProtocolVersion(int)
212     * @see #SC_BLOCK_DATA
213     * @since 1.2
214     */

215     public final static int PROTOCOL_VERSION_2 = 2;
216 }
217
Popular Tags