Class GroupExtractor
java.lang.Object
org.simpleframework.xml.core.GroupExtractor
- All Implemented Interfaces:
Group
The
GroupExtractor represents an extractor for labels
associated with a particular union annotation. This extractor
registers Label by name and by type. Acquiring
the label by type allows the serialization process to dynamically
select a label, and thus converter, based on the instance type.
On deserialization a label is dynamically selected based on name.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classTheRegistryobject is used to maintain mappings from types to labels. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LabelMapThis contains each label registered by label name.private final ExtractorFactoryThis represents a factory for creating union extractors.private final AnnotationThis represents the union label to be used for this group.private final GroupExtractor.RegistryThis contains each label registered by name and by type. -
Constructor Summary
ConstructorsConstructorDescriptionGroupExtractor(Contact contact, Annotation label, Format format) Constructor for theGroupExtractorobject. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidextract()This is used to extract the labels associated with the group.private voidThis is used to extract the labels associated with the group.private voidextract(Extractor extractor, Annotation value) This is used to extract the labels associated with the group.This is used to acquire aLabelMapcontaining the labels available to the group.This is used to acquire aLabelbased on the type of an object.String[]getNames()This is used to acquire the names for each label associated with thisGroupinstance.String[]getPaths()This is used to acquire the paths for each label associated with thisGroupinstance.getText()This is used to get aLabelthat represents the text between elements on an element union.booleanisDeclared(Class type) This is used to determine if a type has been declared by the annotation associated with the group.booleanisInline()This is used to determine if the group is inline.booleanThis is used to determine if an annotated list is a text list.booleanThis is used to determine if the associated type represents a label defined within the union group.toString()This returns a string representation of the union group.
-
Field Details
-
factory
This represents a factory for creating union extractors. -
label
This represents the union label to be used for this group. -
registry
This contains each label registered by name and by type. -
elements
This contains each label registered by label name.
-
-
Constructor Details
-
GroupExtractor
Constructor for theGroupExtractorobject. This will create an extractor for the provided union annotation. Each individual declaration within the union is extracted and made available within the group.- Parameters:
contact- this is the annotated field or methodlabel- this is the label associated with the contactformat- this is the format used by this extractor- Throws:
Exception
-
-
Method Details
-
getNames
-
getPaths
-
getElements
This is used to acquire aLabelMapcontaining the labels available to the group. Providing a context object ensures that each of the labels is mapped to a name that is styled according to its internal style.- Specified by:
getElementsin interfaceGroup- Returns:
- this returns a label map containing the labels
- Throws:
Exception
-
getLabel
This is used to acquire aLabelbased on the type of an object. Selecting a label based on the type ensures that the serialization process can dynamically convert an object to XML. If the type is not supported, this returns null. -
getText
This is used to get aLabelthat represents the text between elements on an element union. Providing a label here ensures that the free text found between elements can be converted in to strings and added to the list. -
isValid
This is used to determine if the associated type represents a label defined within the union group. If the label exists this returns true, if not then this returns false.- Parameters:
type- this is the type to check for- Returns:
- this returns true if a label for the type exists
-
isDeclared
This is used to determine if a type has been declared by the annotation associated with the group. Unlike determining if the type is valid this will not consider super types.- Parameters:
type- this is the type to determine if it is declared- Returns:
- this returns true if the type has been declared
-
isInline
public boolean isInline()This is used to determine if the group is inline. A group is inline if all of the elements in the group is inline. If any of theLabelobjects in the group is not inline then the entire group is not inline, although this is unlikely. -
isTextList
public boolean isTextList()This is used to determine if an annotated list is a text list. A text list is a list of elements that also accepts free text. Typically this will be an element list union that will allow unstructured XML such as XHTML to be parsed.- Specified by:
isTextListin interfaceGroup- Returns:
- returns true if the label represents a text list
-
extract
-
extract
This is used to extract the labels associated with the group. Extraction will instantiate aLabelobject for an individual annotation declared within the union. Each of the label instances is then registered by both name and type.- Parameters:
extractor- this is the extractor to get labels for- Throws:
Exception
-
extract
This is used to extract the labels associated with the group. Extraction will instantiate aLabelobject for an individual annotation declared within the union. Each of the label instances is then registered by both name and type.- Parameters:
extractor- this is the extractor to get labels forvalue- this is an individual annotation declared- Throws:
Exception
-
toString
This returns a string representation of the union group. Providing a string representation in this way ensures that the group can be used in exception messages and for any debugging.
-