Class TypedProperties
- All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>
- Direct Known Subclasses:
Options
A specialization of the
Properties map type with added
convenience methods to retrieve and set options as primitive values.
The internal representation of all data is kept in string form.- Author:
- Abe White
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TypedProperties(Properties defaults) Construct the properties instance with the given set of defaults. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBooleanProperty(String key) Return the property under the given key as a boolean, or false if it does not exist and has no set default.booleangetBooleanProperty(String key, boolean def) Return the property under the given key as a boolean, or the given default if it does not exist.doublegetDoubleProperty(String key) Return the property under the given key as a double, or 0 if it does not exist and has no set default.doublegetDoubleProperty(String key, double def) Return the property under the given key as a double, or the given default if it does not exist.floatgetFloatProperty(String key) Return the property under the given key as a float, or 0 if it does not exist and has no set default.floatgetFloatProperty(String key, float def) Return the property under the given key as a float, or the given default if it does not exist.intgetIntProperty(String key) Return the property under the given key as an int, or 0 if it does not exist and has no set default.intgetIntProperty(String key, int def) Return the property under the given key as an int, or the given default if it does not exist.longgetLongProperty(String key) Return the property under the given key as a long, or 0 if it does not exist and has no set default.longgetLongProperty(String key, long def) Return the property under the given key as a double, or the given default if it does not exist.booleanRemove the property under the given key as a boolean.booleanremoveBooleanProperty(String key, boolean def) Remove the property under the given key as a boolean, or return the given default if it does not exist.doubleRemove the property under the given key as a double.doubleremoveDoubleProperty(String key, double def) Remove the property under the given key as a double, or return the given default if it does not exist.floatRemove the property under the given key as a float.floatremoveFloatProperty(String key, float def) Remove the property under the given key as a float, or return the given default if it does not exist.intremoveIntProperty(String key) Remove the property under the given key as a int.intremoveIntProperty(String key, int def) Remove the property under the given key as a int, or return the given default if it does not exist.longremoveLongProperty(String key) Remove the property under the given key as a long.longremoveLongProperty(String key, long def) Remove the property under the given key as a long, or return the given default if it does not exist.removeProperty(String key) Remove the given property.removeProperty(String key, String def) Remove the given property, or return the given default if it does not exist.voidsetProperty(String key, boolean val) Set the given key to a string version of the given value.voidsetProperty(String key, double val) Set the given key to a string version of the given value.voidsetProperty(String key, float val) Set the given key to a string version of the given value.voidsetProperty(String key, int val) Set the given key to a string version of the given value.voidsetProperty(String key, long val) Set the given key to a string version of the given value.setProperty(String key, String val) OverridesProperties.setProperty(String,String)to remove the key if the given value isnull.Methods inherited from class Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
TypedProperties
public TypedProperties()Default constructor. -
TypedProperties
Construct the properties instance with the given set of defaults.- See Also:
-
-
Method Details
-
getBooleanProperty
Return the property under the given key as a boolean, or false if it does not exist and has no set default. -
getBooleanProperty
Return the property under the given key as a boolean, or the given default if it does not exist. -
getFloatProperty
Return the property under the given key as a float, or 0 if it does not exist and has no set default.- Throws:
NumberFormatException- on parse error
-
getFloatProperty
Return the property under the given key as a float, or the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
getDoubleProperty
Return the property under the given key as a double, or 0 if it does not exist and has no set default.- Throws:
NumberFormatException- on parse error
-
getDoubleProperty
Return the property under the given key as a double, or the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
getLongProperty
Return the property under the given key as a long, or 0 if it does not exist and has no set default.- Throws:
NumberFormatException- on parse error
-
getLongProperty
Return the property under the given key as a double, or the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
getIntProperty
Return the property under the given key as an int, or 0 if it does not exist and has no set default.- Throws:
NumberFormatException- on parse error
-
getIntProperty
Return the property under the given key as an int, or the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
setProperty
OverridesProperties.setProperty(String,String)to remove the key if the given value isnull.- Overrides:
setPropertyin classProperties- See Also:
-
setProperty
Set the given key to a string version of the given value.- See Also:
-
setProperty
Set the given key to a string version of the given value.- See Also:
-
setProperty
Set the given key to a string version of the given value.- See Also:
-
setProperty
Set the given key to a string version of the given value.- See Also:
-
setProperty
Set the given key to a string version of the given value.- See Also:
-
removeProperty
-
removeProperty
-
removeBooleanProperty
Remove the property under the given key as a boolean. -
removeBooleanProperty
Remove the property under the given key as a boolean, or return the given default if it does not exist. -
removeDoubleProperty
Remove the property under the given key as a double.- Throws:
NumberFormatException- on parse error
-
removeDoubleProperty
Remove the property under the given key as a double, or return the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
removeFloatProperty
Remove the property under the given key as a float.- Throws:
NumberFormatException- on parse error
-
removeFloatProperty
Remove the property under the given key as a float, or return the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
removeIntProperty
Remove the property under the given key as a int.- Throws:
NumberFormatException- on parse error
-
removeIntProperty
Remove the property under the given key as a int, or return the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-
removeLongProperty
Remove the property under the given key as a long.- Throws:
NumberFormatException- on parse error
-
removeLongProperty
Remove the property under the given key as a long, or return the given default if it does not exist.- Throws:
NumberFormatException- on parse error
-