Class PropertiesHandler
java.lang.Object
org.openjump.io.PropertiesHandler
- All Implemented Interfaces:
HandlerToMakeYourLifeEasier
Class that enables easy access for reading and writing properties files.
- Version:
- $Rev: 1559 $
- Author:
- Ole Rahn
FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancontainsKey(Object key) booleancontainsValue(Object value) elements()getAll()get all properties as Map object (e.g. to feed into an other map...)getProperty(String key) getProperty(String key, String defaultValue) booleanGets the property value with the keykeyand parses it to anbooleanif possible.booleangetPropertyAsBoolean(String key, boolean defaultValue) Gets the property value with the keykeyand parses it to anbooleanif possible.getPropertyAsColor(String key) Gets the property value with the keykeyand parses it to aColorif possible.getPropertyAsColor(String key, Color defaultValue) Gets the property value with the keykeyand parses it to aColorif possible.doubleGets the property value with the keykeyand parses it to adoubleif possible.doublegetPropertyAsDouble(String key, double defaultValue) Gets the property value with the keykeyand parses it to adoubleif possible.intgetPropertyAsInt(String key) Gets the property value with the keykeyand parses it to anintif possible.intgetPropertyAsInt(String key, int defaultValue) Gets the property value with the keykeyand parses it to anintif possible.booleanisEmpty()keys()keySet()voidload()load the properties from the filevoidsetProperty(String key, Color value) Sets a property key-value pair, replaces a pair with the same key!setProperty(String key, String value) Sets a property key-value pair, replaces a pair with the same key!voidstore()Stores the current properties map to the file.voidStores the current properties map to the file.
-
Field Details
-
propertiesFile
-
properties
-
propertiesFileEnding
- See Also:
-
-
Constructor Details
-
PropertiesHandler
Constructor- Parameters:
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.- See Also:
-
-
Method Details
-
contains
- See Also:
-
containsKey
- See Also:
-
containsValue
- See Also:
-
elements
- See Also:
-
getProperty
-
getProperty
-
isEmpty
public boolean isEmpty()- See Also:
-
keys
- See Also:
-
keySet
- See Also:
-
load
load the properties from the file- Throws:
IOException- if an IOException occurs
-
putAll
-
getAll
-
remove
-
setProperty
-
setProperty
-
store
Stores the current properties map to the file.- Parameters:
comments- comments that will appear in the first lines of the file- Throws:
IOException- if an IOException occurs
-
store
Stores the current properties map to the file.- Throws:
IOException- if an IOException occurs
-
getPropertyAsInt
Gets the property value with the keykeyand parses it to anintif 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.- Parameters:
key- the key to get the value of- Returns:
- the value of the property
-
getPropertyAsInt
Gets the property value with the keykeyand parses it to anintif 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.- Parameters:
key- the key to get the value ofdefaultValue- value to be filled in, if the given key wasn't found- Returns:
- the value of the property
-
getPropertyAsBoolean
Gets the property value with the keykeyand parses it to anbooleanif 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.- Parameters:
key- the key to get the value of- Returns:
- the value of the property
-
getPropertyAsBoolean
Gets the property value with the keykeyand parses it to anbooleanif 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.- Parameters:
key- the key to get the value ofdefaultValue- value to be filled in, if the given key wasn't found- Returns:
- the value of the property
-
getPropertyAsDouble
Gets the property value with the keykeyand parses it to adoubleif 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.- Parameters:
key- the key to get the value of- Returns:
- the value of the property
-
getPropertyAsDouble
Gets the property value with the keykeyand parses it to adoubleif 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.- Parameters:
key- the key to get the value ofdefaultValue- value to be filled in, if the given key wasn't found- Returns:
- the value of the property
-
getPropertyAsColor
Gets the property value with the keykeyand parses it to aColorif 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.- Parameters:
key- the key to get the value of- Returns:
- the value of the property
-
getPropertyAsColor
Gets the property value with the keykeyand parses it to aColorif 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.- Parameters:
key- the key to get the value ofdefaultValue- value to be filled in, if the given key wasn't found- Returns:
- the value of the property
-
getPropertiesFile
- Returns:
- the file name of the properties file handled by this instance
-