|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Strategy
The Strategy
interface represents a strategy that can be
used to resolve and load the Class
objects that compose
a serializable object. A strategy implementation will make use of the
provided attribute node map to extract details that can be used to
determine what type of object must be used.
<xml version="1.0"> <example class="some.example.Demo"> <integer>2</integer> </example>The above example shows how the default strategy augments elements with "class" attributes that describe the type that should be used to instantiate a field when an object is deserialized. So looking at the above example the root element would be a "some.example.Demo".
Custom Strategy
implementations give the persister a
chance to intercept the class loading and type resolution for XML
documents. It also opens up the possibility for class versioning.
To establish contextual information a Map
object can be
used. The map object is a transient object that is created and used
for the duration of a single operation of the persister.
Persister
Method Summary | |
---|---|
Value |
read(Type type,
NodeMap<InputNode> node,
Map map)
This is used to resolve and load a class for the given element. |
boolean |
write(Type type,
Object value,
NodeMap<OutputNode> node,
Map map)
This is used to attach attribute values to the given node map during the serialization process. |
Method Detail |
---|
Value read(Type type, NodeMap<InputNode> node, Map map) throws Exception
type
- this is the type of the root element expectednode
- this is the node map used to resolve an overridemap
- this is used to maintain contextual information
Exception
- thrown if the class cannot be resolvedboolean write(Type type, Object value, NodeMap<OutputNode> node, Map map) throws Exception
type
- this is the declared class for the field usedvalue
- this is the instance variable being serializednode
- this is the node map used to represent the valuemap
- this is used to maintain contextual information
Exception
- thrown if the details cannot be set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |