Package org.simpleframework.xml.core
Class PrimitiveList
java.lang.Object
org.simpleframework.xml.core.PrimitiveList
- All Implemented Interfaces:
Converter
The
PrimitiveList
object is used to convert an element
list to a collection of element entries. This in effect performs a
serialization and deserialization of primitive entry elements for
the collection object. On serialization each objects type must be
checked against the XML annotation entry so that it is serialized
in a form that can be deserialized.
<list> <entry>example one</entry> <entry>example two</entry> <entry>example three</entry> <entry>example four</entry> </list>For the above XML element list the element
entry
is
used to wrap the primitive string value. This wrapping XML element
is configurable and defaults to the lower case string for the name
of the class it represents. So, for example, if the primitive type
is an int
the enclosing element will be called int.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Type
This is the type of object that will be held within the list.private final CollectionFactory
This factory is used to create a suitable collection list.private final String
This is the name that each array element is wrapped with.private final Primitive
This performs the serialization of the primitive element. -
Constructor Summary
ConstructorsConstructorDescriptionPrimitiveList
(Context context, Type type, Type entry, String parent) Constructor for thePrimitiveList
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
isOverridden
(OutputNode node, Object value) This is used to determine whether the specified value has been overridden by the strategy.private Object
Thispopulate
method wll read the XML element list from the provided node and deserialize its children as entry types.Thisread
method will read the XML element list from the provided node and deserialize its children as entry types.Thisread
method will read the XML element map from the provided node and deserialize its children as entry types.boolean
Thisvalidate
method wll validate the XML element list from the provided node and validate its children as entry types.private boolean
Thisvalidate
method will validate the XML element list from the provided node and validate its children as entry types.void
write
(OutputNode node, Object source) Thiswrite
method will write the specified object to the given XML element as as list entries.
-
Field Details
-
factory
This factory is used to create a suitable collection list. -
root
This performs the serialization of the primitive element. -
parent
This is the name that each array element is wrapped with. -
entry
This is the type of object that will be held within the list.
-
-
Constructor Details
-
PrimitiveList
Constructor for thePrimitiveList
object. This is given the list type and entry type to be used. The list type is theCollection
implementation that deserialized entry objects are inserted into.- Parameters:
context
- this is the context object used for serializationtype
- this is the collection type for the list usedentry
- the primitive type to be stored within the listparent
- this is the name to wrap the list element with
-
-
Method Details
-
read
Thisread
method will read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element. -
read
Thisread
method will read the XML element map from the provided node and deserialize its children as entry types. Each entry type must contain a key and value so that the entry can be inserted in to the map as a pair. If either the key or value is composite it is read as a root object, which means itsRoot
annotation must be present and the name of the object element must match that root element name. -
populate
Thispopulate
method wll read the XML element list from the provided node and deserialize its children as entry types. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element.- Parameters:
node
- this is the XML element that is to be deserializedresult
- this is the collection that is to be populated- Returns:
- this returns the item to attach to the object contact
- Throws:
Exception
-
validate
Thisvalidate
method wll validate the XML element list from the provided node and validate its children as entry types. This will validate each entry type as a primitive value. In order to do this the parent string provided forms the element. -
validate
Thisvalidate
method will validate the XML element list from the provided node and validate its children as entry types. This will validate each entry type as a primitive value. In order to do this the parent string provided forms the element.- Parameters:
node
- this is the XML element that is to be deserializedtype
- this is the type to validate against the input node- Returns:
- true if the element matches the XML schema class given
- Throws:
Exception
-
write
Thiswrite
method will write the specified object to the given XML element as as list entries. Each entry within the given list must be assignable to the given primitive type. This will deserialize each entry type as a primitive value. In order to do this the parent string provided forms the element. -
isOverridden
This is used to determine whether the specified value has been overridden by the strategy. If the item has been overridden then no more serialization is require for that value, this is effectively telling the serialization process to stop writing.- Parameters:
node
- the node that a potential override is written tovalue
- this is the object instance to be serialized- Returns:
- returns true if the strategy overrides the object
- Throws:
Exception
-