Class AbstractConfiguration
- java.lang.Object
-
- org.apache.avalon.framework.configuration.AbstractConfiguration
-
- All Implemented Interfaces:
Configuration
- Direct Known Subclasses:
DefaultConfiguration
public abstract class AbstractConfiguration extends java.lang.Object implements Configuration
This is an abstractConfiguration
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
-
-
Constructor Summary
Constructors Constructor Description AbstractConfiguration()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAttribute(java.lang.String name, java.lang.String defaultValue)
Returns the value of the attribute specified by its name as aString
.boolean
getAttributeAsBoolean(java.lang.String name)
Returns the value of the attribute specified by its name as aboolean
.boolean
getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
Returns the value of the attribute specified by its name as aboolean
.float
getAttributeAsFloat(java.lang.String name)
Returns the value of the attribute specified by its name as afloat
.float
getAttributeAsFloat(java.lang.String name, float defaultValue)
Returns the value of the attribute specified by its name as afloat
.int
getAttributeAsInteger(java.lang.String name)
Returns the value of the attribute specified by its name as anint
.int
getAttributeAsInteger(java.lang.String name, int defaultValue)
Returns the value of the attribute specified by its name as anint
.long
getAttributeAsLong(java.lang.String name)
Returns the value of the attribute specified by its name as along
.long
getAttributeAsLong(java.lang.String name, long defaultValue)
Returns the value of the attribute specified by its name as along
.Configuration
getChild(java.lang.String name)
Return the firstConfiguration
object child of this associated with the given name.Configuration
getChild(java.lang.String name, boolean createNew)
Return the firstConfiguration
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 aString
.boolean
getValueAsBoolean()
Returns the value of the configuration element as aboolean
.boolean
getValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as aboolean
.float
getValueAsFloat()
Returns the value of the configuration element as afloat
.float
getValueAsFloat(float defaultValue)
Returns the value of the configuration element as afloat
.int
getValueAsInteger()
Returns the value of the configuration element as anint
.int
getValueAsInteger(int defaultValue)
Returns the value of the configuration element as anint
.long
getValueAsLong()
Returns the value of the configuration element as along
.long
getValueAsLong(long defaultValue)
Returns the value of the configuration element as along
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.avalon.framework.configuration.Configuration
getAttribute, getAttributeNames, getChildren, getChildren, getLocation, getName, getNamespace, getValue
-
-
-
-
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 isnull
.- Since:
- 4.1
-
getValueAsInteger
public int getValueAsInteger() throws ConfigurationException
Returns the value of the configuration element as anint
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getValueAsInteger
in interfaceConfiguration
- Returns:
- the value
- Throws:
ConfigurationException
- if an error occurs
-
getValueAsInteger
public int getValueAsInteger(int defaultValue)
Returns the value of the configuration element as anint
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getValueAsInteger
in interfaceConfiguration
- 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 along
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getValueAsLong
in interfaceConfiguration
- Returns:
- the value
- Throws:
ConfigurationException
- if an error occurs
-
getValueAsLong
public long getValueAsLong(long defaultValue)
Returns the value of the configuration element as along
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getValueAsLong
in interfaceConfiguration
- 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 afloat
.- Specified by:
getValueAsFloat
in interfaceConfiguration
- Returns:
- the value
- Throws:
ConfigurationException
- if an error occurs
-
getValueAsFloat
public float getValueAsFloat(float defaultValue)
Returns the value of the configuration element as afloat
.- Specified by:
getValueAsFloat
in interfaceConfiguration
- 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 aboolean
.- Specified by:
getValueAsBoolean
in interfaceConfiguration
- Returns:
- the value
- Throws:
ConfigurationException
- if an error occurs
-
getValueAsBoolean
public boolean getValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as aboolean
.- Specified by:
getValueAsBoolean
in interfaceConfiguration
- 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 aString
.- Specified by:
getValue
in interfaceConfiguration
- 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 anint
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getAttributeAsInteger
in interfaceConfiguration
- 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 anint
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getAttributeAsInteger
in interfaceConfiguration
- Parameters:
name
- the name of the attributedefaultValue
- 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 along
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getAttributeAsLong
in interfaceConfiguration
- 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 along
. Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.- Specified by:
getAttributeAsLong
in interfaceConfiguration
- Parameters:
name
- the name of the attributedefaultValue
- 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 afloat
.- Specified by:
getAttributeAsFloat
in interfaceConfiguration
- 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 afloat
.- Specified by:
getAttributeAsFloat
in interfaceConfiguration
- Parameters:
name
- the name of the attributedefaultValue
- 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 aboolean
.- Specified by:
getAttributeAsBoolean
in interfaceConfiguration
- Parameters:
name
- the name of the attribute- Returns:
- the value
- Throws:
ConfigurationException
- if an error occurs
-
getAttributeAsBoolean
public boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
Returns the value of the attribute specified by its name as aboolean
.- Specified by:
getAttributeAsBoolean
in interfaceConfiguration
- Parameters:
name
- the name of the attributedefaultValue
- 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 aString
.- Specified by:
getAttribute
in interfaceConfiguration
- Parameters:
name
- the name of the attributedefaultValue
- the default value to return if value malformed or empty- Returns:
- the value
-
getChild
public Configuration getChild(java.lang.String name)
Return the firstConfiguration
object child of this associated with the given name. If no such child exists, a new one will be created.- Specified by:
getChild
in interfaceConfiguration
- Parameters:
name
- the name of the child- Returns:
- the child Configuration
-
getChild
public Configuration getChild(java.lang.String name, boolean createNew)
Return the firstConfiguration
object child of this associated with the given name.- Specified by:
getChild
in interfaceConfiguration
- Parameters:
name
- the name of the childcreateNew
- true if you want to create a new Configuration object if none exists- Returns:
- the child Configuration
-
-