public class Dictionary<T extends Entry> extends AbstractSet<T>
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.Entry
Modifier and Type | Field and Description |
---|---|
protected org.simpleframework.xml.util.Dictionary.Table<T> |
map
Used to map the entries to their configured names.
|
Constructor and Description |
---|
Dictionary()
Constructor for the
Dictionary object. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T item)
This method is used to add the provided entry to this set.
|
T |
get(String name)
This is used to acquire an
Entry from the set by
its name. |
Iterator<T> |
iterator()
Returns an iterator of
Entry objects which can be
used to remove items from this set. |
T |
remove(String name)
This is used to remove an
Entry from the set by
its name. |
int |
size()
This returns the number of
Entry objects within
the dictionary. |
equals, hashCode, removeAll
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public Dictionary()
Dictionary
object. 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.public boolean add(T item)
Entry
object.public int size()
Entry
objects within
the dictionary. This will use the internal map to acquire the
number of entry objects that have been inserted to the map.public Iterator<T> iterator()
Entry
objects 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.iterator
in interface Iterable<T extends Entry>
iterator
in interface Collection<T extends Entry>
iterator
in interface Set<T extends Entry>
iterator
in class AbstractCollection<T extends Entry>
public T get(String name)
Entry
from 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.name
- this is the name of the entry object to retrievepublic T remove(String name)
Entry
from 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.name
- this is the name of the entry object to remove