Class LabelMap

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Label>, Map<String,Label>, SequencedMap<String,Label>

class LabelMap extends LinkedHashMap<String,Label> implements Iterable<Label>
The LabelMap object represents a map that contains string label mappings. This is used for convenience as a typedef like construct to avoid having declare the generic type whenever it is referenced. Also this allows Label values from the map to be iterated within for each loops.
See Also:
  • Field Details

    • policy

      private final Policy policy
      This is policy used to determine the type of mappings used.
  • Constructor Details

    • LabelMap

      public LabelMap()
      Constructor for the LabelMap object is used to create an empty map. This is used for convenience as a typedef like construct which avoids having to use the generic type.
    • LabelMap

      public LabelMap(Policy policy)
      Constructor for the LabelMap object is used to create an empty map. This is used for convenience as a typedef like construct which avoids having to use the generic type.
  • Method Details

    • iterator

      public Iterator<Label> iterator()
      This allows the Label objects within the label map to be iterated within for each loops. This will provide all remaining label objects within the map. The iteration order is not maintained so label objects may be given in any sequence.
      Specified by:
      iterator in interface Iterable<Label>
      Returns:
      this returns an iterator for existing label objects
    • getLabel

      public Label getLabel(String name)
      This performs a remove that will remove the label from the map and return that label. This method allows the values within the map to be exclusively taken one at a time, which enables the user to determine which labels remain.
      Parameters:
      name - this is the name of the element of attribute
      Returns:
      this is the label object representing the XML node
    • getKeys

      public String[] getKeys() throws Exception
      This is used to acquire the paths and names for each label in this map. Extracting the names and paths in this manner allows a labels to be referred to by either. If there are no elements registered with this map this will return an empty set.
      Returns:
      this returns the names and paths for each label
      Throws:
      Exception
    • getPaths

      public String[] getPaths() throws Exception
      This is used to acquire the paths for each label in this map. Extracting the paths in this manner allows them to be used to reference the labels using paths only.
      Returns:
      this returns the paths for each label in this map
      Throws:
      Exception
    • getLabels

      public LabelMap getLabels() throws Exception
      This method is used to clone the label map such that mappings can be maintained in the original even if they are modified in the clone. This is used to that the Schema can remove mappings from the label map as they are visited.
      Returns:
      this returns a cloned representation of this map
      Throws:
      Exception
    • getArray

      private String[] getArray(Set<String> list)
      Convert a set in to an array. Conversion is required as the keys and paths must be arrays. Converting from the set in this manner helps the performance on android which works faster with arrays.
      Parameters:
      list - this is the set to be converted to an array
      Returns:
      this returns an array of strings from the provided set
    • isStrict

      public boolean isStrict(Context context)
      This method is used to determine whether strict mappings are required. Strict mapping means that all labels in the class schema must match the XML elements and attributes in the source XML document. When strict mapping is disabled, then XML elements and attributes that do not exist in the schema class will be ignored without breaking the parser.
      Parameters:
      context - this is used to determine if this is strict
      Returns:
      true if strict parsing is enabled, false otherwise