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 Object implements org.apache.avalon.framework.configuration.Configuration
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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getAttribute(String name, String defaultValue)
    Returns the value of the attribute specified by its name as a String.
    boolean
    Returns the value of the attribute specified by its name as a boolean.
    boolean
    getAttributeAsBoolean(String name, boolean defaultValue)
    Returns the value of the attribute specified by its name as a boolean.
    double
    Returns the value of the attribute specified by its name as a double.
    double
    getAttributeAsDouble(String name, double defaultValue)
    Returns the value of the attribute specified by its name as a double.
    float
    Returns the value of the attribute specified by its name as a float.
    float
    getAttributeAsFloat(String name, float defaultValue)
    Returns the value of the attribute specified by its name as a float.
    int
    Returns the value of the attribute specified by its name as an int.
    int
    getAttributeAsInteger(String name, int defaultValue)
    Returns the value of the attribute specified by its name as an int.
    long
    Returns the value of the attribute specified by its name as a long.
    long
    getAttributeAsLong(String name, long defaultValue)
    Returns the value of the attribute specified by its name as a long.
    org.apache.avalon.framework.configuration.Configuration
    Return the first Configuration object child of this associated with the given name.
    org.apache.avalon.framework.configuration.Configuration
    getChild(String name, boolean createNew)
    Return the first Configuration object child of this associated with the given name.
    protected abstract String
    Returns the prefix of the namespace.
    getValue(String defaultValue)
    Returns the value of the configuration element as a String.
    boolean
    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
    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
    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
    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
    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(String value)
     
    private boolean
    isTrue(String value)
     
    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

    Methods inherited from interface org.apache.avalon.framework.configuration.Configuration

    getAttribute, getAttributeNames, getChildren, getChildren, getLocation, getName, getNamespace, getValue
  • Constructor Details

    • AbstractConfiguration

      public AbstractConfiguration()
  • Method Details

    • getPrefix

      protected abstract String getPrefix() throws org.apache.avalon.framework.configuration.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:
      org.apache.avalon.framework.configuration.ConfigurationException - if no prefix was defined (prefix is null.
      Since:
      4.1
    • getValueAsInteger

      public int getValueAsInteger() throws org.apache.avalon.framework.configuration.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.
      Specified by:
      getValueAsInteger in interface org.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 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.
      Specified by:
      getValueAsInteger in interface org.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.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.
      Specified by:
      getValueAsLong in interface org.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 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.
      Specified by:
      getValueAsLong in interface org.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.ConfigurationException
      Returns the value of the configuration element as a float.
      Specified by:
      getValueAsFloat in interface org.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 a float.
      Specified by:
      getValueAsFloat in interface org.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.ConfigurationException
      Returns the value of the configuration element as a double.
      Specified by:
      getValueAsDouble in interface org.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 a double.
      Specified by:
      getValueAsDouble in interface org.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.ConfigurationException
      Returns the value of the configuration element as a boolean.
      Specified by:
      getValueAsBoolean in interface org.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 a boolean.
      Specified by:
      getValueAsBoolean in interface org.apache.avalon.framework.configuration.Configuration
      Parameters:
      defaultValue - the default value to return if value malformed or empty
      Returns:
      the value
    • getValue

      public String getValue(String defaultValue)
      Returns the value of the configuration element as a String.
      Specified by:
      getValue in interface org.apache.avalon.framework.configuration.Configuration
      Parameters:
      defaultValue - the default value to return if value malformed or empty
      Returns:
      the value
    • getAttributeAsInteger

      public int getAttributeAsInteger(String name) throws org.apache.avalon.framework.configuration.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.
      Specified by:
      getAttributeAsInteger in interface org.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(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.
      Specified by:
      getAttributeAsInteger in interface org.apache.avalon.framework.configuration.Configuration
      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) throws org.apache.avalon.framework.configuration.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.
      Specified by:
      getAttributeAsLong in interface org.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(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.
      Specified by:
      getAttributeAsLong in interface org.apache.avalon.framework.configuration.Configuration
      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) throws org.apache.avalon.framework.configuration.ConfigurationException
      Returns the value of the attribute specified by its name as a float.
      Specified by:
      getAttributeAsFloat in interface org.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(String name, float defaultValue)
      Returns the value of the attribute specified by its name as a float.
      Specified by:
      getAttributeAsFloat in interface org.apache.avalon.framework.configuration.Configuration
      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(String name) throws org.apache.avalon.framework.configuration.ConfigurationException
      Returns the value of the attribute specified by its name as a double.
      Specified by:
      getAttributeAsDouble in interface org.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(String name, double defaultValue)
      Returns the value of the attribute specified by its name as a double.
      Specified by:
      getAttributeAsDouble in interface org.apache.avalon.framework.configuration.Configuration
      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) throws org.apache.avalon.framework.configuration.ConfigurationException
      Returns the value of the attribute specified by its name as a boolean.
      Specified by:
      getAttributeAsBoolean in interface org.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(String value)
    • isFalse

      private boolean isFalse(String value)
    • getAttributeAsBoolean

      public boolean getAttributeAsBoolean(String name, boolean defaultValue)
      Returns the value of the attribute specified by its name as a boolean.
      Specified by:
      getAttributeAsBoolean in interface org.apache.avalon.framework.configuration.Configuration
      Parameters:
      name - the name of the attribute
      defaultValue - the default value to return if value malformed or empty
      Returns:
      the value
    • getAttribute

      public String getAttribute(String name, String defaultValue)
      Returns the value of the attribute specified by its name as a String.
      Specified by:
      getAttribute in interface org.apache.avalon.framework.configuration.Configuration
      Parameters:
      name - the name of the attribute
      defaultValue - the default value to return if value malformed or empty
      Returns:
      the value
    • getChild

      public org.apache.avalon.framework.configuration.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.
      Specified by:
      getChild in interface org.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(String name, boolean createNew)
      Return the first Configuration object child of this associated with the given name.
      Specified by:
      getChild in interface org.apache.avalon.framework.configuration.Configuration
      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 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 Object
      Returns:
      getName() + "::" + getValue() + ":@" + getLocation();