Package org.jppf.utils
Class TypedProperties
java.lang.Object
java.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
org.jppf.utils.AbstractTypedProperties
org.jppf.utils.TypedProperties
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
- Direct Known Subclasses:
NamedArguments,PositionalArguments,UnmodifiableTypedProperties
Extension of the
java.util.Properties class to handle the conversion of string values to other types.- Author:
- Laurent Cohen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA filter forTypedPropertiesobjects. -
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TypedProperties(Map<?, ?> map) Initialize this object with a set of existing properties. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsProperty(JPPFProperty<?> property) Determine whether this set of properties contains the specified property.filter(TypedProperties.Filter filter) Extract the properties that pass the specified filter.<T> Tget(JPPFProperty<T> property) Get the value of a predefined property.<T> Tget(JPPFProperty<T> property, String... parameters) Get the value of a predefined parametrized property.booleangetBoolean(String key) Get the boolean value of a property with a specified name.booleangetBoolean(String key, boolean defValue) Get the boolean value of a property with a specified name.charGet the char value of a property with a specified name.charGet the char value of a property with a specified name.doubleGet the double precision value of a property with a specified name.doubleGet the double precision value of a property with a specified name.Get the value of the specified property as aFile.Get the value of the specified property as aFile.floatGet the single precision value of a property with a specified name.floatGet the single precision value of a property with a specified name.getInetAddress(String key) Get the value of a property with the specified name as anInetAddress.getInetAddress(String key, InetAddress def) Get the value of a property with the specified name as anInetAddress.intGet the integer value of a property with a specified name.intGet the integer value of a property with a specified name.longGet the long integer value of a property with a specified name.longGet the long integer value of a property with a specified name.getProperties(String key) Get the value of a property with the specified name as a set of a properties.getProperties(String key, TypedProperties def) Get the value of a property with the specified name as a set of properties.Get the string value of a property with a specified name.Get the string value of a property with a specified name.String[]getStringArray(String key, String delimiter) Get the value of the specified property as an array of strings.String[]getStringArray(String key, String delimiter, String[] defValue) Get the value of the specified property as an array of strings.<T> Tremove(JPPFProperty<T> property) Remove the specified predefined property.<T> Tremove(JPPFProperty<T> property, String... parameters) Deprecated.<T> TremoveProperty(JPPFProperty<T> property, String... parameters) Remove the specified predefined parametrized property.<T> TypedPropertiesset(JPPFProperty<T> property, T value) Set the value of a predefined property.<T> TypedPropertiesset(JPPFProperty<T> property, T value, String... parameters) Set the value of a predefined parametrized property.setBoolean(String key, boolean value) Set a property with the specified boolean value.Set a property with the specified char value.Set a property with the specified double value.Set the value of the specified property as aFile.Set a property with the specified float value.Set a property with the specified int value.Set a property with the specified long value.Set a property with the specified String value.setStringArray(String key, String delimiter, String... value) Set the value of the specified property as an array of strings.voidMethods inherited from class org.jppf.utils.AbstractTypedProperties
asString, asString, fromString, fromString, getDefaults, loadAndResolve, reset, setDefaults, toStringMethods 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, setProperty, size, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, values
-
Constructor Details
-
TypedProperties
public TypedProperties()Default constructor. -
TypedProperties
Initialize this object with a set of existing properties. This will copy into the present object all map entries such that both key and value are strings.- Parameters:
map- the properties to be copied. No reference to this parameter is kept in this TypedProperties object.
-
-
Method Details
-
getString
Get the string value of a property with a specified name.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a string, or null if it is not found.
-
getString
Get the string value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a string, or the default value if it is not found.
-
setString
Set a property with the specified String value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getInt
Get the integer value of a property with a specified name.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as an int, or zero if it is not found.
-
getInt
Get the integer value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as an int, or the default value if it is not found.
-
setInt
Set a property with the specified int value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getLong
Get the long integer value of a property with a specified name.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a long, or zero if it is not found.
-
getLong
Get the long integer value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a long, or the default value if it is not found.
-
setLong
Set a property with the specified long value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getFloat
Get the single precision value of a property with a specified name.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a float, or zero if it is not found.
-
getFloat
Get the single precision value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a float, or the default value if it is not found.
-
setFloat
Set a property with the specified float value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getDouble
Get the double precision value of a property with a specified name. If the key is not found a default value of 0d is returned.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a double, or zero if it is not found.
-
getDouble
Get the double precision value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a double, or the default value if it is not found.
-
setDouble
Set a property with the specified double value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getBoolean
Get the boolean value of a property with a specified name. If the key is not found a default value of false is returned.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a boolean, or
falseif it is not found.
-
getBoolean
Get the boolean value of a property with a specified name.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a boolean, or the default value if it is not found.
-
setBoolean
Set a property with the specified boolean value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getChar
Get the char value of a property with a specified name. If the key is not found a default value of ' ' is returned.- Parameters:
key- the name of the property to look for.- Returns:
- the value of the property as a char, or the default value ' ' (space character) if it is not found.
-
getChar
Get the char value of a property with a specified name. If the value has more than one character, the first one will be used.- Parameters:
key- the name of the property to look for.defValue- a default value to return if the property is not found.- Returns:
- the value of the property as a char, or the default value if it is not found.
-
setChar
Set a property with the specified char value.- Parameters:
key- the name of the property to set.value- the value to set on the property.- Returns:
- this
TypedPropertiesobject.
-
getFile
Get the value of the specified property as aFile.- Parameters:
key- the name of the property to look up.- Returns:
- an abstract file path based on the value of the property, or null if the property is not defined.
-
getFile
Get the value of the specified property as aFile.- Parameters:
key- the name of the property to look up.defValue- the value to return if the property is not found.- Returns:
- an abstract file path based on the value of the property, or the default value if the property is not defined.
-
setFile
Set the value of the specified property as aFile.- Parameters:
key- the name of the property to look up.value- the file whose path to set as the property value.- Returns:
- this
TypedPropertiesobject.
-
getStringArray
Get the value of the specified property as an array of strings.- Parameters:
key- the name of the property to look up.delimiter- the delimiter used to split the value into an array of strings. It MUST be a litteral string, i.e. not a regex.- Returns:
- an abstract file path based on the value of the property, or null if the property is not defined.
- Since:
- 5.2
-
getStringArray
Get the value of the specified property as an array of strings.- Parameters:
key- the name of the property to look up.delimiter- the delimiter used to split the value into an array of strings. It MUST be a litteral string, i.e. not a regex.defValue- the value to return if the property is not found.- Returns:
- an abstract file path based on the value of the property, or the default value if the property is not defined.
- Since:
- 5.2
-
setStringArray
Set the value of the specified property as an array of strings.- Parameters:
key- the name of the property to look up.delimiter- the delimiter that will be inserted between any two adjacent strings. It MUST be a litteral string, i.e. not a regex.value- an array of strings.- Returns:
- this
TypedPropertiesobject. - Since:
- 5.2
-
getProperties
Get the value of a property with the specified name as a set of a properties.- Parameters:
key- the name of the property to look for. Its value is the path to another properties file. Relative paths are evaluated against the current application directory.- Returns:
- the value of the property as another set of properties, or null if it is not found.
-
getProperties
Get the value of a property with the specified name as a set of properties.- Parameters:
key- the name of the property to look for. Its value is the path to another properties file. Relative paths are evaluated against the current application directory.def- a default value to return if the property is not found.- Returns:
- the value of the property as another set of properties, or the default value if it is not found.
-
getInetAddress
Get the value of a property with the specified name as anInetAddress.- Parameters:
key- the name of the property to retrieve.- Returns:
- the property as an
InetAddressinstance, or null if the property is not defined or the host doesn't exist.
-
getInetAddress
Get the value of a property with the specified name as anInetAddress.- Parameters:
key- the name of the property to retrieve.def- the default value to use if the property is not defined.- Returns:
- the property as an
InetAddressinstance, or the specified default value if the property is not defined.
-
filter
Extract the properties that pass the specified filter.- Parameters:
filter- the filter to use, ifnullthen all properties are returned.- Returns:
- a new
TypedPropertiesobject containing only the properties matching the filter.
-
set
Set the value of a predefined property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to set.value- the value to set.- Returns:
- the value of the property according to its type.
- Since:
- 5.2
-
set
Set the value of a predefined parametrized property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to set.value- the value to set.parameters- the values to replace the property's parameters with.- Returns:
- the value of the property according to its type.
- Since:
- 6.0
-
get
Get the value of a predefined property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to retrieve.- Returns:
- the value of the property according to its type.
- Since:
- 5.2
-
get
Get the value of a predefined parametrized property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to retrieve.parameters- the values to replace the property's parameters with.- Returns:
- the value of the property according to its type.
- Since:
- 6.0
-
remove
Remove the specified predefined property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to retrieve.- Returns:
- the old value of the property, or
nullif it wasn't defined. - Since:
- 5.2
-
containsProperty
Determine whether this set of properties contains the specified property. The lookkup is performed on the property's name first, then on its aliases if the name is not found.- Parameters:
property- the property to look for.- Returns:
trueif the property or one of its aliases is found,falseotherwise.- Since:
- 5.2
-
remove
Deprecated.useremoveProperty(JPPFProperty, String...)instead.Remove the specified predefined parametrized property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to retrieve.parameters- the values to replace the property's parameters with.- Returns:
- the old value of the property, or
nullif it wasn't defined. - Since:
- 6.0
-
removeProperty
Remove the specified predefined parametrized property.- Type Parameters:
T- the type of the property.- Parameters:
property- the property whose value to retrieve.parameters- the values to replace the property's parameters with.- Returns:
- the old value of the property, or
nullif it wasn't defined. - Since:
- 6.1
-
store
- Overrides:
storein classProperties- Throws:
IOException
-
removeProperty(JPPFProperty, String...)instead.