org.apache.avalon.framework.configuration

Class DefaultImmutableConfiguration

Implemented Interfaces:
Serializable

public class DefaultImmutableConfiguration
extends AbstractConfiguration
implements Serializable

An immutable implementation of the Configuration interface.
Version:
CVS $Revision: 1.2 $ $Date: 2004/02/11 14:34:25 $
Author:
Avalon Development Team

Field Summary

protected static Configuration[]
EMPTY_ARRAY
An empty (length zero) array of configuration objects.

Constructor Summary

DefaultImmutableConfiguration(Configuration config)
Deep copy constructor.

Method Summary

boolean
equals(Object other)
Compare if this configuration is equal to another.
String
getAttribute(String name)
Returns the value of the attribute specified by its name as a String.
String[]
getAttributeNames()
Return an array of all attribute names.
Configuration
getChild(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 array of Configuration elements containing all node children.
Configuration[]
getChildren(String name)
Return an array of Configuration objects children of this associated with the given name.
String
getLocation()
Returns a description of location of element.
String
getName()
Returns the name of this configuration element.
String
getNamespace()
Returns the namespace of this configuration element
protected String
getPrefix()
Returns the prefix of the namespace
String
getValue()
Returns the value of the configuration element as a String.
String
getValue(String defaultValue)
Returns the value of the configuration element as a String.
int
hashCode()
Obtaine the hashcode for this configuration.

Field Details

EMPTY_ARRAY

protected static final Configuration[] EMPTY_ARRAY
An empty (length zero) array of configuration objects.

Constructor Details

DefaultImmutableConfiguration

public DefaultImmutableConfiguration(Configuration config)
            throws ConfigurationException
Deep copy constructor.
Parameters:
config - the Configuration to do a deep copy of.

Method Details

equals

public boolean equals(Object other)
Compare if this configuration is equal to another.
Parameters:
other - The other configuration
Returns:
true if they are the same.

getAttribute

public String getAttribute(String name)
            throws ConfigurationException
Returns the value of the attribute specified by its name as a String.
Parameters:
name - a String value
Returns:
a String value

getAttributeNames

public String[] getAttributeNames()
Return an array of all attribute names.
Returns:
a String[] value

getChild

public Configuration getChild(String name,
                              boolean createNew)
Return the first Configuration object child of this associated with the given name.
Parameters:
name - a String value
createNew - a boolean value
Returns:
a Configuration value

getChildCount

public int getChildCount()
Return count of children.
Returns:
an int value

getChildren

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

getChildren

public Configuration[] getChildren(String name)
Return an array of Configuration objects children of this associated with the given name.
The returned array may be empty but is never null.
Parameters:
name - The name of the required children Configuration.
Returns:
a Configuration[] value

getLocation

public String getLocation()
Returns a description of location of element.
Returns:
a String value

getName

public String getName()
Returns the name of this configuration element.
Returns:
a String value

getNamespace

public String getNamespace()
            throws ConfigurationException
Returns the namespace of this configuration element
Returns:
a String value
Since:
4.1

getPrefix

protected String getPrefix()
            throws ConfigurationException
Returns the prefix of the namespace
Returns:
a String value
Since:
4.1

getValue

public String getValue()
            throws ConfigurationException
Returns the value of the configuration element as a String.
Returns:
a String value

getValue

public String getValue(String defaultValue)
Returns the value of the configuration element as a String.
Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
a String value

hashCode

public int hashCode()
Obtaine the hashcode for this configuration.
Returns:
the hashcode.