Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.simpleframework.xml.util
Class Dictionary<E extends Entry>

    java.lang.Object
      java.util.AbstractCollection<E>
          java.util.AbstractSet<E>
              org.simpleframework.xml.util.Dictionary<E>

All Implemented Interfaces:
  java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public class Dictionary<E extends Entry>

extends java.util.AbstractSet<E>

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.

Author:
  Niall Gallagher
See Also:
  `Entry`

Field Summary
`protected org.simpleframework.xml.util.Dictionary.Table` | `map` Used to map the entries to their configured names.

Constructor Summary
`Dictionary()` Constructor for the `Dictionary` object.

Method Summary
`boolean` | `add(E item)` This method is used to add the provided entry to this set.
`E` | `get(java.lang.String name)` This is used to acquire an `Entry` from the set by its name.
`java.util.Iterator<E>` | `iterator()` Returns an iterator of `Entry` objects which can be used to remove items from this set.
`E` | `remove(java.lang.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.

Methods inherited from class java.util.AbstractSet
`equals, hashCode, removeAll`

Methods inherited from class java.util.AbstractCollection
`addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Set
`addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray`

Field Detail

### map

    protected org.simpleframework.xml.util.Dictionary.Table map

  Used to map the entries to their configured names.

Constructor Detail

### Dictionary

    public Dictionary()

  Constructor for the `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.

Method Detail

### add

    public boolean add(E item)

  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 specified `Entry` object.

  Specified by:
    `add` in interface `java.util.Collection<E extends Entry>`
  Specified by:
    `add` in interface `java.util.Set<E extends Entry>`
  Overrides:
    `add` in class `java.util.AbstractCollection<E extends Entry>`
  Parameters:
    `item` - this is the entry object that is to be inserted

### size

    public int size()

  This returns the number of `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.

  Specified by:
    `size` in interface `java.util.Collection<E extends Entry>`
  Specified by:
    `size` in interface `java.util.Set<E extends Entry>`
  Specified by:
    `size` in class `java.util.AbstractCollection<E extends Entry>`
  Returns:
    this returns the number of entry objects in the set

### iterator

    public java.util.Iterator<E> iterator()

  Returns an iterator of `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.

  Specified by:
    `iterator` in interface `java.lang.Iterable<E extends Entry>`
  Specified by:
    `iterator` in interface `java.util.Collection<E extends Entry>`
  Specified by:
    `iterator` in interface `java.util.Set<E extends Entry>`
  Specified by:
    `iterator` in class `java.util.AbstractCollection<E extends Entry>`
  Returns:
    this returns an iterator for the entry objects

### get

    public E get(java.lang.String name)

  This is used to acquire an `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.

  Parameters:
    `name` - this is the name of the entry object to retrieve
  Returns:
    this returns the entry mapped to the specified name

### remove

    public E remove(java.lang.String name)

  This is used to remove an `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.

  Parameters:
    `name` - this is the name of the entry object to remove
  Returns:
    this returns the entry mapped to the specified name

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD