|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simpleframework.xml.convert.AnnotationStrategy
public class AnnotationStrategy
The AnnotationStrategy
object is used to intercept
the serialization process and delegate to custom converters. This
strategy uses the Convert
annotation to specify the
converter to use for serialization and deserialization. If there
is no annotation present on the field or method representing the
object instance to be serialized then this acts as a transparent
proxy to an internal strategy.
By default the TreeStrategy
is used to perform the
normal serialization process should there be no annotation
specifying a converter to use. However, any implementation can
be used, including the CycleStrategy
, which handles
cycles in the object graph. To specify the internal strategy to
use it can be provided in the constructor.
TreeStrategy
Constructor Summary | |
---|---|
AnnotationStrategy()
Constructor for the AnnotationStrategy object. |
|
AnnotationStrategy(Strategy strategy)
Constructor for the AnnotationStrategy object. |
Method Summary | |
---|---|
Value |
read(Type type,
NodeMap<InputNode> node,
Map map)
This is used to read the Value which will be used
to represent the deserialized object. |
boolean |
write(Type type,
Object value,
NodeMap<OutputNode> node,
Map map)
This is used to serialize a representation of the object value provided. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationStrategy()
AnnotationStrategy
object.
This creates a strategy that intercepts serialization on any
annotated method or field. If no annotation exists then this
delegates to an internal TreeStrategy
object.
public AnnotationStrategy(Strategy strategy)
AnnotationStrategy
object.
This creates a strategy that intercepts serialization on any
annotated method or field. If no annotation exists then this
will delegate to the Strategy
provided.
strategy
- the internal strategy to delegate toMethod Detail |
---|
public Value read(Type type, NodeMap<InputNode> node, Map map) throws Exception
Value
which will be used
to represent the deserialized object. If there is an annotation
present then the value will contain an object instance. If it
does not then it is up to the internal strategy to determine
what the returned value contains.
read
in interface Strategy
type
- this is the type that represents a method or fieldnode
- this is the node representing the XML elementmap
- this is the session map that contain variables
Exception
- thrown if the class cannot be resolvedpublic boolean write(Type type, Object value, NodeMap<OutputNode> node, Map map) throws Exception
Convert
annotation present
on the provided type then this will use the converter specified
to serialize a representation of the object. If however there
is no annotation then this will delegate to the internal
strategy. This returns true if the serialization has completed.
write
in interface Strategy
type
- this is the type that represents the field or methodvalue
- this is the object instance to be serializednode
- this is the XML element to be serialized tomap
- this is the session map used by the serializer
Exception
- thrown if the details cannot be set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |