|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An interface to be implemented by classes which are capable of converting an instance of a supported class into a state representation of the object which is serializable. Supported classes may in fact be classes or interfaces.
When possible, classes (not interfaces) should be supported explicitly,
i.e., the getObjectClass()
method of the
SerializableState
returned by getState(Object)
should return the same value which would be returned by invoking
getClass()
on the object passed to
getState(Object)
. In particular, whenever feasible a
Serializer
should not be used to serialize a given object
into a form which when deserialized would yield an instance of the
superclass of the class of which the object is an instance. When it is
not possible to provide a class-specific Serializer
, such
as when a factory class generate subclasses of itself via
factory methods, then permitsSubclasses()
should return
true
; in the case of class-specific Serializer
s
it should return false
.
SerializableState
,
Serializable
Method Summary | |
SerializableState |
getState(Object o,
RenderingHints h)
Converts an object into a state-preserving object which may be serialized. |
Class |
getSupportedClass()
Returns the class or interface which is supported by this Serializer . |
boolean |
permitsSubclasses()
Returns true if and only if it is legal for this
Serializer to be used to serialize a subclass. |
Method Detail |
public Class getSupportedClass()
Serializer
.Class
.public boolean permitsSubclasses()
true
if and only if it is legal for this
Serializer
to be used to serialize a subclass. In
general this method should return false
, i.e., a specific
Serializer
should be registered explicitly for each class.
In some cases this is however not expedient. An example of this is a
Serializer
of classes created by a factory class: the
exact subclasses may not be known but sufficient information may be
able to be extracted from the subclass instance to permit its
serialization by the Serializer
registered for the factory
class.public SerializableState getState(Object o, RenderingHints h)
getSupportedClass()
is a class, i.e., not an interface, then the parameter of
getState()
should be an instance of that class; if
getSupportedClass()
returns an interface, then the
parameter of getState()
should implement that interface.
If the apposite condition is not satisfied then an
IllegalArgumentException
will be thrown.
If the class of the parameter is supported explicitly, i.e., is an
instance of the class returned by getSupportedClass()
, then
the object returned by the getObject()
method of the
generated SerializableState
will be an instance of the
same class. If getSupportedClass()
returns an interface
which the class of the parameter implements, then the object returned
by the getObject()
method of the generated
SerializableState
will be an instance of an unspecified
class which implements that interface.
o
- The object to be converted into a serializable form.h
- Configuration parameters the exact nature of which is
Serializer
-dependent. If null
,
reasonable default settings should be used.IllegalArgumentException
- if o
is
null
, the supported class is an interface
not implemented by the class of which o
is
an instance, or the supported class is not an interface
and getSupportedClass().equals(o.getClass())
returns false
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |