Package org.xipki.util
Class ConfigurableProperties
- java.lang.Object
-
- org.xipki.util.ConfigurableProperties
-
public class ConfigurableProperties extends java.lang.ObjectSimilar asProperties, with the extension to use the place-holder ${env:ENVIROMENT-NAME} for the environment, and ${sys:JAVA-PROPERTY-NAME} for the Java system property.- Since:
- 6.3.1
- Author:
- Lijun Liao (xipki)
-
-
Constructor Summary
Constructors Constructor Description ConfigurableProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.String key)java.lang.StringgetProperty(java.lang.String key)Searches for the property with the specified key in this property list.java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Searches for the property with the specified key in this property list.inthashCode()booleanisEmpty()voidload(java.io.InputStream inStream)Reads a property list (key and element pairs) from the input byte stream.voidload(java.io.Reader reader)Reads a property list (key and element pairs) from the input character stream in a simple line-oriented format.voidload(java.util.Properties props)java.util.Set<java.lang.String>propertyNames()Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.java.lang.Stringremove(java.lang.String key)java.lang.StringsetProperty(java.lang.String key, java.lang.String value)Calls theHashtablemethodput.intsize()java.util.PropertiestoProperties()java.lang.StringtoString()
-
-
-
Method Detail
-
load
public void load(java.util.Properties props)
-
load
public void load(java.io.InputStream inStream) throws java.io.IOExceptionReads a property list (key and element pairs) from the input byte stream.The specified stream remains open after this method returns.
- Parameters:
inStream- the input stream.- Throws:
java.io.IOException- if an error occurred when reading from the input stream.java.lang.NullPointerException- ifinStreamis null.
-
load
public void load(java.io.Reader reader) throws java.io.IOExceptionReads a property list (key and element pairs) from the input character stream in a simple line-oriented format.The specified stream remains open after this method returns.
- Parameters:
reader- the input character stream.- Throws:
java.io.IOException- if an error occurred when reading from the input stream.java.lang.NullPointerException- ifreaderis null.
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returnsnullif the property is not found.- Parameters:
key- the property key.- Returns:
- the value in this property list with the specified key value.
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.- Parameters:
key- the hashtable key.defaultValue- a default value.- Returns:
- the value in this property list with the specified key value.
-
propertyNames
public java.util.Set<java.lang.String> propertyNames()
Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of typeStringare omitted.The returned set is not backed by this
Propertiesobject. Changes to thisPropertiesobject are not reflected in the returned set.- Returns:
- an unmodifiable set of keys in this property list where the key and its corresponding value are strings, including the keys in the default property list.
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(java.lang.String key)
-
setProperty
public java.lang.String setProperty(java.lang.String key, java.lang.String value)Calls theHashtablemethodput. Provided for parallelism with thegetPropertymethod. Enforces use of strings for property keys and values. The value returned is the result of theHashtablecall toput.- Parameters:
key- the key to be placed into this property list.value- the value corresponding tokey.- Returns:
- the previous value of the specified key in this property
list, or
nullif it did not have one.
-
remove
public java.lang.String remove(java.lang.String key)
-
clear
public void clear()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toProperties
public java.util.Properties toProperties()
-
-