Package marauroa.common
Class Configuration
java.lang.Object
marauroa.common.Configuration
This class is a basic configuration file manager
-
Constructor Summary
ConstructorDescriptionConfiguration(ConfigurationParams params)
Create a new COnfiguration instance using filename etc from the given params parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the configuration.This method returns a String with the value of the property.This method returns a String with the value of the property.gets a copy of the configuration as Properties objectstatic Configuration
This method returns an instance of Configurationstatic String
Returns the name of the configuration fileint
This method returns an integer with the value of the property.boolean
This method returns true if the property exists.Enumeration<?>
This method returns an enumeration of the properties that the file containsvoid
This method sets a property with the value we pass as parameterstatic void
setConfigurationFile(boolean relativeToHome, String basedir, String conf)
This method defines the default configuration file for all the instances of Configurationstatic void
setConfigurationFile(String conf)
This method defines the default configuration file for all the instances of Configurationstatic void
setConfigurationPersitance(boolean persistence)
Should the configuration be read from and write to a file?
-
Constructor Details
-
Configuration
Create a new COnfiguration instance using filename etc from the given params parameter.- Parameters:
params
-- Throws:
IOException
-
-
Method Details
-
setConfigurationFile
This method defines the default configuration file for all the instances of Configuration- Parameters:
conf
- the location of the file
-
setConfigurationFile
This method defines the default configuration file for all the instances of Configuration- Parameters:
relativeToHome
- should this file be placed below the users home directory?basedir
- directory prefix which is ignore in webstart environmentconf
- the location of the file
-
setConfigurationPersitance
public static void setConfigurationPersitance(boolean persistence)Should the configuration be read from and write to a file?- Parameters:
persistence
- true to use files, false otherwise
-
getConfigurationFile
Returns the name of the configuration file- Returns:
- the name of the configuration file
-
getConfiguration
This method returns an instance of Configuration- Returns:
- a shared instance of Configuration
- Throws:
IOException
-
get
This method returns a String with the value of the property.- Parameters:
property
- the property we want the value- Returns:
- a string containing the value of the property
-
get
This method returns a String with the value of the property.- Parameters:
property
- the property we want the valuedefaultValue
- a default value in case the property is not defined- Returns:
- a string containing the value of the property
-
getInt
This method returns an integer with the value of the property.- Parameters:
property
- the property we want the valuedefaultValue
- a default value in case the property is not defined- Returns:
- a string containing the value of the property
-
has
This method returns true if the property exists.- Parameters:
property
-- Returns:
- true if the property exists
-
set
This method sets a property with the value we pass as parameter- Parameters:
property
- the property we want to set the valuevalue
- the value to set
-
propertyNames
This method returns an enumeration of the properties that the file contains- Returns:
- enumeration of keys
-
clear
public void clear()Clears the configuration. -
getAsProperties
gets a copy of the configuration as Properties object- Returns:
- Properties
-