Class LabelMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Label>, java.util.Map<java.lang.String,​Label>

    class LabelMap
    extends java.util.LinkedHashMap<java.lang.String,​Label>
    implements java.lang.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:
    Label
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Policy policy
      This is policy used to determine the type of mappings used.
    • Constructor Summary

      Constructors 
      Constructor Description
      LabelMap()
      Constructor for the LabelMap object is used to create an empty map.
      LabelMap​(Policy policy)
      Constructor for the LabelMap object is used to create an empty map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String[] getArray​(java.util.Set<java.lang.String> list)
      Convert a set in to an array.
      java.lang.String[] getKeys()
      This is used to acquire the paths and names for each label in this map.
      Label getLabel​(java.lang.String name)
      This performs a remove that will remove the label from the map and return that label.
      LabelMap getLabels()
      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.
      java.lang.String[] getPaths()
      This is used to acquire the paths for each label in this map.
      boolean isStrict​(Context context)
      This method is used to determine whether strict mappings are required.
      java.util.Iterator<Label> iterator()
      This allows the Label objects within the label map to be iterated within for each loops.
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
    • Field Detail

      • policy

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

      • 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 Detail

      • iterator

        public java.util.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 java.lang.Iterable<Label>
        Returns:
        this returns an iterator for existing label objects
      • getLabel

        public Label getLabel​(java.lang.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 java.lang.String[] getKeys()
                                   throws java.lang.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:
        java.lang.Exception
      • getPaths

        public java.lang.String[] getPaths()
                                    throws java.lang.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:
        java.lang.Exception
      • getLabels

        public LabelMap getLabels()
                           throws java.lang.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:
        java.lang.Exception
      • getArray

        private java.lang.String[] getArray​(java.util.Set<java.lang.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