Class HashGetter

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, Getter
Direct Known Subclasses:
SensibleHashGetter, UIMessage.ControlValues

public class HashGetter extends HashMap<String,Object> implements Getter
The class is an implementation of Getter, implemented using the HashMap. It isn't a synchronous implementation, therefore you must use a single thread in writing and n thread in reading. HashGetter also contains a singleton (global()) used as a global map or shared resource at the application level used to park informations, objects, preloaded data, etc.
See Also:
  • Constructor Details

    • HashGetter

      public HashGetter()
      Null constructor
    • HashGetter

      public HashGetter(int initialCapacity)
      Creates an HashGetter with a specific initial capacity
      Parameters:
      initialCapacity - The initial capacity of the HashGetter
    • HashGetter

      public HashGetter(Object... oo)
      Creates an HashGetter from a variable number of objects passed as parameters. You have to enter the parameters with a pair logic, in which the first element will constitute the key while the second will constitute the value of an entry of the map.
      Parameters:
      oo - A list of Objects
    • HashGetter

      public HashGetter(Map a)
      Creates an HashGetter starting from a Map
      Parameters:
      a - The initial map
    • HashGetter

      public HashGetter(Map m, String... prefixes)
      Creates an HashGetter starting from a Map. The map entries inserted into the HashGetter will be only those whose keys begin with the prefix passed as second parameter
      Parameters:
      m - The initial map
      prefixes - The prefixes used to filter the map entries
  • Method Details

    • global

      public static HashGetter global()
      Singleton method used to return always the same object HashGetter valid at the level of the whole application
      Returns:
      The global HashGetter
    • putByPrefix

      public void putByPrefix(Map m, String... prefixes)
      Puts in the HashGetter the map entries whose keys begin with the prefix passed as second parameter
      Parameters:
      m - Te initial map
      prefixes - The prefix used to filter the map entries
    • putAll

      public void putAll(Map m)
      Specified by:
      putAll in interface Map<String,Object>
      Overrides:
      putAll in class HashMap<String,Object>
    • putByRE

      public void putByRE(Map m, String regex)
      Puts in the HashGetter the map entries whose keys satisfy the regular expression passed as second parameter
      Parameters:
      m - The initial map
      regex - The regular expression used to filter the map entries
    • putOnly

      public void putOnly(Map m, String[] ss)
      Puts in the HashGetter the map entries whose keys are present inside the array passed as second parameter
      Parameters:
      m - The initial map
      ss - The string array of keys used to filter the map entries
    • putOnly

      public void putOnly(Map m, Set<String> ss)
      Puts in the HashGetter the map entries whose keys are present inside the set passed as second parameter
      Parameters:
      m - The initial map
      ss - The set used to filter the map entries
    • set

      public void set(String s, Object o)
      Equivalent to the put method of the HashMap
      Parameters:
      s - The name of the key of the entry
      o - The object to put in the map
    • put

      public Object put(String s, Object o, Object def)
      Puts an object into the map. If the object is null, the default object is putted into the map
      Parameters:
      s - The name of the key of the entry
      o - The object to put in the map
      def - The default object putted in the map if the object is null
      Returns:
      The previous value associated with s (the key), or null if there was no mapping for s (the key). (A null return can also indicate that the map previously associated null with s (the key).)
    • getString

      public String getString(String s, String def)
      Implements the Getter interface, extracts a String value from the map
      Specified by:
      getString in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The String value that corresponds to the key field, or the default one
    • getLong

      public Long getLong(String s, Long def)
      Implements the Getter interface, extracts a Long value from the map
      Specified by:
      getLong in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The Long value that corresponds to the key field, or the default one
    • getlong

      public long getlong(String s, long def)
      Implements the Getter interface, extracts a long value from the map
      Specified by:
      getlong in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The long value that corresponds to the key field, or the default one
    • getInteger

      public Integer getInteger(String s, Integer def)
      Implements the Getter interface, extracts an Integer value from the map
      Specified by:
      getInteger in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The Integer value that corresponds to the key field, or the default one
    • getint

      public int getint(String s, int def)
      Implements the Getter interface, extracts an int value from the map
      Specified by:
      getint in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The int value that corresponds to the key field, or the default one
    • getDouble

      public Double getDouble(String s, Double def)
      Implements the Getter interface, extracts a Double value from the map
      Specified by:
      getDouble in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The Double value that corresponds to the key field, or the default one
    • getdouble

      public double getdouble(String s, double def)
      Implements the Getter interface, extracts a double value from the map
      Specified by:
      getdouble in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The double value that corresponds to the key field, or the default one
    • getFloat

      public Float getFloat(String s, Float def)
      Implements the Getter interface, extracts a Float value from the map
      Specified by:
      getFloat in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The Float value that corresponds to the key field, or the default one
    • getfloat

      public float getfloat(String s, float def)
      Implements the Getter interface, extracts a float value from the map
      Specified by:
      getfloat in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The float value that corresponds to the key field, or the default one
    • getBoolean

      public Boolean getBoolean(String s, Boolean def)
      Implements the Getter interface, extracts a Boolean value from the map
      Specified by:
      getBoolean in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The Boolean value that corresponds to the key field, or the default one
    • getboolean

      public boolean getboolean(String s, boolean def)
      Implements the Getter interface, extracts a boolean value from the map
      Specified by:
      getboolean in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The boolean value that corresponds to the key field, or the default one
    • getDate

      public Date getDate(String s, Date def, SimpleDateFormat sdf)
      Implements the Getter interface, extracts a Date value from the map
      Specified by:
      getDate in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      sdf - The SimpleDateFormat that defines the format of the date to extract. If null, the date is passed unchanged
      Returns:
      The Date value that corresponds to the key field, or the default one
    • keyIterator

      public Iterator<String> keyIterator()
      Extracts an Iterator used to iterate over all the HashGetter elements
      Specified by:
      keyIterator in interface Getter
      Returns:
      The iterator on the elements of the HashGetter
    • get

      public Object get(String key)
      Extracts from the HashGetter the object that corresponds to the key passed as parameters. In this case there isn't a default value.
      Specified by:
      get in interface Getter
      Parameters:
      key - The name of the key
      Returns:
      The object associated to the key passed as parameter, or null if the map contains no mapping for the key
    • get

      public Object get(String s, Object def)
      Extracts from the HashGetter the object that corresponds to the key passed as parameters. If the object is null, or if the map contains no mapping for the kay, the default object is returned
      Specified by:
      get in interface Getter
      Parameters:
      s - The name of the key
      def - The default value returned if the extracted object is null or the key is not present in the map
      Returns:
      The object associated to the key passed as parameter, or null if the map contains no mapping for the key
    • containsKey

      public boolean containsKey(String key)
      Checks if the HashGetter contains an entry with the key passed as parameter
      Specified by:
      containsKey in interface Getter
      Parameters:
      key - The name of the key to search
      Returns:
      true if there is an entry with the key passed as parameter, false otherwise