Package org.simpleframework.xml.core
Class CompositeListUnion
java.lang.Object
org.simpleframework.xml.core.CompositeListUnion
The
CompositeListUnion object is used to act as a
mediator for multiple converters associated with a particular union
group. This will basically determine which Converter
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 the Group of labels
representing the union declaration.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ContextThis is the current context used for the serialization.private final LabelMapThis contains the labels in the union group keyed by name.private final GroupThis contains the group of labels associated with the union.private final ExpressionThis is the path expression used to represent this union.private final StyleThis is this style associated with the serialization context.private final TypeThis is the type field or method annotated as a union. -
Constructor Summary
ConstructorsConstructorDescriptionCompositeListUnion(Context context, Group group, Expression path, Type type) Constructor for theCompositeListUnionobject. -
Method Summary
Modifier and TypeMethodDescriptionThereadmethod uses the name of the XML element to select a converter to be used to read the instance.Thereadmethod uses the name of the XML element to select a converter to be used to read the instance.private ObjectreadElement(InputNode node) ThereadElementmethod uses the name of the element to select a converter to be used to read the instance.private ObjectreadElement(InputNode node, Object value) ThereadElementmethod uses the name of the element to select a converter to be used to read the instance.private ObjectThereadTextmethod is used to read free text from between the declared elements and add them to a list.private ObjectThereadTextmethod is used to read free text from between the declared elements and add them to a list.booleanThevalidatemethod is used to validate the XML element provided using an associated class schema.voidwrite(OutputNode node, Object source) Thewritemethod uses the name of the XML element to select a converter to be used to write the instance.private voidwrite(OutputNode node, Object item, Label label) Thewritemethod uses the name of the XML element to select a converter to be used to write the instance.private voidwrite(OutputNode node, Collection list) Thewritemethod uses the name of the XML element to select a converter to be used to write the instance.
-
Field Details
-
elements
This contains the labels in the union group keyed by name. -
path
This is the path expression used to represent this union. -
context
This is the current context used for the serialization. -
group
This contains the group of labels associated with the union. -
style
This is this style associated with the serialization context. -
type
This is the type field or method annotated as a union.
-
-
Constructor Details
-
CompositeListUnion
public CompositeListUnion(Context context, Group group, Expression path, Type type) throws Exception Constructor for theCompositeListUnionobject. 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:
Exception
-
-
Method Details
-
read
Thereadmethod 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
ThereadElementmethod 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:
Exception
-
readText
ThereadTextmethod 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:
Exception
-
read
Thereadmethod 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:
readin interfaceConverter- Specified by:
readin 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:
Exception- if a deserialized type cannot be instantiated
-
readElement
ThereadElementmethod 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:
Exception
-
readText
ThereadTextmethod 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:
Exception
-
validate
Thevalidatemethod 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
Thewritemethod 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
Thewritemethod 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:
Exception
-
write
Thewritemethod 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:
Exception
-