Class AMHashMap

  • All Implemented Interfaces:
    Serializable, Cloneable, Map

    public class AMHashMap
    extends CaseInsensitiveHashMap
    This class will lower the case of the key that is used to access the HashMap. Primarily this implementation of HashMap is customized for storing and returning attributes. In the case of String values, the values are stored in a Set, whereas in case of byte values the values are stored as byte array. The special byte methods in this class should be used to do specific byte operations. This HashMap stores information about the type of values, (String or byte). All the operations are performed on this basis. The default case is that it stores String values. Note: For byte values there is no negative caching done.
    See Also:
    Serialized Form
    • Constructor Detail

      • AMHashMap

        public AMHashMap()
      • AMHashMap

        public AMHashMap​(boolean forByteValues)
        Creates a new AMHashMap
        Parameters:
        forByteValues - if true then, this map is used for storing byte values. if false, then used for storing String values
      • AMHashMap

        public AMHashMap​(int initialCapacity)
      • AMHashMap

        public AMHashMap​(int initialCapacity,
                         boolean forByteValues)
      • AMHashMap

        public AMHashMap​(HashMap map)
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface Map
        Overrides:
        clear in class HashMap
      • clearNegativeByteAttrs

        protected void clearNegativeByteAttrs()
      • setNegativeByteAttr

        protected void setNegativeByteAttr​(Set n)
      • getNegativeByteAttrClone

        public Set getNegativeByteAttrClone()
      • getMissingKeys

        public Set getMissingKeys​(Set keys)
        This compares all the elements of the specified and returns a Set which contains all the keys missing in the map. If a key is missing, this method adds puts a new element in this map with the missing key and empty Set.
        Parameters:
        keys - the Set of keys that will be compared against the keys in this map.
        Returns:
        a set of keys which are missing
      • getMissingAndEmptyKeys

        public Set getMissingAndEmptyKeys​(Set keys)
        This compares all the elements of the specified and returns a Set which contains all the keys missing in the map and also those keys whose values are empty. If a key is missing, this method adds puts a new element in this map with the missing key and empty Set.
        Parameters:
        keys - the Set of keys that will be compared against the keys in this map.
        Returns:
        a set of keys which are missing and keys whose values are empty Sets.
      • removeKeys

        public void removeKeys​(Set keys)
      • copy

        public void copy​(Map map)
        Copies the contents of the specified map to this map. This operation overwrites the values in this map.
        Parameters:
        map - the map that needs to be copied
      • copyValuesOnly

        public Set copyValuesOnly​(Map map)
        Copies the contents of the specified map to this map. This operation overwrites the values in this map with new contents. This method copies only Sets with values and not empty sets. NOTE: This method will not worry about any negative attributes. Hence will be used in CacheBlock when the entries are being stored.
        Parameters:
        map - the map that needs to be copied
        Returns:
        a set of attributes which have empty sets stored with them
      • merge

        public void merge​(Map map)
        Merges all the values from the specified map to the current map. Adds new values into the current map if not already present. The method assumes that the values in the map are of Set type.
        Parameters:
        map - the map whose values need to merge and added to the current map.
        Throws:
        NullPointerException - if the map is null.
      • addEmptyValues

        public void addEmptyValues​(Set names)
        Method which adds new entries to the map with empty set as values
        Parameters:
        names - new entries to be added to the map
      • removeEmptyValues

        public void removeEmptyValues()
        Removes all the empty values (empty sets) from the map.
      • getCopy

        public Map getCopy()
        This method is to some what clone() behaviour. However, this AMHashMap is designed to mostly store attribute names as keys and Set of values corresponding to each key, a new protected method has been created for this purpose.
        Returns:
        a new AMHashMap that has a copy of all the elements in this map
      • getCopy

        public Map getCopy​(Set names)
        This method is to some what clone() behaviour. However, this AMHashMap is designed to mostly store attribute names as keys and Set of values corresponding to each key, a new protected method has been created for this purpose.
        Parameters:
        names - the names of the attributes that need to be obtained from Map
        Returns:
        a new AMHashMap that has a copy of all the elements in this map
      • isByteValues

        public boolean isByteValues()
        Checks whether this map contains byte array or string values.
        Returns:
        true if the type of values is byte[][] otherwise false.