public class TypedProperties extends Properties
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.defaults
Constructor and Description |
---|
TypedProperties()
Default constructor.
|
TypedProperties(Properties defaults)
Construct the properties instance with the given set of defaults.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getBooleanProperty(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(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(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(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(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(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(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(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(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(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(String key)
Remove the property under the given key as a boolean.
|
boolean |
removeBooleanProperty(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(String key)
Remove the property under the given key as a double.
|
double |
removeDoubleProperty(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(String key)
Remove the property under the given key as a float.
|
float |
removeFloatProperty(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(String key)
Remove the property under the given key as a int.
|
int |
removeIntProperty(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(String key)
Remove the property under the given key as a long.
|
long |
removeLongProperty(String key,
long def)
Remove the property under the given key as a long, or return the
given default if it does not exist.
|
String |
removeProperty(String key)
Remove the given property.
|
String |
removeProperty(String key,
String def)
Remove the given property, or return the given default if it does
not exist.
|
void |
setProperty(String key,
boolean val)
Set the given key to a string version of the given value.
|
void |
setProperty(String key,
double val)
Set the given key to a string version of the given value.
|
void |
setProperty(String key,
float val)
Set the given key to a string version of the given value.
|
void |
setProperty(String key,
int val)
Set the given key to a string version of the given value.
|
void |
setProperty(String key,
long val)
Set the given key to a string version of the given value.
|
Object |
setProperty(String key,
String val)
Overrides
Properties.setProperty(String,String) to remove
the key if the given value is null . |
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
public TypedProperties()
public TypedProperties(Properties defaults)
Properties.Properties(Properties)
public boolean getBooleanProperty(String key)
public boolean getBooleanProperty(String key, boolean def)
public float getFloatProperty(String key)
NumberFormatException
- on parse errorpublic float getFloatProperty(String key, float def)
NumberFormatException
- on parse errorpublic double getDoubleProperty(String key)
NumberFormatException
- on parse errorpublic double getDoubleProperty(String key, double def)
NumberFormatException
- on parse errorpublic long getLongProperty(String key)
NumberFormatException
- on parse errorpublic long getLongProperty(String key, long def)
NumberFormatException
- on parse errorpublic int getIntProperty(String key)
NumberFormatException
- on parse errorpublic int getIntProperty(String key, int def)
NumberFormatException
- on parse errorpublic Object setProperty(String key, String val)
Properties.setProperty(String,String)
to remove
the key if the given value is null
.setProperty
in class Properties
Properties.setProperty(String,String)
public void setProperty(String key, boolean val)
Properties.setProperty(String,String)
public void setProperty(String key, double val)
Properties.setProperty(String,String)
public void setProperty(String key, float val)
Properties.setProperty(String,String)
public void setProperty(String key, int val)
Properties.setProperty(String,String)
public void setProperty(String key, long val)
Properties.setProperty(String,String)
public String removeProperty(String key, String def)
public boolean removeBooleanProperty(String key)
public boolean removeBooleanProperty(String key, boolean def)
public double removeDoubleProperty(String key)
NumberFormatException
- on parse errorpublic double removeDoubleProperty(String key, double def)
NumberFormatException
- on parse errorpublic float removeFloatProperty(String key)
NumberFormatException
- on parse errorpublic float removeFloatProperty(String key, float def)
NumberFormatException
- on parse errorpublic int removeIntProperty(String key)
NumberFormatException
- on parse errorpublic int removeIntProperty(String key, int def)
NumberFormatException
- on parse errorpublic long removeLongProperty(String key)
NumberFormatException
- on parse errorpublic long removeLongProperty(String key, long def)
NumberFormatException
- on parse errorCopyright © 2006–2018 Apache Software Foundation. All rights reserved.