public class PropertiesHandler extends java.lang.Object implements HandlerToMakeYourLifeEasier
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Properties |
properties |
protected java.lang.String |
propertiesFile |
static java.lang.String |
propertiesFileEnding |
| Constructor and Description |
|---|
PropertiesHandler(java.lang.String propertiesFileName)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(java.lang.Object value) |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Enumeration |
elements() |
java.util.Map<java.lang.String,java.lang.Object> |
getAll()
get all properties as Map object (e.g. to feed into an other map...)
|
java.lang.String |
getPropertiesFile() |
java.lang.String |
getProperty(java.lang.String key) |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue) |
boolean |
getPropertyAsBoolean(java.lang.String key)
Gets the property value with the key
key and parses it
to an boolean if possible. |
boolean |
getPropertyAsBoolean(java.lang.String key,
boolean defaultValue)
Gets the property value with the key
key and parses it
to an boolean if possible. |
java.awt.Color |
getPropertyAsColor(java.lang.String key)
Gets the property value with the key
key and parses it
to a Color if possible. |
java.awt.Color |
getPropertyAsColor(java.lang.String key,
java.awt.Color defaultValue)
Gets the property value with the key
key and parses it
to a Color if possible. |
double |
getPropertyAsDouble(java.lang.String key)
Gets the property value with the key
key and parses it
to a double if possible. |
double |
getPropertyAsDouble(java.lang.String key,
double defaultValue)
Gets the property value with the key
key and parses it
to a double if possible. |
int |
getPropertyAsInt(java.lang.String key)
Gets the property value with the key
key and parses it
to an int if possible. |
int |
getPropertyAsInt(java.lang.String key,
int defaultValue)
Gets the property value with the key
key and parses it
to an int if possible. |
boolean |
isEmpty() |
java.util.Enumeration |
keys() |
java.util.Set |
keySet() |
void |
load()
load the properties from the file
|
void |
putAll(java.util.Map<java.lang.String,java.lang.Object> arg0) |
java.lang.Object |
remove(java.lang.Object arg0) |
java.lang.Object |
setProperty(java.lang.String key,
java.awt.Color value)
Sets a property key-value pair, replaces a pair with the same key!
|
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Sets a property key-value pair, replaces a pair with the same key!
|
void |
store()
Stores the current properties map to the file.
|
void |
store(java.lang.String comments)
Stores the current properties map to the file.
|
protected java.lang.String propertiesFile
protected java.util.Properties properties
public static final java.lang.String propertiesFileEnding
public PropertiesHandler(java.lang.String propertiesFileName)
propertiesFileName - the file name (with out path!) of the properties file, that is to be read or written. It will automatically be placed in the config directory.PirolPlugInSettings.configDirectory()public boolean contains(java.lang.Object value)
Propertiespublic boolean containsKey(java.lang.Object key)
Propertiespublic boolean containsValue(java.lang.Object value)
Propertiespublic java.util.Enumeration elements()
Propertiespublic java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
Propertiespublic java.lang.String getProperty(java.lang.String key)
Propertiespublic boolean isEmpty()
Propertiespublic java.util.Enumeration keys()
Propertiespublic java.util.Set keySet()
Propertiespublic void load()
throws java.io.IOException
java.io.IOExceptionpublic void putAll(java.util.Map<java.lang.String,java.lang.Object> arg0)
Propertiespublic java.util.Map<java.lang.String,java.lang.Object> getAll()
public java.lang.Object remove(java.lang.Object arg0)
Propertiespublic java.lang.Object setProperty(java.lang.String key,
java.lang.String value)
key - the key for the pairvalue - the valuePropertiespublic java.lang.Object setProperty(java.lang.String key,
java.awt.Color value)
key - the key for the pairvalue - the valuePropertiespublic void store(java.lang.String comments)
throws java.io.IOException
comments - comments that will appear in the first lines of the filejava.io.IOExceptionpublic void store()
throws java.io.IOException
java.io.IOExceptionpublic int getPropertyAsInt(java.lang.String key)
key and parses it
to an int if possible. An exception will be thrown,
if this key is not found within the properties and if the value could not
be parsed as desired.key - the key to get the value ofpublic int getPropertyAsInt(java.lang.String key,
int defaultValue)
key and parses it
to an int if possible.
If this key is not found within the properties the given default-Value will be returned.
An exception will be thrown, if the value is existent, but could not be parsed as desired.key - the key to get the value ofdefaultValue - value to be filled in, if the given key wasn't foundpublic boolean getPropertyAsBoolean(java.lang.String key)
key and parses it
to an boolean if possible. An exception will be thrown,
if this key is not found within the properties and if the value could not
be parsed as desired.key - the key to get the value ofpublic boolean getPropertyAsBoolean(java.lang.String key,
boolean defaultValue)
key and parses it
to an boolean if possible.
If this key is not found within the properties the given default-Value will be returned.
An exception will be thrown, if the value is existent, but could not be parsed as desired.key - the key to get the value ofdefaultValue - value to be filled in, if the given key wasn't foundpublic double getPropertyAsDouble(java.lang.String key)
key and parses it
to a double if possible. An exception will be thrown,
if this key is not found within the properties and if the value could not
be parsed as desired.key - the key to get the value ofpublic double getPropertyAsDouble(java.lang.String key,
double defaultValue)
key and parses it
to a double if possible.
If this key is not found within the properties the given default-Value will be returned.
An exception will be thrown, if the value is existent, but could not be parsed as desired.key - the key to get the value ofdefaultValue - value to be filled in, if the given key wasn't foundpublic java.awt.Color getPropertyAsColor(java.lang.String key)
key and parses it
to a Color if possible. An exception will be thrown,
if this key is not found within the properties and if the value could not
be parsed as desired.key - the key to get the value ofpublic java.awt.Color getPropertyAsColor(java.lang.String key,
java.awt.Color defaultValue)
key and parses it
to a Color if possible.
If this key is not found within the properties the given default-Value will be returned.
An exception will be thrown, if the value is existent, but could not be parsed as desired.key - the key to get the value ofdefaultValue - value to be filled in, if the given key wasn't foundpublic java.lang.String getPropertiesFile()