org.apache.avalon.framework.configuration
Class DefaultConfiguration

java.lang.Object
  |
  +--org.apache.avalon.framework.configuration.AbstractConfiguration
        |
        +--org.apache.avalon.framework.configuration.DefaultConfiguration
All Implemented Interfaces:
Configuration

public class DefaultConfiguration
extends AbstractConfiguration

This is the default Configuration implementation.

Author:
Federico Barbieri, Stefano Mazzocchi, Pierpaolo Fumagalli, Peter Donald

Field Summary
protected static Configuration[] EMPTY_ARRAY
           
protected  java.util.HashMap m_attributes
           
protected  java.util.ArrayList m_children
           
protected  java.lang.String m_location
           
protected  java.lang.String m_name
           
protected  java.lang.String m_value
           
 
Constructor Summary
DefaultConfiguration(java.lang.String name, java.lang.String location)
          Create a new DefaultConfiguration instance.
 
Method Summary
 java.lang.String addAttribute(java.lang.String name, java.lang.String value)
          Add an attribute to this configuration element, returning its old value or null.
 void addChild(Configuration configuration)
          Add a child Configuration to this configuration element.
 void appendValueData(java.lang.String value)
          Append data to the value of this configuration element.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the attribute specified by its name as a String.
 java.lang.String[] getAttributeNames()
          Return an array of all attribute names.
 Configuration getChild(java.lang.String name, boolean createNew)
          Return the first Configuration object child of this associated with the given name.
 int getChildCount()
          Return count of children.
 Configuration[] getChildren()
          Return an Iterator of Configuration elements containing all node children.
 Configuration[] getChildren(java.lang.String name)
          Return an Enumeration of Configuration objects children of this associated with the given name.
 java.lang.String getLocation()
          Returns a description of location of element.
 java.lang.String getName()
          Returns the name of this configuration element.
 java.lang.String getValue()
          Returns the value of the configuration element as a String.
 void removeChild(Configuration configuration)
          Remove a child Configuration to this configuration element.
 void setAttribute(java.lang.String name, java.lang.String value)
           
 void setValue(java.lang.String value)
           
 
Methods inherited from class org.apache.avalon.framework.configuration.AbstractConfiguration
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValue, getValueAsBoolean, getValueAsBoolean, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

protected static final Configuration[] EMPTY_ARRAY

m_name

protected final java.lang.String m_name

m_location

protected final java.lang.String m_location

m_attributes

protected java.util.HashMap m_attributes

m_children

protected java.util.ArrayList m_children

m_value

protected java.lang.String m_value
Constructor Detail

DefaultConfiguration

public DefaultConfiguration(java.lang.String name,
                            java.lang.String location)
Create a new DefaultConfiguration instance.
Method Detail

getName

public java.lang.String getName()
Returns the name of this configuration element.
Following copied from interface: org.apache.avalon.framework.configuration.Configuration
Returns:
name of the Configuration node.

getLocation

public java.lang.String getLocation()
Returns a description of location of element.
Following copied from interface: org.apache.avalon.framework.configuration.Configuration
Returns:
a string describing location of Configuration

getValue

public java.lang.String getValue()
                          throws ConfigurationException
Returns the value of the configuration element as a String.
Throws:
ConfigurationException - If the value is not present.

getAttributeNames

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

getChildren

public Configuration[] getChildren()
Return an Iterator of Configuration elements containing all node children.
Returns:
The child nodes with name

getAttribute

public java.lang.String getAttribute(java.lang.String name)
                              throws ConfigurationException
Returns the value of the attribute specified by its name as a String.
Throws:
ConfigurationException - If the attribute is not present.

getChild

public Configuration getChild(java.lang.String name,
                              boolean createNew)
Return the first Configuration object child of this associated with the given name.
Overrides:
getChild in class AbstractConfiguration
Following copied from interface: org.apache.avalon.framework.configuration.Configuration
Parameters:
child - The name of the child node.
Returns:
Configuration

getChildren

public Configuration[] getChildren(java.lang.String name)
Return an Enumeration of Configuration objects children of this associated with the given name.
The returned Enumeration may be empty.
Parameters:
name - The name of the required children Configuration.

appendValueData

public void appendValueData(java.lang.String value)
Append data to the value of this configuration element.

setValue

public void setValue(java.lang.String value)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)

addAttribute

public java.lang.String addAttribute(java.lang.String name,
                                     java.lang.String value)
Add an attribute to this configuration element, returning its old value or null.

addChild

public void addChild(Configuration configuration)
Add a child Configuration to this configuration element.

removeChild

public void removeChild(Configuration configuration)
Remove a child Configuration to this configuration element.

getChildCount

public int getChildCount()
Return count of children.


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.