|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xnap.commons.settings.PropertyResource
public class PropertyResource
This class provides a default implementation for a preferences framework. Methods are provided that can read and write native types, arrays and a few custom types.
Field Summary | |
---|---|
protected boolean |
changedFlag
Determines if preferences need to be saved. |
protected static org.apache.commons.logging.Log |
logger
|
protected String |
namespace
The namespace is prefixed to each key. |
protected int |
oldVersion
Version of database when read. |
protected Properties |
properties
Preferences. |
protected PropertyChangeSupport |
propertyChange
|
protected int |
version
Version of database format. |
Constructor Summary | |
---|---|
PropertyResource()
|
|
PropertyResource(int version,
String namespace)
Constructs a PreferencesSupport object. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds a preferences listener. |
void |
addPropertyChangeListener(String key,
PropertyChangeListener l)
Adds a preferences listener for a specific key. |
protected void |
convert(int oldVersion)
Invoked by load(File) to converts preferences from
oldVersion to current version. |
boolean |
equals(Object o)
Returns true if o is the same object or if its
version number, namespace and properties map are equal to
this' fields. |
void |
firePropertyChange(String key,
Object oldValue,
Object newValue)
Fires PropertyChangeEvent without namespace. |
String |
get(String key,
String defaultValue)
Returns the value to which the specified key is mapped. |
int |
getOldVersion()
Returns the version of the preferences in the file at the point of the last read operation. |
int |
getVersion()
Returns the current version of the preferences. |
void |
load(File prefsFile)
Reads preferences from prefsFile . |
void |
put(String key,
String newValue)
|
void |
remove(String key)
Ignores namespace. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes a preferences listener. |
void |
removePropertyChangeListener(String key,
PropertyChangeListener l)
|
void |
renameProperty(String oldKey,
String newKey)
Renames a property, used for conversion of property file formats. |
boolean |
store(File prefsFile)
Writes preferences to default preferences file. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.commons.logging.Log logger
protected transient PropertyChangeSupport propertyChange
protected boolean changedFlag
protected int version
protected int oldVersion
protected String namespace
protected Properties properties
Constructor Detail |
---|
public PropertyResource(int version, String namespace)
PreferencesSupport
object.
version
- the current version of the preferences, this version
can be more recent than the version of the filenamespace
- the namespace, used as a prefix for all keyspublic PropertyResource()
Method Detail |
---|
public void load(File prefsFile) throws IOException
prefsFile
.
IOException
public boolean store(File prefsFile) throws IOException
IOException
has occured
IOException
public boolean equals(Object o)
o
is the same object or if its
version number, namespace and properties map are equal to
this' fields.
equals
in class Object
public int getOldVersion()
public int getVersion()
protected void convert(int oldVersion)
load(File)
to converts preferences from
oldVersion
to current version.
public void addPropertyChangeListener(PropertyChangeListener l)
public void addPropertyChangeListener(String key, PropertyChangeListener l)
addPropertyChangeListener
in interface SettingResource
public void firePropertyChange(String key, Object oldValue, Object newValue)
firePropertyChange
in interface SettingResource
public void removePropertyChangeListener(PropertyChangeListener l)
public void removePropertyChangeListener(String key, PropertyChangeListener l)
removePropertyChangeListener
in interface SettingResource
public String get(String key, String defaultValue)
SettingResource
get
in interface SettingResource
public void put(String key, String newValue)
put
in interface SettingResource
public void remove(String key)
remove
in interface SettingResource
public void renameProperty(String oldKey, String newKey)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |