Package org.simpleframework.xml.strategy
Class WriteGraph
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
String>
The
WriteGraph
object is used to build the graph that
is used to represent the serialized object and its references. The
graph is stored in an IdentityHashMap
which will
store the objects in such a way that this graph object can tell if
it has already been written to the XML document. If an object has
already been written to the XML document an reference attribute
is added to the element representing the object and serialization
of that object is complete, that is, no more elements are written.
The attribute values written by this are unique strings, which allows the deserialization process to identify object references easily. By default these references are incrementing integers however for deserialization they can be any unique string value.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
This is the label used to mark the type of an object.private final String
This is used to specify the length of array instances.private final String
This is the attribute used to mark the identity of an object.private final String
This is the attribute used to refer to an existing instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
This is used to write the XML element attributes representing the serialized object instance.private Class
writeArray
(Class field, Object value, NodeMap node) This is used to add a length attribute to the element due to the fact that the serialized value is an array.private boolean
writeReference
(Object value, NodeMap node) This is used to write the XML element attributes representing the serialized object instance.Methods inherited from class java.util.IdentityHashMap
clear, clone, containsKey, containsValue, entrySet, equals, forEach, get, hashCode, isEmpty, keySet, put, putAll, remove, remove, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, merge, putIfAbsent, replace
-
Field Details
-
length
This is used to specify the length of array instances. -
label
This is the label used to mark the type of an object. -
mark
This is the attribute used to mark the identity of an object. -
refer
This is the attribute used to refer to an existing instance.
-
-
Constructor Details
-
WriteGraph
Constructor for theWriteGraph
object. This is used to build the graph used for writing objects to the XML document. The specified strategy is used to acquire the names of the special attributes used during the serialization.- Parameters:
contract
- this is the name scheme used by the strategy
-
-
Method Details
-
write
This is used to write the XML element attributes representing the serialized object instance. If the object has already been serialized to the XML document then a reference attribute is inserted and this returns true, if not, then this will write a unique identity marker attribute and return false.- Parameters:
type
- this is the type of the object to be serializedvalue
- this is the instance that is to be serializednode
- this is the node that contains the attributes- Returns:
- returns true if the element has been fully written
-
writeReference
This is used to write the XML element attributes representing the serialized object instance. If the object has already been serialized to the XML document then a reference attribute is inserted and this returns true, if not, then this will write a unique identity marker attribute and return false.- Parameters:
value
- this is the instance that is to be serializednode
- this is the node that contains the attributes- Returns:
- returns true if the element has been fully written
-
writeArray
This is used to add a length attribute to the element due to the fact that the serialized value is an array. The length of the array is acquired and inserted in to the attributes.- Parameters:
field
- this is the field type for the array to setvalue
- this is the actual value for the array to setnode
- this is the map of attributes for the element- Returns:
- returns the array component type that is set
-