Package org.simpleframework.xml.core
Class CompositeInlineList
java.lang.Object
org.simpleframework.xml.core.CompositeInlineList
The
CompositeInlineList
object is used to convert an
group of elements in to a collection of element entries. This is
used when a containing element for a list is not required. It
extracts the elements by matching elements to name of the type
that the annotated field or method requires. This enables these
element entries to exist as siblings to other objects within the
object. One restriction is that the Root
annotation
for each of the types within the list must be the same.
<entry attribute="one"> <text>example text value</text> </entry> <entry attribute="two"> <text>some other example</text> </entry> <entry attribute="three"> <text>yet another example</text> </entry>For the above XML element list the element
entry
is
contained within the list. Each entry element is thus deserialized
as a root element and then inserted into the list. This enables
lists to be composed from XML documents. For serialization the
reverse is done, each element taken from the collection is written
as a root element to the owning element to create the list.
Entry objects do not need to be of the same type.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Type
This is the entry type for elements within the list.private final CollectionFactory
This factory is used to create a suitable collection list.private final String
This represents the name of the entry elements to write.private final Traverser
This performs the traversal used for object serialization.private final Type
This represents the actual method or field for the list. -
Constructor Summary
ConstructorsConstructorDescriptionCompositeInlineList
(Context context, Type type, Type entry, String name) Constructor for theCompositeInlineList
object. -
Method Summary
Modifier and TypeMethodDescriptionThisread
method wll read the XML element list from the provided node and deserialize its children as entry types.private Object
Thisread
method will read the XML element from the provided node.Thisread
method will read the XML element list from the provided node and deserialize its children as entry types.private Object
read
(InputNode node, Collection list) Thisread
method wll read the XML element list from the provided node and deserialize its children as entry types.boolean
Thisread
method will read the XML element list from the provided node and deserialize 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.void
write
(OutputNode node, Collection list) 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 traversal used for object serialization. -
name
This represents the name of the entry elements to write. -
entry
This is the entry type for elements within the list. -
type
This represents the actual method or field for the list.
-
-
Constructor Details
-
CompositeInlineList
Constructor for theCompositeInlineList
object. This is given the list type and entry type to be used. The list type is theCollection
implementation that is used to collect the deserialized entry objects from the XML source.- Parameters:
context
- this is the context object used for serializationtype
- this is the collection type for the list usedentry
- the entry type to be stored within the listname
- this is the name of the entries used for this list
-
-
Method Details
-
read
Thisread
method wll read the XML element list from the provided node and deserialize its children as entry types. This will each entry type is deserialized as a root type, that is, itsRoot
annotation must be present and the name of the entry element must match that root element name. -
read
Thisread
method will read the XML element list from the provided node and deserialize its children as entry types. This will each entry type is deserialized as a root type, that is, itsRoot
annotation must be present and the name of the entry element must match that root element name.- Specified by:
read
in interfaceConverter
- Specified by:
read
in interfaceRepeater
- Parameters:
node
- this is the XML element that is to be deserializedvalue
- this is the value to read the objects in to- Returns:
- this returns the item to attach to the object contact
- Throws:
Exception
- if a deserialized type cannot be instantiated
-
read
Thisread
method wll read the XML element list from the provided node and deserialize its children as entry types. This will each entry type is deserialized as a root type, that is, itsRoot
annotation must be present and the name of the entry element must match that root element name.- Parameters:
node
- this is the XML element that is to be deserializedlist
- this is the collection that is to be populated- Returns:
- this returns the item to attach to the object contact
- Throws:
Exception
-
read
Thisread
method will read the XML element from the provided node. This checks to ensure that the deserialized type is the same as the entry type provided. If the types are not the same then an exception is thrown. This is done to ensure each node in the collection contain the same root annotation.- Parameters:
node
- this is the XML element that is to be deserializedexpect
- this is the type expected of the deserialized type- Returns:
- this returns the item to attach to the object contact
- Throws:
Exception
-
validate
Thisread
method will read the XML element list from the provided node and deserialize its children as entry types. This will each entry type is deserialized as a root type, that is, itsRoot
annotation must be present and the name of the entry element must match that root element name. -
write
Thiswrite
method will write the specified object to the given XML element as as list entries. Each entry within the given collection must be assignable from the annotated type specified within theElementList
annotation. Each entry is serialized as a root element, that is, itsRoot
annotation is used to extract the name. -
write
Thiswrite
method will write the specified object to the given XML element as as list entries. Each entry within the given collection must be assignable from the annotated type specified within theElementList
annotation. Each entry is serialized as a root element, that is, itsRoot
annotation is used to extract the name.- Parameters:
node
- this is the XML element container to be populatedlist
- this is the source collection to be serialized- Throws:
Exception
-