java.io
Class ObjectInputStream
- Closeable, DataInput, ObjectInput, ObjectStreamConstants
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.
|
PROTOCOL_VERSION_1 , PROTOCOL_VERSION_2 , SC_BLOCK_DATA , SC_ENUM , SC_EXTERNALIZABLE , SC_SERIALIZABLE , SC_WRITE_METHOD , STREAM_MAGIC , STREAM_VERSION , SUBCLASS_IMPLEMENTATION_PERMISSION , SUBSTITUTION_PERMISSION , TC_ARRAY , TC_BASE , TC_BLOCKDATA , TC_BLOCKDATALONG , TC_CLASS , TC_CLASSDESC , TC_ENDBLOCKDATA , TC_ENUM , TC_EXCEPTION , TC_LONGSTRING , TC_MAX , TC_NULL , TC_OBJECT , TC_PROXYCLASSDESC , TC_REFERENCE , TC_RESET , TC_STRING , baseWireHandle |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
ObjectInputStream
protected ObjectInputStream()
throws IOException,
SecurityException
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.
defaultReadObject
public void defaultReadObject()
throws ClassNotFoundException,
IOException,
NotActiveException
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.
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)
throws SecurityException
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.
readClassDescriptor
protected ObjectStreamClass readClassDescriptor()
throws ClassNotFoundException,
IOException
This method reads a class descriptor from the real input stream
and use these data to create a new instance of ObjectStreamClass.
Fields are sorted and ordered for the real read which occurs for
each instance of the described class. Be aware that if you call that
method you must ensure that the stream is synchronized, in the other
case it may be completely desynchronized.
- A new instance of ObjectStreamClass containing the freshly
created descriptor.
readObject
public final Object readObject()
throws ClassNotFoundException,
IOException
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. This method can also throw Errors and
RuntimeExceptions if caused by existing readResolve() user code.
- readObject in interface ObjectInput
- The object read from the underlying stream.
readUnshared
public Object readUnshared()
throws IOException,
ClassNotFoundException
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
readObject()
.
This behaviour is achieved by:
- a reference to the deserialized object.
registerValidation
public void registerValidation(ObjectInputValidation validator,
int priority)
throws InvalidObjectException,
NotActiveException
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.
resolveClass
protected Class> resolveClass(ObjectStreamClass osc)
throws ClassNotFoundException,
IOException
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.
resolveObject
protected Object resolveObject(Object obj)
throws IOException
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.
ObjectInputStream.java -- Class used to read serialized objects
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.