java.io
Class ObjectInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.ObjectInputStream
All Implemented Interfaces:
ObjectInput, ObjectStreamConstants
ObjectInputStream
protected ObjectInputStream()
Protected constructor that allows subclasses to override
deserialization. This constructor should be called by subclasses
that wish to override 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:
ObjectInputStream
public ObjectInputStream(java.io.InputStream in)
Creates a new 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).
Parameters:
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:
available
public int available()
close
public void close()
defaultReadObject
public void defaultReadObject()
Reads the current objects non-transient, non-static fields from
the current class from the underlying output stream.
This method is intended to be called from within a object's
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
.
enableResolveObject
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)
.
Otherwise, resolveObject (Object)
will not be called.
Parameters:
Throws:
read
public int read()
read
public int read(byte[] data, int offset, int length)
Parameters:
readBoolean
public boolean readBoolean()
readByte
public byte readByte()
readChar
public char readChar()
readDouble
public double readDouble()
readFields
public ObjectInputStream.GetField readFields()
readFloat
public float readFloat()
readFully
public void readFully(byte[] data)
Parameters:
readFully
public void readFully(byte[] data, int offset, int size)
Parameters:
readInt
public int readInt()
readLine
public String readLine()
See Also:
readLong
public long readLong()
readObject
public final Object readObject()
Returns the next deserialized object read from the underlying stream.
This method can be overriden by a class by implementing
private void readObject (ObjectInputStream)
.
If an exception is thrown from this method, the stream is left in
an undefined state.
Throws:
readObjectOverride
protected Object readObjectOverride()
This method allows subclasses to override the default
de serialization mechanism provided by
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:
readShort
public short readShort()
readStreamHeader
protected void readStreamHeader()
Reads stream magic and stream version information from the
underlying stream.
Throws:
readUTF
public String readUTF()
readUnsignedByte
public int readUnsignedByte()
readUnsignedShort
public int readUnsignedShort()
registerValidation
public void registerValidation(java.io.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 ()
.
The order of validation for multiple
ObjectInputValidation
s can be controled using
priority
. Validators with higher priorities are
called first.
Parameters:
Throws:
See Also:
resolveClass
protected Class resolveClass(java.io.ObjectStreamClass osc)
Called when a class is being deserialized. This is a hook to
allow subclasses to read in information written by the
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.
Parameters:
Throws:
See Also:
resolveObject
protected Object resolveObject(java.lang.Object obj)
Allows subclasses to resolve objects that are read from the
stream with other objects to be returned in their place. This
method is called the first time each object is encountered.
This method must be enabled before it will be called in the
serialization process.
Parameters:
Throws:
See Also:
resolveProxyClass
protected Class resolveProxyClass(java.lang.String[] intfs)
Parameters:
skipBytes
public int skipBytes(int len)
Parameters:
readObject (Object)
. This method does a security check NOTE: currently not implemented, then sets a flag that informsreadObject (Object)
to call the subclassesreadObjectOverride (Object)
method.