org.apache.avalon.framework.configuration

Class AbstractConfiguration

public abstract class AbstractConfiguration extends Object implements Configuration

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

Version: CVS $Revision: 1.28 $ $Date: 2003/02/11 16:19:27 $

Author: Avalon Development Team

Method Summary
StringgetAttribute(String name, String defaultValue)
Returns the value of the attribute specified by its name as a String.
booleangetAttributeAsBoolean(String name)
Returns the value of the attribute specified by its name as a boolean.
booleangetAttributeAsBoolean(String name, boolean defaultValue)
Returns the value of the attribute specified by its name as a boolean.
floatgetAttributeAsFloat(String name)
Returns the value of the attribute specified by its name as a float.
floatgetAttributeAsFloat(String name, float defaultValue)
Returns the value of the attribute specified by its name as a float.
intgetAttributeAsInteger(String name)
Returns the value of the attribute specified by its name as an int.
intgetAttributeAsInteger(String name, int defaultValue)
Returns the value of the attribute specified by its name as an int.
longgetAttributeAsLong(String name)
Returns the value of the attribute specified by its name as a long.
longgetAttributeAsLong(String name, long defaultValue)
Returns the value of the attribute specified by its name as a long.
ConfigurationgetChild(String name)
Return the first Configuration object child of this associated with the given name.
ConfigurationgetChild(String name, boolean createNew)
Return the first Configuration object child of this associated with the given name.
protected abstract StringgetPrefix()
Returns the prefix of the namespace.
StringgetValue(String defaultValue)
Returns the value of the configuration element as a String.
booleangetValueAsBoolean()
Returns the value of the configuration element as a boolean.
booleangetValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as a boolean.
floatgetValueAsFloat()
Returns the value of the configuration element as a float.
floatgetValueAsFloat(float defaultValue)
Returns the value of the configuration element as a float.
intgetValueAsInteger()
Returns the value of the configuration element as an int.
intgetValueAsInteger(int defaultValue)
Returns the value of the configuration element as an int.
longgetValueAsLong()
Returns the value of the configuration element as a long.
longgetValueAsLong(long defaultValue)
Returns the value of the configuration element as a long.

Method Detail

getAttribute

public String getAttribute(String name, 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

getAttributeAsBoolean

public boolean getAttributeAsBoolean(String name)
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

getAttributeAsBoolean

public boolean getAttributeAsBoolean(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

getAttributeAsFloat

public float getAttributeAsFloat(String name)
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(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

getAttributeAsInteger

public int getAttributeAsInteger(String name)
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(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(String name)
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(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

getChild

public Configuration getChild(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(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

getPrefix

protected abstract String getPrefix()
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

getValue

public String getValue(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

getValueAsBoolean

public boolean getValueAsBoolean()
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

getValueAsFloat

public float getValueAsFloat()
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

getValueAsInteger

public int getValueAsInteger()
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()
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