org.apache.avalon.framework.configuration
Class AbstractConfiguration

java.lang.Object
  extended by org.apache.avalon.framework.configuration.AbstractConfiguration
Direct Known Subclasses:
DefaultConfiguration, DefaultImmutableConfiguration

public abstract class AbstractConfiguration
extends java.lang.Object

This is an abstract Configuration implementation that deals with methods that can be abstracted away from underlying implementations.

Version:
$Id: AbstractConfiguration.java 156533 2005-03-08 08:51:40 -0600 (Tue, 08 Mar 2005) leif $
Author:
Avalon Development Team

Constructor Summary
AbstractConfiguration()
           
 
Method Summary
 java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
          Returns the value of the attribute specified by its name as a String.
 boolean getAttributeAsBoolean(java.lang.String name)
          Returns the value of the attribute specified by its name as a boolean.
 boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
          Returns the value of the attribute specified by its name as a boolean.
 double getAttributeAsDouble(java.lang.String name)
          Returns the value of the attribute specified by its name as a double.
 double getAttributeAsDouble(java.lang.String name, double defaultValue)
          Returns the value of the attribute specified by its name as a double.
 float getAttributeAsFloat(java.lang.String name)
          Returns the value of the attribute specified by its name as a float.
 float getAttributeAsFloat(java.lang.String name, float defaultValue)
          Returns the value of the attribute specified by its name as a float.
 int getAttributeAsInteger(java.lang.String name)
          Returns the value of the attribute specified by its name as an int.
 int getAttributeAsInteger(java.lang.String name, int defaultValue)
          Returns the value of the attribute specified by its name as an int.
 long getAttributeAsLong(java.lang.String name)
          Returns the value of the attribute specified by its name as a long.
 long getAttributeAsLong(java.lang.String name, long defaultValue)
          Returns the value of the attribute specified by its name as a long.
 Configuration getChild(java.lang.String name)
          Return the first Configuration object child of this associated with the given name.
 Configuration getChild(java.lang.String name, boolean createNew)
          Return the first Configuration object child of this associated with the given name.
protected abstract  java.lang.String getPrefix()
          Returns the prefix of the namespace.
 java.lang.String getValue(java.lang.String defaultValue)
          Returns the value of the configuration element as a String.
 boolean getValueAsBoolean()
          Returns the value of the configuration element as a boolean.
 boolean getValueAsBoolean(boolean defaultValue)
          Returns the value of the configuration element as a boolean.
 double getValueAsDouble()
          Returns the value of the configuration element as a double.
 double getValueAsDouble(double defaultValue)
          Returns the value of the configuration element as a double.
 float getValueAsFloat()
          Returns the value of the configuration element as a float.
 float getValueAsFloat(float defaultValue)
          Returns the value of the configuration element as a float.
 int getValueAsInteger()
          Returns the value of the configuration element as an int.
 int getValueAsInteger(int defaultValue)
          Returns the value of the configuration element as an int.
 long getValueAsLong()
          Returns the value of the configuration element as a long.
 long getValueAsLong(long defaultValue)
          Returns the value of the configuration element as a long.
private  boolean isFalse(java.lang.String value)
           
private  boolean isTrue(java.lang.String value)
           
 java.lang.String toString()
          The toString() operation is used for debugging information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractConfiguration

public AbstractConfiguration()
Method Detail

getPrefix

protected abstract java.lang.String getPrefix()
                                       throws ConfigurationException
Returns the prefix of the namespace. This is only used as a serialization hint, therefore is not part of the client API. It should be included in all Configuration implementations though.

