org.codehaus.dna
Interface Configuration

All Known Implementing Classes:
DefaultConfiguration

public interface Configuration

The configuration object represents hierarchial configuration data. The data represented by this object is a simplified XML format. Configuration objects are unable to represent namespace information and elements can not have mixed content. ie Configuration elements can not have both a value and child elements.

Version:
$Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $

Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Return attribute value with specified name.
 java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
          Return attribute value with specified name.
 boolean getAttributeAsBoolean(java.lang.String name)
          Return attribute value with specified name as a boolean.
 boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
          Return attribute value with specified name as a boolean.
 float getAttributeAsFloat(java.lang.String name)
          Return attribute value with specified name as afloat.
 float getAttributeAsFloat(java.lang.String name, float defaultValue)
          Return attribute value with specified name as a float.
 int getAttributeAsInteger(java.lang.String name)
          Return attribute value with specified name as an integer.
 int getAttributeAsInteger(java.lang.String name, int defaultValue)
          Return attribute value with specified name as an integer.
 long getAttributeAsLong(java.lang.String name)
          Return attribute value with specified name as a long.
 long getAttributeAsLong(java.lang.String name, long defaultValue)
          Return attribute value with specified name as a long.
 java.lang.String[] getAttributeNames()
          Return an array of all the attribute names.
 Configuration getChild(java.lang.String name)
          Return a child Configuration element with specified name.
 Configuration getChild(java.lang.String name, boolean createChild)
          Return a child Configuration element with specified name.
 Configuration[] getChildren()
          Return an array of all the child elements.
 Configuration[] getChildren(java.lang.String name)
          Return an array of all the child elements with specified name.
 java.lang.String getLocation()
          Return the location of configuration element.
 java.lang.String getName()
          Return the name of the configuration element.
 java.lang.String getPath()
          Return the path to the configuration element.
 java.lang.String getValue()
          Return text value of element.
 java.lang.String getValue(java.lang.String defaultValue)
          Return text value of element.
 boolean getValueAsBoolean()
          Return text value of element as a boolean.
 boolean getValueAsBoolean(boolean defaultValue)
          Return text value of element as a boolean.
 float getValueAsFloat()
          Return text value of element as a float.
 float getValueAsFloat(float defaultValue)
          Return text value of element as a float.
 int getValueAsInteger()
          Return text value of element as an integer.
 int getValueAsInteger(int defaultValue)
          Return text value of element as an integer.
 long getValueAsLong()
          Return text value of element as a long.
 long getValueAsLong(long defaultValue)
          Return text value of element as a long.
 

Method Detail

getName

public java.lang.String getName()
Return the name of the configuration element.

Returns:
the name of the configuration element.

getPath

public java.lang.String getPath()
Return the path to the configuration element. The path should be in the xpath form but may be the empty string if unabel to determine path.

Returns:
the path to the configuration element.

getLocation

public java.lang.String getLocation()
Return the location of configuration element. Usually of the form "uri[:line number[:column number]]" if possible. ie "file:myFile.xml:80:2". However the line number and column number may be elided if unavailable.

Returns:
the location of configuration element.

getChildren

public Configuration[] getChildren()
Return an array of all the child elements.

Returns:
an array of all the child elements.

getChildren

public Configuration[] getChildren(java.lang.String name)
Return an array of all the child elements with specified name.

Parameters:
name - the name of child configuration objects
Returns:
an array of all the child elements with specified name.

getChild

public Configuration getChild(java.lang.String name)
Return a child Configuration element with specified name. If no such element exists an element will be autocreated.

Parameters:
name - the name of child configuration object
Returns:
a child Configuration element with specified name.

getChild

public Configuration getChild(java.lang.String name,
                              boolean createChild)
Return a child Configuration element with specified name. If no such element exists and createChild is true then an element will be autocreated otherwise null will be returned.

Parameters:
name - the name of child configuration object
createChild - true if child should be created if it does not exist
Returns:
a child Configuration element with specified name.

getValue

public java.lang.String getValue()
                          throws ConfigurationException
Return text value of element.

Returns:
the value
Throws:
ConfigurationException - if no value in element

getValue

public java.lang.String getValue(java.lang.String defaultValue)
Return text value of element. Use specified default if no value in element.

Parameters:
defaultValue - the default value
Returns:
the value

getValueAsInteger

public int getValueAsInteger()
                      throws ConfigurationException
Return text value of element as an integer.

Returns:
the value
Throws:
ConfigurationException - if no value in element or value can not be converted to correct type

getValueAsInteger

public int getValueAsInteger(int defaultValue)
Return text value of element as an integer. Use specified default if no value in element or value can not be converted to correct type.

Parameters:
defaultValue - the default value
Returns:
the value

getValueAsLong

public long getValueAsLong()
                    throws ConfigurationException
Return text value of element as a long.

Returns:
the value
Throws:
ConfigurationException - if no value in element or value can not be converted to correct type

getValueAsLong

public long getValueAsLong(long defaultValue)
Return text value of element as a long. Use specified default if no value in element or value can not be converted to correct type.

Parameters:
defaultValue - the default value
Returns:
the value

getValueAsBoolean

public boolean getValueAsBoolean()
                          throws ConfigurationException
Return text value of element as a boolean.

Returns:
the value
Throws:
ConfigurationException - if no value in element or value can not be converted to correct type

getValueAsBoolean

public boolean getValueAsBoolean(boolean defaultValue)
Return text value of element as a boolean. Use specified default if no value in element or value can not be converted to correct type.

Parameters:
defaultValue - the default value
Returns:
the value

getValueAsFloat

public float getValueAsFloat()
                      throws ConfigurationException
Return text value of element as a float.

Returns:
the value
Throws:
ConfigurationException - if no value in element or value can not be converted to correct type

getValueAsFloat

public float getValueAsFloat(float defaultValue)
Return text value of element as a float. Use specified default if no value in element or value can not be converted to correct type.

Parameters:
defaultValue - the default value
Returns:
the value

getAttributeNames

public java.lang.String[] getAttributeNames()
Return an array of all the attribute names.

Returns:
an array of all the attribute names.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
                              throws ConfigurationException
Return attribute value with specified name.

Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
ConfigurationException - if no attribute with specified name

getAttribute

public java.lang.String getAttribute(java.lang.String name,
                                     java.lang.String defaultValue)
Return attribute value with specified name. If no attribute with specified name then return default value.

Parameters:
name - the attribute name
defaultValue - the default value
Returns:
the attribute value

getAttributeAsInteger

public int getAttributeAsInteger(java.lang.String name)
                          throws ConfigurationException
Return attribute value with specified name as an integer.

Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
ConfigurationException - if no attribute with specified name or attribute can not be converted to correct type

getAttributeAsInteger

public int getAttributeAsInteger(java.lang.String name,
                                 int defaultValue)
Return attribute value with specified name as an integer. If no attribute with specified name or attribute can not be converted to correct type then return default value.

Parameters:
name - the attribute name
defaultValue - the default value
Returns:
the attribute value

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name)
                        throws ConfigurationException
Return attribute value with specified name as a long.

Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
ConfigurationException - if no attribute with specified name or attribute can not be converted to correct type

getAttributeAsLong

public long getAttributeAsLong(java.lang.String name,
                               long defaultValue)
Return attribute value with specified name as a long. If no attribute with specified name or attribute can not be converted to correct type then return default value.

Parameters:
name - the attribute name
defaultValue - the default value
Returns:
the attribute value

getAttributeAsBoolean

public boolean getAttributeAsBoolean(java.lang.String name)
                              throws ConfigurationException
Return attribute value with specified name as a boolean.

Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
ConfigurationException - if no attribute with specified name or attribute can not be converted to correct type

getAttributeAsBoolean

public boolean getAttributeAsBoolean(java.lang.String name,
                                     boolean defaultValue)
Return attribute value with specified name as a boolean. If no attribute with specified name or attribute can not be converted to correct type then return default value.

Parameters:
name - the attribute name
defaultValue - the default value
Returns:
the attribute value

getAttributeAsFloat

public float getAttributeAsFloat(java.lang.String name)
                          throws ConfigurationException
Return attribute value with specified name as afloat.

Parameters:
name - the attribute name
Returns:
the attribute value
Throws:
ConfigurationException - if no attribute with specified name or attribute can not be converted to correct type

getAttributeAsFloat

public float getAttributeAsFloat(java.lang.String name,
                                 float defaultValue)
Return attribute value with specified name as a float. If no attribute with specified name or attribute can not be converted to correct type then return default value.

Parameters:
name - the attribute name
defaultValue - the default value
Returns:
the attribute value


Copyright © 2003-2004 Codehaus. All Rights Reserved.