org.apache.slide.util.conf
Class AbstractConfiguration

java.lang.Object
  extended byorg.apache.slide.util.conf.AbstractConfiguration
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
ConfigurationElement, ConfigurationImpl

public abstract class AbstractConfiguration
extends java.lang.Object
implements Configuration

This is an abstract Configuration implementation that deals with methods that can be abstracted away from underlying implementations. (Betaversion Productions) (Apache Software Foundation) (Apache Software Foundation, Exoffice Technologies)

Version:
CVS $Revision: 1.5 $ $Date: 2004/07/28 09:34:25 $

Field Summary
protected  java.lang.String location
          The location string containing information about this Configuration location in the source file.
 
Constructor Summary
protected AbstractConfiguration()
          Construct a new AbstractConfiguration instance.
protected AbstractConfiguration(java.lang.String source, int line)
          Construct a new AbstractConfiguration instance.
 
Method Summary
 java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
          Returns the value of the attribute specified by its name as a String.
 boolean getAttributeAsBoolean(java.lang.String name)
          Returns the value of the attribute specified by its name as a boolean.
 boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
          Returns the value of the attribute specified by its name as a boolean.
 float getAttributeAsFloat(java.lang.String name)
          Returns the value of the attribute specified by its name as a float.
 float getAttributeAsFloat(java.lang.String name, float defaultValue)
          Returns the value of the attribute specified by its name as a float.
 int getAttributeAsInt(java.lang.String name)
          Returns the value of the attribute specified by its name as an int.
 int getAttributeAsInt(java.lang.String name, int defaultValue)
          Returns the value of the attribute specified by its name as an int.
 long getAttributeAsLong(java.lang.String name)
          Returns the value of the attribute specified by its name as a long.
 long getAttributeAsLong(java.lang.String name, long defaultValue)
          Returns the value of the attribute specified by its name as a long.
 Configuration getConfiguration(java.lang.String name)
          Return the first Configuration object child of this associated with the given name.
 java.lang.String getLocation()
          Return a String indicating the position of this configuration element in a source file or URI or null.
 java.lang.String getValue(java.lang.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 getValueAsInt()
          Returns the value of the configuration element as an int.
 int getValueAsInt(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.slide.util.conf.Configuration
getAttribute, getConfigurations, getName, getValue
 

Field Detail

location

protected java.lang.String location
The location string containing information about this Configuration location in the source file.

Constructor Detail

AbstractConfiguration

protected AbstractConfiguration()
Construct a new AbstractConfiguration instance.


AbstractConfiguration

protected AbstractConfiguration(java.lang.String source,
                                int line)
Construct a new AbstractConfiguration instance.

Method Detail

getValueAsInt

public int getValueAsInt()
                  throws ConfigurationException
Returns the value of the configuration element as an int.

Specified by:
getValueAsInt in interface Configuration
Returns:
the value of the node.
Throws:
ConfigurationException - If conversion to int fails

getValueAsLong

public long getValueAsLong()
                    throws ConfigurationException
Returns the value of the configuration element as a long.

Specified by:
getValueAsLong in interface Configuration
Returns:
the value of the node.
Throws:
ConfigurationException - If conversion to long fails.

getValueAsFloat

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

Specified by:
getValueAsFloat in interface Configuration
Returns:
the value of the node.
Throws:
ConfigurationException - If conversion to float fails.

getValueAsBoolean

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

Specified by:
getValueAsBoolean in interface Configuration
Returns:
the value of the node.
Throws:
ConfigurationException - If conversion to boolean fails.

getValue

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

Specified by:
getValue in interface Configuration
Parameters:
defaultValue - The default value desired.
Returns:
String value of the Configuration, or default if none specified.

getValueAsInt

public int getValueAsInt(int defaultValue)
Returns the value of the configuration element as an int.

Specified by:
getValueAsInt in interface Configuration
Parameters:
defaultValue - The default value desired.
Returns:
int value of the Configuration, or default if none specified.

getValueAsLong

public long getValueAsLong(long defaultValue)
Returns the value of the configuration element as a long.

Specified by:
getValueAsLong in interface Configuration
Parameters:
defaultValue - The default value desired.
Returns:
long value of the Configuration, or default if none specified.

getValueAsFloat

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

Specified by:
getValueAsFloat in interface Configuration
Parameters:
defaultValue - The default value desired.
Returns:
float value of the Configuration, or default if none specified.

getValueAsBoolean

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

Specified by:
getValueAsBoolean in interface Configuration
Parameters:
defaultValue - The default value desired.
Returns:
boolean value of the Configuration, or default if none specified.

getAttributeAsInt

public int getAttributeAsInt(java.lang.String name)
                      throws ConfigurationException
Returns the value of the attribute specified by its name as an int.

Specified by:
getAttributeAsInt in interface Configuration
Parameters:
name - The name of the parameter you ask the value of.
Returns:
int value of attribute
Throws:
ConfigurationException - If no parameter with that name exists. or if conversion to int fails.

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name)
                        throws ConfigurationException
Returns the value of the attribute specified by its name as a long.

Specified by:
getAttributeAsLong in interface Configuration
Parameters:
name - The name of the parameter you ask the value of.
Returns:
long value of attribute
Throws:
ConfigurationException - If no parameter with that name exists. or if conversion to long fails.

getAttributeAsFloat

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

Specified by:
getAttributeAsFloat in interface Configuration
Parameters:
name - The name of the parameter you ask the value of.
Returns:
float value of attribute
Throws:
ConfigurationException - If no parameter with that name exists. or if conversion to float fails.

getAttributeAsBoolean

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

Specified by:
getAttributeAsBoolean in interface Configuration
Parameters:
name - The name of the parameter you ask the value of.
Returns:
boolean value of attribute
Throws:
ConfigurationException - If no parameter with that name exists. or if conversion to boolean fails.

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 a String.

Specified by:
getAttribute in interface Configuration
Parameters:
name - The name of the attribute you ask the value of.
defaultValue - The default value desired.
Returns:
String value of attribute. It will return the default value if the named attribute does not exist, or if the value is not set.

getAttributeAsInt

public int getAttributeAsInt(java.lang.String name,
                             int defaultValue)
Returns the value of the attribute specified by its name as an int.

Specified by:
getAttributeAsInt in interface Configuration
Parameters:
name - The name of the attribute you ask the value of.
defaultValue - The default value desired.
Returns:
int value of attribute. It will return the default value if the named attribute does not exist, or if the value is not set.

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name,
                               long defaultValue)
Returns the value of the attribute specified by its name as a long.

Specified by:
getAttributeAsLong in interface Configuration
Parameters:
name - The name of the attribute you ask the value of.
defaultValue - The default value desired.
Returns:
long value of attribute. It will return the default value if the named attribute does not exist, or if the value is not set.

getAttributeAsFloat

public float getAttributeAsFloat(java.lang.String name,
                                 float defaultValue)
Returns the value of the attribute specified by its name as a float.

Specified by:
getAttributeAsFloat in interface Configuration
Parameters:
name - The name of the attribute you ask the value of.
defaultValue - The default value desired.
Returns:
float value of attribute. It will return the default value if the named attribute does not exist, or if the value is not set.

getAttributeAsBoolean

public boolean getAttributeAsBoolean(java.lang.String name,
                                     boolean defaultValue)
Returns the value of the attribute specified by its name as a boolean.

Specified by:
getAttributeAsBoolean in interface Configuration
Parameters:
name - The name of the attribute you ask the value of.
defaultValue - The default value desired.
Returns:
boolean value of attribute. It will return the default value if the named attribute does not exist, or if the value is not set.

getConfiguration

public Configuration getConfiguration(java.lang.String name)
Return the first Configuration object child of this associated with the given name.

Specified by:
getConfiguration in interface Configuration
Parameters:
name - The name of the child node.
Returns:
Configuration

getLocation

public java.lang.String getLocation()
Return a String indicating the position of this configuration element in a source file or URI or null.

Specified by:
getLocation in interface Configuration
Returns:
String if a source file or URI is specified. Otherwise it returns null