|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.groboutils.util.io.v1.PropertyDatabase
A database of property files. Internally, it uses a ResourceBundle, so that locale specific properties can be used. The format is for the application defined property files to be defined as "read-only", and for a user defined property file to be the readable/writeable properties (i.e. modifications or additions or removals of the default properties). User settings override the read-only settings. The user property file is not localized, and is stored at $home/.app-name/user.properties (or the filename may be specified).
By default, the properties are loaded from the Resource streams, although this can be changed.
Before using this class, you must initialize the user property file
by either setApplicationName( String )
or
setUserPropertyFile( String )
.
The stored data is only of type String, and multiple identical key entries are not possible - only the first one is allowed.
Constructor Summary | |
PropertyDatabase()
Default Constructor |
|
PropertyDatabase(java.util.Locale l)
Specify the Locale to load the properties from. |
Method Summary | |
void |
addResourceBundle(java.lang.String resourceName)
Adds a resource bundle of the given name to the database, from the specified locale. |
protected void |
autoSave()
|
java.io.File |
getApplicationDirectory()
Returns the directory where the user properties are stored for the current application, or null if there is no application set. |
boolean |
getBooleanValue(java.lang.String key)
Convenience function to convert a property to a boolean value. |
byte |
getByteValue(java.lang.String key)
Convenience function to convert a property to a byte value. |
char |
getCharValue(java.lang.String key)
Convenience function to convert a property to a char value. |
double |
getDoubleValue(java.lang.String key)
Convenience function to convert a property to a double value. |
float |
getFloatValue(java.lang.String key)
Convenience function to convert a property to a float value. |
int |
getIntValue(java.lang.String key)
Convenience function to convert a property to an int value. |
long |
getLongValue(java.lang.String key)
Convenience function to convert a property to a long value. |
short |
getShortValue(java.lang.String key)
Convenience function to convert a property to a short value. |
java.lang.String |
getValue(java.lang.String key)
Retrieves the value associated with the given key. |
boolean |
isAutosaveOn()
Retrieves the auto-save setting. |
protected void |
loadUserProperties()
|
java.lang.String |
removeValue(java.lang.String key)
Removes a value from the properties. |
void |
saveUserProperties()
Saves the current user properties. |
void |
setApplicationName(java.lang.String name)
Set the application name and thus the corresponding directory that will store the user properties. |
void |
setAutosaveOn(boolean yes)
Sets the current autosave setting. |
void |
setBooleanValue(java.lang.String key,
boolean value)
Convenience function to convert a boolean value to a String property. |
void |
setByteValue(java.lang.String key,
byte value)
Convenience function to convert a byte value to a String property. |
void |
setCharValue(java.lang.String key,
char value)
Convenience function to convert a char value to a String property. |
void |
setDoubleValue(java.lang.String key,
double value)
Convenience function to convert a byte value to a String property. |
void |
setFloatValue(java.lang.String key,
float value)
Convenience function to convert a float value to a String property. |
void |
setIntValue(java.lang.String key,
int value)
Convenience function to convert an int value to a String property. |
void |
setLongValue(java.lang.String key,
long value)
Convenience function to convert a long value to a String property. |
void |
setShortValue(java.lang.String key,
short value)
Convenience function to convert a short value to a String property. |
void |
setTrace(java.io.PrintWriter tracer)
Sets the trace stream. |
void |
setUserPropertyFile(java.lang.String name)
Set the user property file name exactly. |
void |
setValue(java.lang.String key,
java.lang.String value)
Sets the given value to the user properties. |
java.lang.String |
setValueToDefault(java.lang.String key)
Resets the user property to the resource bundle's default value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PropertyDatabase()
public PropertyDatabase(java.util.Locale l)
Method Detail |
public void setApplicationName(java.lang.String name) throws java.io.IOException
name
- name of the application.
java.io.IOException
public java.io.File getApplicationDirectory()
public void setUserPropertyFile(java.lang.String name) throws java.io.IOException
java.io.IOException
public void saveUserProperties() throws java.io.IOException
java.io.IOException
public void addResourceBundle(java.lang.String resourceName)
public boolean isAutosaveOn()
public void setAutosaveOn(boolean yes)
public java.lang.String removeValue(java.lang.String key)
key
- the key to remove
public void setValue(java.lang.String key, java.lang.String value)
key
- the key to assign the value tovalue
- the value to be assigned to the keypublic java.lang.String getValue(java.lang.String key)
key
- the key to pull the value out ofpublic java.lang.String setValueToDefault(java.lang.String key)
key
- the key to be reset.
public int getIntValue(java.lang.String key)
public void setIntValue(java.lang.String key, int value)
public boolean getBooleanValue(java.lang.String key)
public void setBooleanValue(java.lang.String key, boolean value)
public byte getByteValue(java.lang.String key)
public void setByteValue(java.lang.String key, byte value)
public char getCharValue(java.lang.String key)
public void setCharValue(java.lang.String key, char value)
public double getDoubleValue(java.lang.String key)
public void setDoubleValue(java.lang.String key, double value)
public float getFloatValue(java.lang.String key)
public void setFloatValue(java.lang.String key, float value)
public long getLongValue(java.lang.String key)
public void setLongValue(java.lang.String key, long value)
public short getShortValue(java.lang.String key)
public void setShortValue(java.lang.String key, short value)
public void setTrace(java.io.PrintWriter tracer)
protected void loadUserProperties() throws java.io.IOException
java.io.IOException
protected void autoSave()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |