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.PropertiesA specialization of thePropertiesmap 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 booleangetBooleanProperty(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.booleangetBooleanProperty(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.doublegetDoubleProperty(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.doublegetDoubleProperty(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.floatgetFloatProperty(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.floatgetFloatProperty(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.intgetIntProperty(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.intgetIntProperty(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.longgetLongProperty(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.longgetLongProperty(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.booleanremoveBooleanProperty(java.lang.String key)Remove the property under the given key as a boolean.booleanremoveBooleanProperty(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.doubleremoveDoubleProperty(java.lang.String key)Remove the property under the given key as a double.doubleremoveDoubleProperty(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.floatremoveFloatProperty(java.lang.String key)Remove the property under the given key as a float.floatremoveFloatProperty(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.intremoveIntProperty(java.lang.String key)Remove the property under the given key as a int.intremoveIntProperty(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.longremoveLongProperty(java.lang.String key)Remove the property under the given key as a long.longremoveLongProperty(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.StringremoveProperty(java.lang.String key)Remove the given property.java.lang.StringremoveProperty(java.lang.String key, java.lang.String def)Remove the given property, or return the given default if it does not exist.voidsetProperty(java.lang.String key, boolean val)Set the given key to a string version of the given value.voidsetProperty(java.lang.String key, double val)Set the given key to a string version of the given value.voidsetProperty(java.lang.String key, float val)Set the given key to a string version of the given value.voidsetProperty(java.lang.String key, int val)Set the given key to a string version of the given value.voidsetProperty(java.lang.String key, long val)Set the given key to a string version of the given value.java.lang.ObjectsetProperty(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:
setPropertyin 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
-
-