Package org.apache.openjpa.lib.util
Class TypedProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<java.lang.Object,java.lang.Object>
-
- java.util.Properties
-
- org.apache.openjpa.lib.util.TypedProperties
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.Object,java.lang.Object>
- Direct Known Subclasses:
Options
public class TypedProperties extends java.util.Properties
A specialization of theProperties
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TypedProperties()
Default constructor.TypedProperties(java.util.Properties defaults)
Construct the properties instance with the given set of defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getBooleanProperty(java.lang.String key)
Return the property under the given key as a boolean, or false if it does not exist and has no set default.boolean
getBooleanProperty(java.lang.String key, boolean def)
Return the property under the given key as a boolean, or the given default if it does not exist.double
getDoubleProperty(java.lang.String key)
Return the property under the given key as a double, or 0 if it does not exist and has no set default.double
getDoubleProperty(java.lang.String key, double def)
Return the property under the given key as a double, or the given default if it does not exist.float
getFloatProperty(java.lang.String key)
Return the property under the given key as a float, or 0 if it does not exist and has no set default.float
getFloatProperty(java.lang.String key, float def)
Return the property under the given key as a float, or the given default if it does not exist.int
getIntProperty(java.lang.String key)
Return the property under the given key as an int, or 0 if it does not exist and has no set default.int
getIntProperty(java.lang.String key, int def)
Return the property under the given key as an int, or the given default if it does not exist.long
getLongProperty(java.lang.String key)
Return the property under the given key as a long, or 0 if it does not exist and has no set default.long
getLongProperty(java.lang.String key, long def)
Return the property under the given key as a double, or the given default if it does not exist.boolean
removeBooleanProperty(java.lang.String key)
Remove the property under the given key as a boolean.boolean
removeBooleanProperty(java.lang.String key, boolean def)
Remove the property under the given key as a boolean, or return the given default if it does not exist.double
removeDoubleProperty(java.lang.String key)
Remove the property under the given key as a double.double
removeDoubleProperty(java.lang.String key, double def)
Remove the property under the given key as a double, or return the given default if it does not exist.float
removeFloatProperty(java.lang.String key)
Remove the property under the given key as a float.float
removeFloatProperty(java.lang.String key, float def)
Remove the property under the given key as a float, or return the given default if it does not exist.int
removeIntProperty(java.lang.String key)
Remove the property under the given key as a int.int
removeIntProperty(java.lang.String key, int def)
Remove the property under the given key as a int, or return the given default if it does not exist.long
removeLongProperty(java.lang.String key)
Remove the property under the given key as a long.long
removeLongProperty(java.lang.String key, long def)
Remove the property under the given key as a long, or return the given default if it does not exist.java.lang.String
removeProperty(java.lang.String key)
Remove the given property.java.lang.String
removeProperty(java.lang.String key, java.lang.String def)
Remove the given property, or return the given default if it does not exist.void
setProperty(java.lang.String key, boolean val)
Set the given key to a string version of the given value.void
setProperty(java.lang.String key, double val)
Set the given key to a string version of the given value.void
setProperty(java.lang.String key, float val)
Set the given key to a string version of the given value.void
setProperty(java.lang.String key, int val)
Set the given key to a string version of the given value.void
setProperty(java.lang.String key, long val)
Set the given key to a string version of the given value.java.lang.Object
setProperty(java.lang.String key, java.lang.String val)
OverridesProperties.setProperty(String,String)
to remove the key if the given value isnull
.-
Methods inherited from class java.util.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
-
-
-
-
Method Detail
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String key)
Return the property under the given key as a boolean, or false if it does not exist and has no set default.
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String key, boolean def)
Return the property under the given key as a boolean, or the given default if it does not exist.
-
getFloatProperty
public float getFloatProperty(java.lang.String key)
Return the property under the given key as a float, or 0 if it does not exist and has no set default.- Throws:
java.lang.NumberFormatException
- on parse error
-
getFloatProperty
public float getFloatProperty(java.lang.String key, float def)
Return the property under the given key as a float, or the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
getDoubleProperty
public double getDoubleProperty(java.lang.String key)
Return the property under the given key as a double, or 0 if it does not exist and has no set default.- Throws:
java.lang.NumberFormatException
- on parse error
-
getDoubleProperty
public double getDoubleProperty(java.lang.String key, double def)
Return the property under the given key as a double, or the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
getLongProperty
public long getLongProperty(java.lang.String key)
Return the property under the given key as a long, or 0 if it does not exist and has no set default.- Throws:
java.lang.NumberFormatException
- on parse error
-
getLongProperty
public long getLongProperty(java.lang.String key, long def)
Return the property under the given key as a double, or the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
getIntProperty
public int getIntProperty(java.lang.String key)
Return the property under the given key as an int, or 0 if it does not exist and has no set default.- Throws:
java.lang.NumberFormatException
- on parse error
-
getIntProperty
public int getIntProperty(java.lang.String key, int def)
Return the property under the given key as an int, or the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
setProperty
public java.lang.Object setProperty(java.lang.String key, java.lang.String val)
OverridesProperties.setProperty(String,String)
to remove the key if the given value isnull
.- Overrides:
setProperty
in classjava.util.Properties
- See Also:
Properties.setProperty(String,String)
-
setProperty
public void setProperty(java.lang.String key, boolean val)
Set the given key to a string version of the given value.- See Also:
Properties.setProperty(String,String)
-
setProperty
public void setProperty(java.lang.String key, double val)
Set the given key to a string version of the given value.- See Also:
Properties.setProperty(String,String)
-
setProperty
public void setProperty(java.lang.String key, float val)
Set the given key to a string version of the given value.- See Also:
Properties.setProperty(String,String)
-
setProperty
public void setProperty(java.lang.String key, int val)
Set the given key to a string version of the given value.- See Also:
Properties.setProperty(String,String)
-
setProperty
public void setProperty(java.lang.String key, long val)
Set the given key to a string version of the given value.- See Also:
Properties.setProperty(String,String)
-
removeProperty
public java.lang.String removeProperty(java.lang.String key)
Remove the given property.
-
removeProperty
public java.lang.String removeProperty(java.lang.String key, java.lang.String def)
Remove the given property, or return the given default if it does not exist.
-
removeBooleanProperty
public boolean removeBooleanProperty(java.lang.String key)
Remove the property under the given key as a boolean.
-
removeBooleanProperty
public boolean removeBooleanProperty(java.lang.String key, boolean def)
Remove the property under the given key as a boolean, or return the given default if it does not exist.
-
removeDoubleProperty
public double removeDoubleProperty(java.lang.String key)
Remove the property under the given key as a double.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeDoubleProperty
public double removeDoubleProperty(java.lang.String key, double def)
Remove the property under the given key as a double, or return the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeFloatProperty
public float removeFloatProperty(java.lang.String key)
Remove the property under the given key as a float.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeFloatProperty
public float removeFloatProperty(java.lang.String key, float def)
Remove the property under the given key as a float, or return the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeIntProperty
public int removeIntProperty(java.lang.String key)
Remove the property under the given key as a int.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeIntProperty
public int removeIntProperty(java.lang.String key, int def)
Remove the property under the given key as a int, or return the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeLongProperty
public long removeLongProperty(java.lang.String key)
Remove the property under the given key as a long.- Throws:
java.lang.NumberFormatException
- on parse error
-
removeLongProperty
public long removeLongProperty(java.lang.String key, long def)
Remove the property under the given key as a long, or return the given default if it does not exist.- Throws:
java.lang.NumberFormatException
- on parse error
-
-