org.compass.core.util.config
Class AbstractConfigurationHelper

java.lang.Object
  extended by org.compass.core.util.config.AbstractConfigurationHelper
All Implemented Interfaces:
ConfigurationHelper
Direct Known Subclasses:
PlainConfigurationHelper

public abstract class AbstractConfigurationHelper
extends Object
implements ConfigurationHelper

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


Constructor Summary
AbstractConfigurationHelper()
           
 
Method Summary
 String getAttribute(String name, String defaultValue)
          Returns the value of the attribute specified by its name as a String.
 boolean getAttributeAsBoolean(String name)
          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.
 float getAttributeAsFloat(String name)
          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 getAttributeAsInteger(String name)
          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 getAttributeAsLong(String name)
          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.
 ConfigurationHelper getChild(String name)
          Return the first Configuration object child of this associated with the given name.
 ConfigurationHelper getChild(String name, boolean createNew)
          Return the first Configuration object child of this associated with the given name.
protected abstract  String getPrefix()
          Returns the prefix of the namespace.
 String getValue(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.
 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.
 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
 
Methods inherited from interface org.compass.core.util.config.ConfigurationHelper
getAttribute, getAttributeNames, getAttributeOrValue, getChildren, getChildren, getChildren, getLocation, getName, getValue, makeReadOnly
 

Constructor Detail

AbstractConfigurationHelper

public AbstractConfigurationHelper()
Method Detail

getPrefix

protected abstract 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.

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.

Specified by:
getValueAsInteger in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

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.

Specified by:
getValueAsLong in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

getValueAsFloat

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

Specified by:
getValueAsFloat in interface ConfigurationHelper
Throws:
ConfigurationException

getValueAsFloat

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

Specified by:
getValueAsFloat in interface ConfigurationHelper

getValueAsBoolean

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

Specified by:
getValueAsBoolean in interface ConfigurationHelper
Throws:
ConfigurationException

getValueAsBoolean

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

Specified by:
getValueAsBoolean in interface ConfigurationHelper

getValue

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

Specified by:
getValue in interface ConfigurationHelper

getAttributeAsInteger

public int getAttributeAsInteger(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.

Specified by:
getAttributeAsInteger in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

getAttributeAsLong

public long getAttributeAsLong(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.

Specified by:
getAttributeAsLong in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

getAttributeAsFloat

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

Specified by:
getAttributeAsFloat in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

getAttributeAsBoolean

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

Specified by:
getAttributeAsBoolean in interface ConfigurationHelper
Throws:
ConfigurationException

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 ConfigurationHelper

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 ConfigurationHelper

getChild

public ConfigurationHelper 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 ConfigurationHelper

getChild

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

Specified by:
getChild in interface ConfigurationHelper

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();


Copyright (c) 2004-2008 The Compass Project.