public abstract class Properties extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Properties.Initializer
Implementing this interface one can define initial values of properties.
|
static interface |
Properties.Reader
This class helps to store and read custom types using
Properties.setObject(java.lang.String, java.lang.Object) and Properties.getObject(java.lang.String, java.lang.Object) methods. |
Constructor and Description |
---|
Properties() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener to this properties instance.
|
abstract Object[] |
getArray(String propertyName,
Object[] defaultValue)
Reads array property from storage.
|
abstract boolean |
getBoolean(String propertyName,
boolean defaultValue)
Reads boolean property from storage.
|
abstract byte |
getByte(String propertyName,
byte defaultValue)
Reads byte property from storage.
|
abstract char |
getChar(String propertyName,
char defaultValue)
Reads char property from storage.
|
abstract Collection |
getCollection(String propertyName,
Collection defaultValue)
Reads Collection property from storage.
|
static Properties |
getDefault()
Returns shared instance of Properties class.
|
abstract double |
getDouble(String propertyName,
double defaultValue)
Reads double property from storage.
|
abstract float |
getFloat(String propertyName,
float defaultValue)
Reads float property from storage.
|
abstract int |
getInt(String propertyName,
int defaultValue)
Reads int property from storage.
|
abstract long |
getLong(String propertyName,
long defaultValue)
Reads long property from storage.
|
abstract Map |
getMap(String propertyName,
Map defaultValue)
Reads Map property from storage.
|
abstract Object |
getObject(String propertyName,
Object defaultValue)
Reads Object property from storage.
|
abstract Properties |
getProperties(String propertyName)
Returns Properties instance for some "subfolder" in properties file.
|
abstract short |
getShort(String propertyName,
short defaultValue)
Reads short property from storage.
|
abstract String |
getString(String propertyName,
String defaultValue)
Reads String property from storage.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove a property change listener from this properties instance.
|
abstract void |
setArray(String propertyName,
Object[] value)
Sets a new value of property with given propertyName.
|
abstract void |
setBoolean(String propertyName,
boolean value)
Sets a new value of property with given propertyName.
|
abstract void |
setByte(String propertyName,
byte value)
Sets a new value of property with given propertyName.
|
abstract void |
setChar(String propertyName,
char value)
Sets a new value of property with given propertyName.
|
abstract void |
setCollection(String propertyName,
Collection value)
Sets a new value of property with given propertyName.
|
abstract void |
setDouble(String propertyName,
double value)
Sets a new value of property with given propertyName.
|
abstract void |
setFloat(String propertyName,
float value)
Sets a new value of property with given propertyName.
|
abstract void |
setInt(String propertyName,
int value)
Sets a new value of property with given propertyName.
|
abstract void |
setLong(String propertyName,
long value)
Sets a new value of property with given propertyName.
|
abstract void |
setMap(String propertyName,
Map value)
Sets a new value of property with given propertyName.
|
abstract void |
setObject(String propertyName,
Object value)
Sets a new value of property with given propertyName.
|
abstract void |
setShort(String propertyName,
short value)
Sets a new value of property with given propertyName.
|
abstract void |
setString(String propertyName,
String value)
Sets a new value of property with given propertyName.
|
public static Properties getDefault()
public abstract String getString(String propertyName, String defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setString(String propertyName, String value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract int getInt(String propertyName, int defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setInt(String propertyName, int value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract char getChar(String propertyName, char defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setChar(String propertyName, char value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract float getFloat(String propertyName, float defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setFloat(String propertyName, float value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract long getLong(String propertyName, long defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setLong(String propertyName, long value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract double getDouble(String propertyName, double defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setDouble(String propertyName, double value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract boolean getBoolean(String propertyName, boolean defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setBoolean(String propertyName, boolean value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract byte getByte(String propertyName, byte defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setByte(String propertyName, byte value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract short getShort(String propertyName, short defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setShort(String propertyName, short value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract Object getObject(String propertyName, Object defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setObject(String propertyName, Object value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract Object[] getArray(String propertyName, Object[] defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setArray(String propertyName, Object[] value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract Collection getCollection(String propertyName, Collection defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setCollection(String propertyName, Collection value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract Map getMap(String propertyName, Map defaultValue)
propertyName
- a propertyName of propertydefaultValue
- a default value to be used if property is not setpublic abstract void setMap(String propertyName, Map value)
propertyName
- a propertyName of propertyvalue
- the new value of propertypublic abstract Properties getProperties(String propertyName)
propertyName
- a subfolder namepublic void addPropertyChangeListener(PropertyChangeListener l)
Please note, that this properties object is not collected from memory sooner than all it's listeners. Therefore it's not necessray to keep a strong reference to this object while holding the listener.
l
- The property change listenerUnsupportedOperationException
- if not supported. The default
properties implementation retrieved by Properties.getDefault()
supports
adding/removing listeners.public void removePropertyChangeListener(PropertyChangeListener l)
Please note, that this properties object is not collected from memory sooner than all it's listeners. Therefore it's not necessray to keep a strong reference to this object while holding the listener. OTOH it is necessary to remove all listeners or release all strong references to the listeners to allow collection of this properties object.
l
- The property change listenerUnsupportedOperationException
- if not supported. The default
properties implementation retrieved by Properties.getDefault()
supports
adding/removing listeners.