Class AbstractConfiguration
- java.lang.Object
-
- org.apache.avalon.framework.configuration.AbstractConfiguration
-
- All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configuration
- Direct Known Subclasses:
DefaultConfiguration,DefaultImmutableConfiguration
public abstract class AbstractConfiguration extends java.lang.Object implements org.apache.avalon.framework.configuration.ConfigurationThis is an abstractConfigurationimplementation 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
Constructors Constructor Description AbstractConfiguration()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAttribute(java.lang.String name, java.lang.String defaultValue)Returns the value of the attribute specified by its name as aString.booleangetAttributeAsBoolean(java.lang.String name)Returns the value of the attribute specified by its name as aboolean.booleangetAttributeAsBoolean(java.lang.String name, boolean defaultValue)Returns the value of the attribute specified by its name as aboolean.doublegetAttributeAsDouble(java.lang.String name)Returns the value of the attribute specified by its name as adouble.doublegetAttributeAsDouble(java.lang.String name, double defaultValue)Returns the value of the attribute specified by its name as adouble.floatgetAttributeAsFloat(java.lang.String name)Returns the value of the attribute specified by its name as afloat.floatgetAttributeAsFloat(java.lang.String name, float defaultValue)Returns the value of the attribute specified by its name as afloat.intgetAttributeAsInteger(java.lang.String name)Returns the value of the attribute specified by its name as anint.intgetAttributeAsInteger(java.lang.String name, int defaultValue)Returns the value of the attribute specified by its name as anint.longgetAttributeAsLong(java.lang.String name)Returns the value of the attribute specified by its name as along.longgetAttributeAsLong(java.lang.String name, long defaultValue)Returns the value of the attribute specified by its name as along.org.apache.avalon.framework.configuration.ConfigurationgetChild(java.lang.String name)Return the firstConfigurationobject child of this associated with the given name.org.apache.avalon.framework.configuration.ConfigurationgetChild(java.lang.String name, boolean createNew)Return the firstConfigurationobject child of this associated with the given name.protected abstract java.lang.StringgetPrefix()Returns the prefix of the namespace.java.lang.StringgetValue(java.lang.String defaultValue)Returns the value of the configuration element as aString.booleangetValueAsBoolean()Returns the value of the configuration element as aboolean.booleangetValueAsBoolean(boolean defaultValue)Returns the value of the configuration element as aboolean.doublegetValueAsDouble()Returns the value of the configuration element as adouble.doublegetValueAsDouble(double defaultValue)Returns the value of the configuration element as adouble.floatgetValueAsFloat()Returns the value of the configuration element as afloat.floatgetValueAsFloat(float defaultValue)Returns the value of the configuration element as afloat.intgetValueAsInteger()Returns the value of the configuration element as anint.intgetValueAsInteger(int defaultValue)Returns the value of the configuration element as anint.longgetValueAsLong()Returns the value of the configuration element as along.longgetValueAsLong(long defaultValue)Returns the value of the configuration element as along.private booleanisFalse(java.lang.String value)private booleanisTrue(java.lang.String value)java.lang.StringtoString()The toString() operation is used for debugging information.
-
-
-
Method Detail
-
getPrefix
protected abstract java.lang.String getPrefix() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns 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:
org.apache.avalon.framework.configuration.ConfigurationException- if no prefix was defined (prefix isnull.- Since:
- 4.1
-
getValueAsInteger
public int getValueAsInteger() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns 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:
getValueAsIntegerin interfaceorg.apache.avalon.framework.configuration.Configuration- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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:
getValueAsIntegerin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getValueAsLong
public long getValueAsLong() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns 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:
getValueAsLongin interfaceorg.apache.avalon.framework.configuration.Configuration- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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:
getValueAsLongin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getValueAsFloat
public float getValueAsFloat() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the configuration element as afloat.- Specified by:
getValueAsFloatin interfaceorg.apache.avalon.framework.configuration.Configuration- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException- if an error occurs
-
getValueAsFloat
public float getValueAsFloat(float defaultValue)
Returns the value of the configuration element as afloat.- Specified by:
getValueAsFloatin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getValueAsDouble
public double getValueAsDouble() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the configuration element as adouble.- Specified by:
getValueAsDoublein interfaceorg.apache.avalon.framework.configuration.Configuration- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException- if an error occurs
-
getValueAsDouble
public double getValueAsDouble(double defaultValue)
Returns the value of the configuration element as adouble.- Specified by:
getValueAsDoublein interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getValueAsBoolean
public boolean getValueAsBoolean() throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the configuration element as aboolean.- Specified by:
getValueAsBooleanin interfaceorg.apache.avalon.framework.configuration.Configuration- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException- if an error occurs
-
getValueAsBoolean
public boolean getValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as aboolean.- Specified by:
getValueAsBooleanin interfaceorg.apache.avalon.framework.configuration.Configuration- 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:
getValuein interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getAttributeAsInteger
public int getAttributeAsInteger(java.lang.String name) throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns 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:
getAttributeAsIntegerin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attribute- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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:
getAttributeAsIntegerin interfaceorg.apache.avalon.framework.configuration.Configuration- 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 org.apache.avalon.framework.configuration.ConfigurationExceptionReturns 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:
getAttributeAsLongin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attribute- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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:
getAttributeAsLongin interfaceorg.apache.avalon.framework.configuration.Configuration- 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 org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the attribute specified by its name as afloat.- Specified by:
getAttributeAsFloatin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attribute- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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:
getAttributeAsFloatin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attributedefaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getAttributeAsDouble
public double getAttributeAsDouble(java.lang.String name) throws org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the attribute specified by its name as adouble.- Specified by:
getAttributeAsDoublein interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attribute- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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 adouble.- Specified by:
getAttributeAsDoublein interfaceorg.apache.avalon.framework.configuration.Configuration- 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 org.apache.avalon.framework.configuration.ConfigurationExceptionReturns the value of the attribute specified by its name as aboolean.- Specified by:
getAttributeAsBooleanin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attribute- Returns:
- the value
- Throws:
org.apache.avalon.framework.configuration.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 aboolean.- Specified by:
getAttributeAsBooleanin interfaceorg.apache.avalon.framework.configuration.Configuration- 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:
getAttributein interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the attributedefaultValue- the default value to return if value malformed or empty- Returns:
- the value
-
getChild
public org.apache.avalon.framework.configuration.Configuration getChild(java.lang.String name)
Return the firstConfigurationobject child of this associated with the given name. If no such child exists, a new one will be created.- Specified by:
getChildin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the child- Returns:
- the child Configuration
-
getChild
public org.apache.avalon.framework.configuration.Configuration getChild(java.lang.String name, boolean createNew)Return the firstConfigurationobject child of this associated with the given name.- Specified by:
getChildin interfaceorg.apache.avalon.framework.configuration.Configuration- Parameters:
name- the name of the childcreateNew- 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:
toStringin classjava.lang.Object- Returns:
- getName() + "::" + getValue() + ":@" + getLocation();
-
-