public final class Settings extends HashMap<String,Object>
HashMap
with additional functionality.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
Settings()
Constructs an empty
Settings instance with the default initial
capacity and load factor. |
Settings(int initialCapacity)
Constructs an empty
Settings instance with the specified initial
capacity and a default load factor. |
Settings(int initialCapacity,
float loadFactor)
Constructs an empty
Settings instance with the specified initial
capacity and load factor. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(String key,
PropertyChangeListener listener)
Adds a
listener to the list of change listeners of this map. |
void |
clear()
Removes all of the mappings from this map.
|
Object |
get(Object key)
Returns the value to which the specified object key is mapped.
|
Object |
get(String key)
Returns the value to which the specified string key is mapped.
|
Object |
get(String key,
Object defval)
Returns the object value of a mapping or
defval if not defined. |
BigDecimal |
getBigDecimal(String key)
Returns the decimal value of a mapping or
ZERO if not defined. |
BigDecimal |
getBigDecimal(String key,
BigDecimal defval)
Returns the decimal value of a mapping or
defval if not defined. |
boolean |
getBoolean(String key)
Returns the boolean value of a mapping or
false if not defined. |
boolean |
getBoolean(String key,
boolean defval)
Returns the boolean value of the key or
defval if not defined. |
Date |
getDate(String key)
Returns the date value of a mapping or
null if not defined. |
Date |
getDate(String key,
Date defval)
Returns the date value of a mapping or
defval if not defined. |
double |
getDouble(String key)
Returns the double value of a mapping or
0 if not defined. |
double |
getDouble(String key,
double defval)
Returns the double value of a mapping or
defval if not defined. |
int |
getInt(String key)
Returns the integer value of a mapping or
0 if not defined. |
int |
getInt(String key,
int defval)
Returns the integer value of a mapping or
defval if not defined. |
long |
getLong(String key)
Returns the long value of a mapping or
0 if not defined. |
long |
getLong(String key,
long defval)
Returns the long value of a mapping or
defval if not defined. |
String |
getString(String key)
Returns the string value of a mapping or
null if not defined. |
String |
getString(String key,
String defval)
Returns the string value of a mapping or
defval if not defined. |
Object |
put(String key,
Object value)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map<? extends String,? extends Object> map)
Copies all of the mappings from the specified
map to this map. |
void |
putAll(Properties properties)
Copies all of the mappings of
properties to this map. |
void |
putDefaults(Properties properties)
Adds the mappings of
properties not contained in this map. |
void |
putDefaults(Settings settings)
Adds the mappings of
settings not contained in this map. |
void |
putMap(Map<?,?> map)
Copies all of the mappings of supplied map to this map.
|
Object |
remove(Object key)
Removes the mapping for the specified key from this map if present.
|
void |
removePropertyChangeListener(String key,
PropertyChangeListener listener)
Removes a
listener from the list of change listeners of this map. |
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public Settings()
Settings
instance with the default initial
capacity and load factor.public Settings(int initialCapacity, float loadFactor)
Settings
instance with the specified initial
capacity and load factor.initialCapacity
- the initial capacity.loadFactor
- the load factor.IllegalArgumentException
- if the initial capacity is negative or
the load factor is nonpositive.public Settings(int initialCapacity)
Settings
instance with the specified initial
capacity and a default load factor.initialCapacity
- the initial capacity.IllegalArgumentException
- if the initial capacity is negative.public Object put(String key, Object value)
put
in interface Map<String,Object>
put
in class HashMap<String,Object>
key
- the key with which the specified value is to be associated.value
- value to be associated with the specified key.key
or null
.NullPointerException
- if an argument is null
.public void putAll(Map<? extends String,? extends Object> map)
map
to this map.
These mappings will replace any mappings that this map had for any of the
keys currently in the specified map. Registered listeners are notified of
the changed mappings.public void putAll(Properties properties)
properties
to this map. These
mappings replace any mappings that this map had for any of the keys
currently in the specified Properties
. Registered listeners are
notified of the changed mappings.properties
- the properties to copy to this map.NullPointerException
- if properties
is null
.public void putMap(Map<?,?> map)
map
. Registered listeners are notified of the
changed mappings.map
- the map to copy to this map.NullPointerException
- if map
is null
.public void putDefaults(Settings settings)
settings
not contained in this map. The
mappings that currently exist in this map are not changed. Registered
listeners are notified of the changed mappings.settings
- the settings to add to this map.NullPointerException
- if settings
is null
.public void putDefaults(Properties properties)
properties
not contained in this map. The
mappings that currently exist in this map are not changed. Registered
listeners are notified of the changed mappings.properties
- the properties to add to this map.NullPointerException
- if properties
is null
.public Object remove(Object key)
public void clear()
public Object get(String key)
key
- the string key of the mapping.null
if not defined.NullPointerException
- if key
is null
.public Object get(String key, Object defval)
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.public String getString(String key)
null
if not defined.key
- the key of the mapping.null
if not defined.NullPointerException
- if key
is null
.public String getString(String key, String defval)
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.public double getDouble(String key) throws NumberFormatException
0
if not defined.key
- the key of the mapping.0
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a Double
.public double getDouble(String key, double defval) throws NumberFormatException
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a Double
.public int getInt(String key) throws NumberFormatException
0
if not defined.key
- the key of the mapping.0
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not an Integer
.public int getInt(String key, int defval) throws NumberFormatException
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not an Integer
.public long getLong(String key) throws NumberFormatException
0
if not defined.key
- the key of the mapping.0
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a Long
.public long getLong(String key, long defval) throws NumberFormatException
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a Long
.public BigDecimal getBigDecimal(String key) throws NumberFormatException
ZERO
if not defined.key
- the key of the mapping.ZERO
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a BigDecimal
.public BigDecimal getBigDecimal(String key, BigDecimal defval) throws NumberFormatException
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.NumberFormatException
- if the value is not a BigDecimal
.public boolean getBoolean(String key)
false
if not defined.key
- the key of the mapping.false
if not defined.NullPointerException
- if key
is null
.ClassCastException
- if the value is not a Boolean
.public boolean getBoolean(String key, boolean defval)
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.public Date getDate(String key)
null
if not defined.key
- the key of the mapping.null
if not defined.NullPointerException
- if key
is null
.IllegalArgumentException
- if the value is not a Date
.public Date getDate(String key, Date defval)
defval
if not defined.key
- the key of the mapping.defval
- the default value.defval
if not defined.NullPointerException
- if key
is null
.IllegalArgumentException
- if the value is not a Date
.public void addPropertyChangeListener(String key, PropertyChangeListener listener)
listener
to the list of change listeners of this map.key
- the key of the mapping.listener
- the property change listener.NullPointerException
- if an argument is null
.public void removePropertyChangeListener(String key, PropertyChangeListener listener)
listener
from the list of change listeners of this map.key
- the key of the mapping.listener
- the property change listener.NullPointerException
- if an argument is null
.Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.