Package org.simpleframework.xml.core
Class GroupExtractor.Registry
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Label>
,Map<Class,
,Label> SequencedMap<Class,
Label>
- Enclosing class:
GroupExtractor
private static class GroupExtractor.Registry
extends LinkedHashMap<Class,Label>
implements Iterable<Label>
The
Registry
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.-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
isText()
This is used to determine if an annotated list is a text list.iterator()
This is used so that all theLabel
objects that have been added to the registry can be iterated over.void
This is used to register a label based on the name.private void
registerElement
(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.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
(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.This is used to resolve the text for this registry.private Label
resolveText
(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, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Field Details
-
elements
This maintains a mapping between label names and labels. -
text
This label represents the free text between elements.
-
-
Constructor Details
-
Registry
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 Details
-
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
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. -
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
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
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
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
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:
label
- this is the label that is to be registeredname
- this is the name of the label to be registered- Throws:
Exception
-
registerElement
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:
label
- this is the label that is to be registeredname
- this is the name of the label to be registered- Throws:
Exception
-
registerText
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:
Exception
-