Package overit.geocall.util
Class HashGetter
- Direct Known Subclasses:
SensibleHashGetter,UIMessage.ControlValues
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionNull constructorHashGetter(int initialCapacity) Creates an HashGetter with a specific initial capacityHashGetter(Object... oo) Creates an HashGetter from a variable number of objects passed as parameters.HashGetter(Map a) Creates an HashGetter starting from a MapHashGetter(Map m, String... prefixes) Creates an HashGetter starting from a Map. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Checks if the HashGetter contains an entry with the key passed as parameterExtracts from the HashGetter the object that corresponds to the key passed as parameters.Extracts from the HashGetter the object that corresponds to the key passed as parameters.booleangetboolean(String s, boolean def) Implements theGetterinterface, extracts a boolean value from the mapgetBoolean(String s, Boolean def) Implements theGetterinterface, extracts a Boolean value from the mapgetDate(String s, Date def, SimpleDateFormat sdf) Implements theGetterinterface, extracts a Date value from the mapdoubleImplements theGetterinterface, extracts a double value from the mapImplements theGetterinterface, extracts a Double value from the mapfloatImplements theGetterinterface, extracts a float value from the mapImplements theGetterinterface, extracts a Float value from the mapintImplements theGetterinterface, extracts an int value from the mapgetInteger(String s, Integer def) Implements theGetterinterface, extracts an Integer value from the maplongImplements theGetterinterface, extracts a long value from the mapImplements theGetterinterface, extracts a Long value from the mapImplements theGetterinterface, extracts a String value from the mapstatic HashGetterglobal()Singleton method used to return always the same object HashGetter valid at the level of the whole applicationExtracts an Iterator used to iterate over all the HashGetter elementsPuts an object into the map.voidvoidputByPrefix(Map m, String... prefixes) Puts in the HashGetter the map entries whose keys begin with the prefix passed as second parametervoidPuts in the HashGetter the map entries whose keys satisfy the regular expression passed as second parametervoidPuts in the HashGetter the map entries whose keys are present inside the array passed as second parametervoidPuts in the HashGetter the map entries whose keys are present inside the set passed as second parametervoidEquivalent to the put method of the HashMapMethods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
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
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
Creates an HashGetter starting from a Map- Parameters:
a- The initial map
-
HashGetter
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 mapprefixes- The prefixes used to filter the map entries
-
-
Method Details
-
global
Singleton method used to return always the same object HashGetter valid at the level of the whole application- Returns:
- The global HashGetter
-
putByPrefix
Puts in the HashGetter the map entries whose keys begin with the prefix passed as second parameter- Parameters:
m- Te initial mapprefixes- The prefix used to filter the map entries
-
putAll
-
putByRE
Puts in the HashGetter the map entries whose keys satisfy the regular expression passed as second parameter- Parameters:
m- The initial mapregex- The regular expression used to filter the map entries
-
putOnly
Puts in the HashGetter the map entries whose keys are present inside the array passed as second parameter- Parameters:
m- The initial mapss- The string array of keys used to filter the map entries
-
putOnly
Puts in the HashGetter the map entries whose keys are present inside the set passed as second parameter- Parameters:
m- The initial mapss- The set used to filter the map entries
-
set
Equivalent to the put method of the HashMap- Parameters:
s- The name of the key of the entryo- The object to put in the map
-
put
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 entryo- The object to put in the mapdef- The default object putted in the map if the object is null- Returns:
- The previous value associated with
s(thekey), ornullif there was no mapping fors(thekey). (Anullreturn can also indicate that the map previously associatednullwiths(thekey).)
-
getString
Implements theGetterinterface, extracts a String value from the map -
getLong
Implements theGetterinterface, extracts a Long value from the map -
getlong
Implements theGetterinterface, extracts a long value from the map -
getInteger
Implements theGetterinterface, extracts an Integer value from the map- Specified by:
getIntegerin interfaceGetter- Parameters:
s- The name of the keydef- 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
Implements theGetterinterface, extracts an int value from the map -
getDouble
Implements theGetterinterface, extracts a Double value from the map -
getdouble
Implements theGetterinterface, extracts a double value from the map -
getFloat
Implements theGetterinterface, extracts a Float value from the map -
getfloat
Implements theGetterinterface, extracts a float value from the map -
getBoolean
Implements theGetterinterface, extracts a Boolean value from the map- Specified by:
getBooleanin interfaceGetter- Parameters:
s- The name of the keydef- 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
Implements theGetterinterface, extracts a boolean value from the map- Specified by:
getbooleanin interfaceGetter- Parameters:
s- The name of the keydef- 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
Implements theGetterinterface, extracts a Date value from the map- Specified by:
getDatein interfaceGetter- Parameters:
s- The name of the keydef- The default value returned if the extracted object is null or the key is not present in the mapsdf- 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
Extracts an Iterator used to iterate over all the HashGetter elements- Specified by:
keyIteratorin interfaceGetter- Returns:
- The iterator on the elements of the HashGetter
-
get
Extracts from the HashGetter the object that corresponds to the key passed as parameters. In this case there isn't a default value. -
get
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 -
containsKey
Checks if the HashGetter contains an entry with the key passed as parameter- Specified by:
containsKeyin interfaceGetter- Parameters:
key- The name of the key to search- Returns:
- true if there is an entry with the key passed as parameter, false otherwise
-