Returns:
A non-null String (defaults to "")
Throws:
ConfigurationException - if no prefix was defined (prefix is null.
Since:
4.1

getValueAsInteger

public int getValueAsInteger()
                      throws ConfigurationException
Returns the value of the configuration element as an int. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Returns:
the value
Throws:
ConfigurationException - if an error occurs

getValueAsInteger

public int getValueAsInteger(int defaultValue)
Returns the value of the configuration element as an int. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getValueAsLong

public long getValueAsLong()
                    throws ConfigurationException
Returns the value of the configuration element as a long. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Returns:
the value
Throws:
ConfigurationException - if an error occurs

getValueAsLong

public long getValueAsLong(long defaultValue)
Returns the value of the configuration element as a long. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getValueAsFloat

public float getValueAsFloat()
                      throws ConfigurationException
Returns the value of the configuration element as a float.

Returns:
the value
Throws:
ConfigurationException - if an error occurs

getValueAsFloat

public float getValueAsFloat(float defaultValue)
Returns the value of the configuration element as a float.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getValueAsDouble

public double getValueAsDouble()
                        throws ConfigurationException
Returns the value of the configuration element as a double.

Returns:
the value
Throws:
ConfigurationException - if an error occurs

getValueAsDouble

public double getValueAsDouble(double defaultValue)
Returns the value of the configuration element as a double.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getValueAsBoolean

public boolean getValueAsBoolean()
                          throws ConfigurationException
Returns the value of the configuration element as a boolean.

Returns:
the value
Throws:
ConfigurationException - if an error occurs

getValueAsBoolean

public boolean getValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as a boolean.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getValue

public java.lang.String getValue(java.lang.String defaultValue)
Returns the value of the configuration element as a String.

Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttributeAsInteger

public int getAttributeAsInteger(java.lang.String name)
                          throws ConfigurationException
Returns the value of the attribute specified by its name as an int. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
name - the name of the attribute
Returns:
the value
Throws:
ConfigurationException - if an error occurs

getAttributeAsInteger

public int getAttributeAsInteger(java.lang.String name,
                                 int defaultValue)
Returns the value of the attribute specified by its name as an int. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name)
                        throws ConfigurationException
Returns the value of the attribute specified by its name as a long. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
name - the name of the attribute
Returns:
the value
Throws:
ConfigurationException - if an error occurs

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name,
                               long defaultValue)
Returns the value of the attribute specified by its name as a long. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttributeAsFloat

public float getAttributeAsFloat(java.lang.String name)
                          throws ConfigurationException
Returns the value of the attribute specified by its name as a float.

Parameters:
name - the name of the attribute
Returns:
the value
Throws:
ConfigurationException - if an error occurs

getAttributeAsFloat

public float getAttributeAsFloat(java.lang.String name,
                                 float defaultValue)
Returns the value of the attribute specified by its name as a float.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttributeAsDouble

public double getAttributeAsDouble(java.lang.String name)
                            throws ConfigurationException
Returns the value of the attribute specified by its name as a double.

Parameters:
name - the name of the attribute
Returns:
the value
Throws:
ConfigurationException - if an error occurs

getAttributeAsDouble

public double getAttributeAsDouble(java.lang.String name,
                                   double defaultValue)
Returns the value of the attribute specified by its name as a double.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttributeAsBoolean

public boolean getAttributeAsBoolean(java.lang.String name)
                              throws ConfigurationException
Returns the value of the attribute specified by its name as a boolean.

Parameters:
name - the name of the attribute
Returns:
the value
Throws:
ConfigurationException - if an error occurs

isTrue

private boolean isTrue(java.lang.String value)

isFalse

private boolean isFalse(java.lang.String value)

getAttributeAsBoolean

public boolean getAttributeAsBoolean(java.lang.String name,
                                     boolean defaultValue)
Returns the value of the attribute specified by its name as a boolean.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getAttribute

public java.lang.String getAttribute(java.lang.String name,
                                     java.lang.String defaultValue)
Returns the value of the attribute specified by its name as a String.

Parameters:
name - the name of the attribute
defaultValue - the default value to return if value malformed or empty
Returns:
the value

getChild

public Configuration getChild(java.lang.String name)
Return the first Configuration object child of this associated with the given name. If no such child exists, a new one will be created.

Parameters:
name - the name of the child
Returns:
the child Configuration

getChild

public Configuration getChild(java.lang.String name,
                              boolean createNew)
Return the first Configuration object child of this associated with the given name.

Parameters:
name - the name of the child
createNew - true if you want to create a new Configuration object if none exists
Returns:
the child Configuration

toString

public java.lang.String toString()
The toString() operation is used for debugging information. It does not create a deep reproduction of this configuration and all child configurations, instead it displays the name, value, and location.

Overrides:
toString in class java.lang.Object
Returns:
getName() + "::" + getValue() + ":@" + getLocation();