Package org.simpleframework.xml.core
Class GroupExtractor.Registry
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.Class,Label>
-
- org.simpleframework.xml.core.GroupExtractor.Registry
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<Label>
,java.util.Map<java.lang.Class,Label>
- Enclosing class:
- GroupExtractor
private static class GroupExtractor.Registry extends java.util.LinkedHashMap<java.lang.Class,Label> implements java.lang.Iterable<Label>
TheRegistry
object is used to maintain mappings from types to labels. Each of the mappings can be used to dynamically select a label based on the instance type that is to be serialized. This also registers based on the label name.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isText()
This is used to determine if an annotated list is a text list.java.util.Iterator<Label>
iterator()
This is used so that all theLabel
objects that have been added to the registry can be iterated over.void
register(java.lang.Class type, Label label)
This is used to register a label based on the name.private void
registerElement(java.lang.Class type, Label label)
This is used to register a label based on the name.private void
registerText(Label label)
This is used to register the provided label is a text label.Label
resolve(java.lang.Class type)
Here we resolve theLabel
the type is matched with by checking if the type is directly mapped or if any of the super classes of the type are mapped.private Label
resolveElement(java.lang.Class type)
Here we resolve theLabel
the type is matched with by checking if the type is directly mapped or if any of the super classes of the type are mapped.Label
resolveText()
This is used to resolve the text for this registry.private Label
resolveText(java.lang.Class type)
This is used to resolve the text for this registry.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Constructor Detail
-
Registry
public Registry(LabelMap elements)
Constructor for theRegistry
object. This is used to register label instances using both the name and type of the label. Registration in this way ensures that each label can be dynamically selected.- Parameters:
elements
- this contains name to label mappings
-
-
Method Detail
-
isText
public boolean isText()
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.- Returns:
- returns true if the label represents a text list
-
iterator
public java.util.Iterator<Label> iterator()
This is used so that all theLabel
objects that have been added to the registry can be iterated over. Iteration over the labels allows for easy validation.- Specified by:
iterator
in interfacejava.lang.Iterable<Label>
- Returns:
- this returns an iterator for all the labels
-
resolveText
public Label resolveText()
This is used to resolve the text for this registry. If there is a text annotation declared with the union then this will return aLabel
that can be used to convert the free text between elements in to strings.- Returns:
- this returns the label representing free text
-
resolve
public Label resolve(java.lang.Class type)
Here we resolve theLabel
the type is matched with by checking if the type is directly mapped or if any of the super classes of the type are mapped. If there are no classes in the hierarchy of the type that are mapped then this will return null otherwise the label will be returned.- Parameters:
type
- this is the type to resolve the label for- Returns:
- this will return the label that is best matched
-
resolveText
private Label resolveText(java.lang.Class type)
This is used to resolve the text for this registry. If there is a text annotation declared with the union then this will return aLabel
that can be used to convert the free text between elements in to strings.- Parameters:
type
- this is the type to resolve the text as- Returns:
- this returns the label representing free text
-
resolveElement
private Label resolveElement(java.lang.Class type)
Here we resolve theLabel
the type is matched with by checking if the type is directly mapped or if any of the super classes of the type are mapped. If there are no classes in the hierarchy of the type that are mapped then this will return null otherwise the label will be returned.- Parameters:
type
- this is the type to resolve the label for- Returns:
- this will return the label that is best matched
-
register
public void register(java.lang.Class type, Label label) throws java.lang.Exception
This is used to register a label based on the name. This is done to ensure the label instance can be dynamically found during the deserialization process by providing the name.- Parameters:
name
- this is the name of the label to be registeredlabel
- this is the label that is to be registered- Throws:
java.lang.Exception
-
registerElement
private void registerElement(java.lang.Class type, Label label) throws java.lang.Exception
This is used to register a label based on the name. This is done to ensure the label instance can be dynamically found during the deserialization process by providing the name.- Parameters:
name
- this is the name of the label to be registeredlabel
- this is the label that is to be registered- Throws:
java.lang.Exception
-
registerText
private void registerText(Label label) throws java.lang.Exception
This is used to register the provided label is a text label. Registration as a text label can only happen if the field or method has aText
annotation declared on it.- Parameters:
label
- this is the label to register as text- Throws:
java.lang.Exception
-
-