Package org.simpleframework.xml.core
Class CompositeListUnion
- java.lang.Object
-
- org.simpleframework.xml.core.CompositeListUnion
-
class CompositeListUnion extends java.lang.Object implements Repeater
TheCompositeListUnion
object is used to act as a mediator for multiple converters associated with a particular union group. This will basically determine whichConverter
should be delegated to based on either the XML element name being read or the type of the instance object being written. Selection of the converter is done by consulting theGroup
of labels representing the union declaration.
-
-
Field Summary
Fields Modifier and Type Field Description private Context
context
This is the current context used for the serialization.private LabelMap
elements
This contains the labels in the union group keyed by name.private Group
group
This contains the group of labels associated with the union.private Expression
path
This is the path expression used to represent this union.private Style
style
This is this style associated with the serialization context.private Type
type
This is the type field or method annotated as a union.
-
Constructor Summary
Constructors Constructor Description CompositeListUnion(Context context, Group group, Expression path, Type type)
Constructor for theCompositeListUnion
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
read(InputNode node)
Theread
method uses the name of the XML element to select a converter to be used to read the instance.java.lang.Object
read(InputNode node, java.lang.Object value)
Theread
method uses the name of the XML element to select a converter to be used to read the instance.private java.lang.Object
readElement(InputNode node)
ThereadElement
method uses the name of the element to select a converter to be used to read the instance.private java.lang.Object
readElement(InputNode node, java.lang.Object value)
ThereadElement
method uses the name of the element to select a converter to be used to read the instance.private java.lang.Object
readText(InputNode node)
ThereadText
method is used to read free text from between the declared elements and add them to a list.private java.lang.Object
readText(InputNode node, java.lang.Object value)
ThereadText
method is used to read free text from between the declared elements and add them to a list.boolean
validate(InputNode node)
Thevalidate
method is used to validate the XML element provided using an associated class schema.void
write(OutputNode node, java.lang.Object source)
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance.private void
write(OutputNode node, java.lang.Object item, Label label)
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance.private void
write(OutputNode node, java.util.Collection list)
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance.
-
-
-
Field Detail
-
elements
private final LabelMap elements
This contains the labels in the union group keyed by name.
-
path
private final Expression path
This is the path expression used to represent this union.
-
context
private final Context context
This is the current context used for the serialization.
-
group
private final Group group
This contains the group of labels associated with the union.
-
style
private final Style style
This is this style associated with the serialization context.
-
type
private final Type type
This is the type field or method annotated as a union.
-
-
Constructor Detail
-
CompositeListUnion
public CompositeListUnion(Context context, Group group, Expression path, Type type) throws java.lang.Exception
Constructor for theCompositeListUnion
object. This is used to create a converter that delegates to other associated converters within the union group depending on the XML element name being read or the instance type that is being written.- Parameters:
context
- this is the context used for the serializationgroup
- this is the union group used for delegationpath
- this is the path expression representing this uniontype
- this is the annotated field or method to be used- Throws:
java.lang.Exception
-
-
Method Detail
-
read
public java.lang.Object read(InputNode node) throws java.lang.Exception
Theread
method uses the name of the XML element to select a converter to be used to read the instance. Selection of the converter is done by looking up the associated label from the union group using the element name. Once the converter has been selected it is used to read the instance.
-
readElement
private java.lang.Object readElement(InputNode node) throws java.lang.Exception
ThereadElement
method uses the name of the element to select a converter to be used to read the instance. Selection of the converter is done by looking up the associated label from the union group using the element name. Once the converter has been selected it is used to read the instance.- Parameters:
node
- this is the XML element used to read the instance- Returns:
- this is the instance that has been read by this
- Throws:
java.lang.Exception
-
readText
private java.lang.Object readText(InputNode node) throws java.lang.Exception
ThereadText
method is used to read free text from between the declared elements and add them to a list. Consuming free text in this manner enables an element list union to parse unstructured XML such as XHTML.- Parameters:
node
- this is the node to consume the free text from- Returns:
- this returns the list with the text added to it
- Throws:
java.lang.Exception
-
read
public java.lang.Object read(InputNode node, java.lang.Object value) throws java.lang.Exception
Theread
method uses the name of the XML element to select a converter to be used to read the instance. Selection of the converter is done by looking up the associated label from the union group using the element name. Once the converter has been selected it is used to read the instance.- Specified by:
read
in interfaceConverter
- Specified by:
read
in interfaceRepeater
- Parameters:
node
- this is the XML element used to read the instancevalue
- this is the value that is to be repeated- Returns:
- this is the instance that has been read by this
- Throws:
java.lang.Exception
- if a deserialized type cannot be instantiated
-
readElement
private java.lang.Object readElement(InputNode node, java.lang.Object value) throws java.lang.Exception
ThereadElement
method uses the name of the element to select a converter to be used to read the instance. Selection of the converter is done by looking up the associated label from the union group using the element name. Once the converter has been selected it is used to read the instance.- Parameters:
node
- this is the XML element used to read the instancevalue
- this is the value that is to be repeated- Returns:
- this is the instance that has been read by this
- Throws:
java.lang.Exception
-
readText
private java.lang.Object readText(InputNode node, java.lang.Object value) throws java.lang.Exception
ThereadText
method is used to read free text from between the declared elements and add them to a list. Consuming free text in this manner enables an element list union to parse unstructured XML such as XHTML.- Parameters:
node
- this is the node to consume the free text fromvalue
- this is the value that is to be repeated- Returns:
- this returns the list with the text added to it
- Throws:
java.lang.Exception
-
validate
public boolean validate(InputNode node) throws java.lang.Exception
Thevalidate
method is used to validate the XML element provided using an associated class schema. The schema is selected using the name of the XML element to acquire the associated converter. Once the converter has been acquired it is delegated to and validated against it.
-
write
public void write(OutputNode node, java.lang.Object source) throws java.lang.Exception
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance. Selection of the converter is done by looking up the associated label from the union group using the instance type. Once the converter has been selected it is used to write the instance.
-
write
private void write(OutputNode node, java.util.Collection list) throws java.lang.Exception
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance. Selection of the converter is done by looking up the associated label from the union group using the instance type. Once the converter has been selected it is used to write the instance.- Parameters:
node
- this is the XML element used to write the instancelist
- this is the value that is to be written- Throws:
java.lang.Exception
-
write
private void write(OutputNode node, java.lang.Object item, Label label) throws java.lang.Exception
Thewrite
method uses the name of the XML element to select a converter to be used to write the instance. Selection of the converter is done by looking up the associated label from the union group using the instance type. Once the converter has been selected it is used to write the instance.- Parameters:
node
- this is the XML element used to write the instanceitem
- this is the individual list entry to be serializedlabel
- this is the label to used to acquire the converter- Throws:
java.lang.Exception
-
-