|
|||||||||
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 | |
---|---|
Type |
getElement(java.lang.Class field,
NodeMap node,
java.util.Map map)
This is used to resolve and load a class for the given element. |
Type |
getRoot(java.lang.Class field,
NodeMap node,
java.util.Map map)
This is used to resolve and load the root class type. |
boolean |
setElement(java.lang.Class field,
java.lang.Object value,
NodeMap node,
java.util.Map map)
This is used to attach attribute values to the given node map during the serialization process. |
boolean |
setRoot(java.lang.Class field,
java.lang.Object value,
NodeMap node,
java.util.Map map)
This is used to attach attributes values to the given node map during the serialization process. |
Method Detail |
---|
Type getRoot(java.lang.Class field, NodeMap node, java.util.Map map) throws java.lang.Exception
getElement
because the root element may contain details like the location
of the byte codes, much like the RMI codebase annotation, or
the version of the package for example "some.package.v2". This
must return null if a type cannot be resolved.
field
- 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
java.lang.Exception
- thrown if the class cannot be resolvedType getElement(java.lang.Class field, NodeMap node, java.util.Map map) throws java.lang.Exception
field
- 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
java.lang.Exception
- thrown if the class cannot be resolvedboolean setRoot(java.lang.Class field, java.lang.Object value, NodeMap node, java.util.Map map) throws java.lang.Exception
field
- 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
java.lang.Exception
- thrown if the details cannot be setboolean setElement(java.lang.Class field, java.lang.Object value, NodeMap node, java.util.Map map) throws java.lang.Exception
field
- 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
java.lang.Exception
- thrown if the details cannot be set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |