raccoon.api.config
Interface IConfig

All Known Implementing Classes:
StdConfig, StrConfig

public interface IConfig

The standard configuration interface. All configuration Services implement this interface, no matter what the source.

Since:
Raccoon v0.1, refactored in Raccoon v0.8
Version:
$Id: IConfig.java,v 1.1 2004/08/08 20:25:55 crouvrais Exp $
Author:
Cedric ROUVRAIS

Field Summary
static java.lang.String PTY_CONFIG
          The name of the property for components using implementations of this interface.
 
Method Summary
 boolean getBoolean(java.lang.String pProperty)
          Reads the value of the propery and converts it to a boolean.
 boolean getBoolean(java.lang.String pProperty, boolean pDefaultValue)
          Reads the value of the propery and converts it to a boolean.
 double getDouble(java.lang.String pProperty)
          Reads the value of the propery and converts it to a double.
 double getDouble(java.lang.String pProperty, double pDefaultValue)
          Reads the value of the propery and converts it to a double.
 int getInt(java.lang.String pProperty)
          Reads the value of the propery and converts it to a integer.
 int getInt(java.lang.String pProperty, int pDefaultValue)
          Reads the value of the propery and converts it to a integer.
 long getLong(java.lang.String pProperty)
          Reads the value of the propery and converts it to a long.
 long getLong(java.lang.String pProperty, long pDefaultValue)
          Reads the value of the propery and converts it to a long.
 java.util.Properties getProperties()
          Extracts all the available properties to a convenient format.
 java.lang.String getString(java.lang.String pProperty)
          Reads the value of the propery and converts it to a String.
 java.lang.String getString(java.lang.String pProperty, java.lang.Object[] pParams)
          Retrieves a Message String from the configuration file and converts it into a String.
 java.lang.String getString(java.lang.String pProperty, java.lang.Object[] pParams, java.lang.String pDefaultValue)
          Retrieves a Message String from the configuration file and converts it into a String.
 java.lang.String getString(java.lang.String pProperty, java.lang.String pDefaultValue)
          Reads the value of the propery and converts it to a String.
 java.util.StringTokenizer getStrings(java.lang.String pProperty)
          Reads the value of the property and returns a StringTokenizer object.
 boolean isAvailable(java.lang.String pProperty)
          Convenience method to check if a specific property is defined.
 void refresh()
          Reload the properties from the properties file.
 

Field Detail

PTY_CONFIG

static final java.lang.String PTY_CONFIG
The name of the property for components using implementations of this interface.

See Also:
Constant Field Values
Method Detail

isAvailable

boolean isAvailable(java.lang.String pProperty)
                    throws RaccoonException
Convenience method to check if a specific property is defined.

Parameters:
pProperty - the property to search for.
Returns:
is the property in the configuration file.
Throws:
RaccoonException - if this component is active.

getBoolean

boolean getBoolean(java.lang.String pProperty)
                   throws RaccoonException,
                          java.lang.NumberFormatException
Reads the value of the propery and converts it to a boolean. This method will return true if the value of the property is a String(true) or is 1. This method will return false if the value of the property is a String(false) or is 0.

Parameters:
pProperty - the property to look for
Returns:
the boolean value for the requested property
Throws:
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a boolean.

getBoolean

boolean getBoolean(java.lang.String pProperty,
                   boolean pDefaultValue)
Reads the value of the propery and converts it to a boolean. This method will return true if the value of the property is a String(true) or is 1. This method will return false if the value of the property is a String(false) or is 0. This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property to look for
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the boolean value for the requested property

getInt

int getInt(java.lang.String pProperty)
           throws RaccoonException,
                  java.lang.NumberFormatException
Reads the value of the propery and converts it to a integer.

Parameters:
pProperty - the property to look for
Returns:
the integer value for the requested property
Throws:
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a int.

getInt

int getInt(java.lang.String pProperty,
           int pDefaultValue)
Reads the value of the propery and converts it to a integer. This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property to look for
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the integer value for the requested property

getLong

long getLong(java.lang.String pProperty)
             throws RaccoonException,
                    java.lang.NumberFormatException
Reads the value of the propery and converts it to a long.

Parameters:
pProperty - the property to look for
Returns:
the long value for the requested property
Throws:
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a long.

getLong

long getLong(java.lang.String pProperty,
             long pDefaultValue)
Reads the value of the propery and converts it to a long. This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property to look for
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the long value for the requested property

getDouble

double getDouble(java.lang.String pProperty)
                 throws RaccoonException
Reads the value of the propery and converts it to a double.

Parameters:
pProperty - the property to look for
Returns:
the double value for the requested property
Throws:
RaccoonException - if the value can't be found or is invalid.

getDouble

double getDouble(java.lang.String pProperty,
                 double pDefaultValue)
Reads the value of the propery and converts it to a double. This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property to look for
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the double value for the requested property

getStrings

java.util.StringTokenizer getStrings(java.lang.String pProperty)
                                     throws RaccoonException
Reads the value of the property and returns a StringTokenizer object.

Parameters:
pProperty - the property for which the data is required.
Returns:
a string tokenizer based in the given property data
Throws:
RaccoonException - if the property couldn't be found.

getString

java.lang.String getString(java.lang.String pProperty)
                           throws RaccoonException
Reads the value of the propery and converts it to a String.

Parameters:
pProperty - the property to look for
Returns:
the String value for the requested property
Throws:
RaccoonException - if the value is an invalid String

getString

java.lang.String getString(java.lang.String pProperty,
                           java.lang.String pDefaultValue)
Reads the value of the propery and converts it to a String. This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property to look for
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the String value for the requested property

getString

java.lang.String getString(java.lang.String pProperty,
                           java.lang.Object[] pParams)
                           throws RaccoonException
Retrieves a Message String from the configuration file and converts it into a String.

A Message String is a specific String, because each occurrence of {i} in that String will be replaced by Object[i].toString()

For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
Will result in the following String being returned:
"Hello Kathleen, you have mail"

No matter what the implementation behind the scenes is.

Parameters:
pProperty - the property that is to be retrieved.
pParams - a list of objects implementing the toString() method that will be inserted into the resulting String
Returns:
the value of the given property that has been formatted.
Throws:
RaccoonException - if this method fails

getString

java.lang.String getString(java.lang.String pProperty,
                           java.lang.Object[] pParams,
                           java.lang.String pDefaultValue)
Retrieves a Message String from the configuration file and converts it into a String.

A Message String is a specific String, because each occurrence of {i} in that String will be replaced by Object[i].toString()

For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
Will result in the following String being returned:
"Hello Kathleen, you have mail"

No matter what the implementation behind the scenes is.

This method will return pDefaultvalue if any error occurs.

Parameters:
pProperty - the property that is to be retrieved.
pParams - a list of objects implementing the toString() method that will be inserted into the resulting String
pDefaultValue - the default value returned if the property is not found in the config file
Returns:
the value of the given property that has been formatted.

refresh

void refresh()
             throws RaccoonException
Reload the properties from the properties file.

Throws:
RaccoonException - if this component hasn't been initialised.

getProperties

java.util.Properties getProperties()
                                   throws RaccoonException
Extracts all the available properties to a convenient format.

Returns:
all properties as a Properties object
Throws:
RaccoonException - if the component isn't active


Copyright null null. All Rights Reserved.