java.io
public class ObjectInputStream extends InputStream implements ObjectInput, ObjectStreamConstants
Nested Class Summary | |
---|---|
abstract static class | ObjectInputStream.GetField
This class allows a class to specify exactly which fields should
be read, and what values should be read for these fields.
|
Constructor Summary | |
---|---|
ObjectInputStream(InputStream in)
Creates a new ObjectInputStream that will do all of
its reading from in . | |
protected | ObjectInputStream()
Protected constructor that allows subclasses to override
deserialization. |
Method Summary | |
---|---|
int | available() |
void | close() |
void | defaultReadObject()
Reads the current objects non-transient, non-static fields from
the current class from the underlying output stream.
|
protected boolean | enableResolveObject(boolean enable)
If enable is true and this object is
trusted, then resolveObject (Object) will be called
in subsequent calls to readObject (Object) .
|
int | read() |
int | read(byte[] data, int offset, int length) |
boolean | readBoolean() |
byte | readByte() |
char | readChar() |
protected ObjectStreamClass | readClassDescriptor()
This method reads a class descriptor from the real input stream
and use these data to create a new instance of ObjectStreamClass.
|
double | readDouble() |
ObjectInputStream.GetField | readFields()
This method should be called by a method called 'readObject' in the
deserializing class (if present). |
float | readFloat() |
void | readFully(byte[] data) |
void | readFully(byte[] data, int offset, int size) |
int | readInt() |
String | readLine() |
long | readLong() |
Object | readObject()
Returns the next deserialized object read from the underlying stream.
|
protected Object | readObjectOverride()
This method allows subclasses to override the default
de serialization mechanism provided by
ObjectInputStream . |
short | readShort() |
protected void | readStreamHeader()
Reads stream magic and stream version information from the
underlying stream.
|
Object | readUnshared() Returns the next deserialized object read from the underlying stream in an unshared manner. |
int | readUnsignedByte() |
int | readUnsignedShort() |
String | readUTF() |
void | registerValidation(ObjectInputValidation validator, int priority)
Registers a ObjectInputValidation to be carried out
on the object graph currently being deserialized before it is
returned to the original caller of readObject () .
|
protected Class<?> | resolveClass(ObjectStreamClass osc)
Called when a class is being deserialized. |
protected Object | resolveObject(Object obj)
Allows subclasses to resolve objects that are read from the
stream with other objects to be returned in their place. |
protected Class<?> | resolveProxyClass(String[] intfs) |
int | skipBytes(int len) |
ObjectInputStream
that will do all of
its reading from in
. This method also checks
the stream by reading the header information (stream magic number
and stream version).
Throws: IOException Reading stream header from underlying stream cannot be completed. StreamCorruptedException An invalid stream magic number or stream version was read from the stream.
See Also: readStreamHeader
readObject (Object)
. This
method does a security check NOTE: currently not
implemented, then sets a flag that informs
readObject (Object)
to call the subclasses
readObjectOverride (Object)
method.
See Also: readObjectOverride
private void readObject (ObjectInputStream)
method.
Throws: ClassNotFoundException The class that an object being
read in belongs to cannot be found.
NotActiveException This method was called from a
context other than from the current object's and current class's
private void readObject (ObjectInputStream)
method.
IOException Exception from underlying
OutputStream
.
enable
is true
and this object is
trusted, then resolveObject (Object)
will be called
in subsequent calls to readObject (Object)
.
Otherwise, resolveObject (Object)
will not be called.
Throws: SecurityException This class is not trusted.
Returns: A new instance of ObjectStreamClass containing the freshly created descriptor.
Throws: ClassNotFoundException if the required class to build the descriptor has not been found in the system. IOException An input/output error occured. InvalidClassException If there was a compatibility problem between the class present in the system and the serialized class.
Returns: A valid freshly created 'GetField' instance to get access to the deserialized stream.
Throws: IOException An input/output exception occured. ClassNotFoundException NotActiveException
Deprecated:
See Also: readLine
private void readObject (ObjectInputStream)
.
If an exception is thrown from this method, the stream is left in
an undefined state. This method can also throw Errors and
RuntimeExceptions if caused by existing readResolve() user code.
Returns: The object read from the underlying stream.
Throws: ClassNotFoundException The class that an object being
read in belongs to cannot be found.
IOException Exception from underlying
InputStream
.
ObjectInputStream
. To make this method be used for
writing objects, subclasses must invoke the 0-argument
constructor on this class from their constructor.
See Also: ObjectInputStream
Throws: IOException Exception from underlying stream. StreamCorruptedException An invalid stream magic number or stream version was read from the stream.
Returns the next deserialized object read from the underlying stream in an unshared manner. Any object returned by this method will not be returned by subsequent calls to either this method or {@link #readObject()}.
This behaviour is achieved by:
Returns: a reference to the deserialized object.
Throws: ClassNotFoundException if the class of the object being deserialized can not be found. StreamCorruptedException if information in the stream is inconsistent. ObjectStreamException if the next object has already been returned by an earlier call to this method or {@link #readObject()}. OptionalDataException if primitive data occurs next in the stream. IOException if an I/O error occurs from the stream.
Since: 1.4
See Also: readObject
ObjectInputValidation
to be carried out
on the object graph currently being deserialized before it is
returned to the original caller of readObject ()
.
The order of validation for multiple
ObjectInputValidation
s can be controled using
priority
. Validators with higher priorities are
called first.
Throws: InvalidObjectException validator
is
null
NotActiveException an attempt was made to add a
validator outside of the readObject
method of the
object currently being deserialized
annotateClass (Class)
method of an
ObjectOutputStream
.
This implementation looks up the active call stack for a
ClassLoader
; if a ClassLoader
is found,
it is used to load the class associated with osc
,
otherwise, the default system ClassLoader
is used.
Throws: IOException Exception from underlying
OutputStream
.
See Also: annotateClass
Throws: IOException Exception from underlying
OutputStream
.
See Also: ObjectInputStream