Package org.simpleframework.xml.core
Class LabelExtractor
java.lang.Object
org.simpleframework.xml.core.LabelExtractor
The
LabelExtractor
object is used to create instances of
the Label
object that can be used to convert an XML
node into a Java object. Each label created requires the contact it
represents and the XML annotation it is marked with.
The Label
objects created by this factory a selected
using the XML annotation type. If the annotation type is not known
the factory will throw an exception, otherwise a label instance
is created that will expose the properties of the annotation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
TheLabelBuilder
object will create a constructor that can be used to instantiate the correct label for the XML annotation specified.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Cache
<LabelGroup> This is used to cache the list of labels that have been created.private final Format
Contains the format that is associated with the serializer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Annotation[]
getAnnotations
(Annotation label) This is used to extract the individual annotations associated with the union annotation provided.private LabelExtractor.LabelBuilder
getBuilder
(Annotation label) Creates an entry that is used to select the constructor for the label.private Constructor
getConstructor
(Annotation label) Creates a constructor that can be used to instantiate the label used to represent the specified annotation.private LabelGroup
getGroup
(Contact contact, Annotation label, Object key) Creates aLabelGroup
using the provided contact and annotation.private Object
getKey
(Contact contact, Annotation label) This is used to create a key to uniquely identify a label that is associated with a contact.getLabel
(Contact contact, Annotation label) Creates aLabel
using the provided contact and XML annotation.private Label
getLabel
(Contact contact, Annotation label, Annotation entry) Creates aLabel
using the provided contact and XML annotation.private LabelGroup
getLabels
(Contact contact, Annotation label) Creates aLabelGroup
using the provided contact and annotation.getList
(Contact contact, Annotation label) Creates aList
using the provided contact and XML annotation.private LabelGroup
getSingle
(Contact contact, Annotation label) Creates aLabelGroup
using the provided contact and annotation.private LabelGroup
getUnion
(Contact contact, Annotation label) Creates aLabelGroup
using the provided contact and annotation.
-
Field Details
-
cache
This is used to cache the list of labels that have been created. -
format
Contains the format that is associated with the serializer.
-
-
Constructor Details
-
LabelExtractor
Constructor for theLabelExtractor
object. This creates an extractor that will extract labels for a specific contact. Labels are cached within the extractor so that they can be looked up without having to rebuild it each time.- Parameters:
format
- this is the format used by the serializer
-
-
Method Details
-
getLabel
Creates aLabel
using the provided contact and XML annotation. The label produced contains all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the label instantiated for the contact
- Throws:
Exception
-
getList
Creates aList
using the provided contact and XML annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getGroup
Creates aLabelGroup
using the provided contact and annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contactkey
- this is the key that uniquely represents the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getLabels
Creates aLabelGroup
using the provided contact and annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getSingle
Creates aLabelGroup
using the provided contact and annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getUnion
Creates aLabelGroup
using the provided contact and annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getAnnotations
This is used to extract the individual annotations associated with the union annotation provided. If the annotation does not represent a union then this will return null.- Parameters:
label
- this is the annotation to extract from- Returns:
- this returns an array of annotations from the union
- Throws:
Exception
-
getLabel
Creates aLabel
using the provided contact and XML annotation. The label produced contains all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contactentry
- this is the annotation used for the entries- Returns:
- returns the label instantiated for the field
- Throws:
Exception
-
getKey
This is used to create a key to uniquely identify a label that is associated with a contact. A key contains the contact type, the declaring class, the name, and the annotation type. This will uniquely identify the label within the class.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- this returns the key associated with the label
-
getConstructor
Creates a constructor that can be used to instantiate the label used to represent the specified annotation. The constructor created by this method takes two arguments, a contact object and anAnnotation
of the type specified.- Parameters:
label
- the XML annotation representing the label- Returns:
- returns a constructor for instantiating the label
- Throws:
Exception
-
getBuilder
Creates an entry that is used to select the constructor for the label. Each label must implement a constructor that takes a contact and the specific XML annotation for that field. If the annotation is not know this method throws an exception.- Parameters:
label
- the XML annotation used to create the label- Returns:
- this returns the entry used to create a constructor
- Throws:
Exception
-