Package org.simpleframework.xml.util
Class Dictionary<T extends Entry>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
org.simpleframework.xml.util.Dictionary<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
The
Dictionary object represents a mapped set of entry
objects that can be serialized and deserialized. This is used when
there is a need to load a list of objects that can be mapped using
a name attribute. Using this object avoids the need to implement a
commonly required pattern of building a map of XML element objects.
<dictionary>
<entry name="example">
<element>example text</element>
</entry>
<entry name="example">
<element>example text</element>
</entry>
</dictionary>
This can contain implementations of the Entry object
which contains a required "name" attribute. Implementations of the
entry object can add further XML attributes an elements. This must
be annotated with the ElementList annotation in order
to be serialized and deserialized as an object field.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classTheTableobject is used to represent a map of entries mapped to a string name. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Dictionary.Table<T> Used to map the entries to their configured names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis method is used to add the provided entry to this set.This is used to acquire anEntryfrom the set by its name.iterator()Returns an iterator ofEntryobjects which can be used to remove items from this set.This is used to remove anEntryfrom the set by its name.intsize()This returns the number ofEntryobjects within the dictionary.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
map
Used to map the entries to their configured names.
-
-
Constructor Details
-
Dictionary
public Dictionary()Constructor for theDictionaryobject. This is used to create a set that contains entry objects mapped to an XML attribute name value. Entry objects added to this dictionary can be retrieved using its name value.
-
-
Method Details
-
add
This method is used to add the provided entry to this set. If an entry of the same name already existed within the set then it is replaced with the specifiedEntryobject. -
size
public int size()This returns the number ofEntryobjects within the dictionary. This will use the internal map to acquire the number of entry objects that have been inserted to the map. -
iterator
Returns an iterator ofEntryobjects which can be used to remove items from this set. This will use the internal map object and return the iterator for the map values.- Specified by:
iteratorin interfaceCollection<T extends Entry>- Specified by:
iteratorin interfaceIterable<T extends Entry>- Specified by:
iteratorin interfaceSet<T extends Entry>- Specified by:
iteratorin classAbstractCollection<T extends Entry>- Returns:
- this returns an iterator for the entry objects
-
get
This is used to acquire anEntryfrom the set by its name. This uses the internal map to look for the entry, if the entry exists it is returned, if not this returns null.- Parameters:
name- this is the name of the entry object to retrieve- Returns:
- this returns the entry mapped to the specified name
-
remove
This is used to remove anEntryfrom the set by its name. This uses the internal map to look for the entry, if the entry exists it is returned and removed from the map.- Parameters:
name- this is the name of the entry object to remove- Returns:
- this returns the entry mapped to the specified name
-