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 AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisText()This is used to determine if an annotated list is a text list.iterator()This is used so that all theLabelobjects that have been added to the registry can be iterated over.voidThis is used to register a label based on the name.private voidregisterElement(Class type, Label label) This is used to register a label based on the name.private voidregisterText(Label label) This is used to register the provided label is a text label.Here we resolve theLabelthe 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 LabelresolveElement(Class type) Here we resolve theLabelthe 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 LabelresolveText(Class type) This is used to resolve the text for this registry.Methods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from interface 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 theRegistryobject. 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
-
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 aLabelthat 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 theLabelthe 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 aLabelthat 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 theLabelthe 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
-