org.apache.avalon.framework.configuration

Class DefaultImmutableConfiguration

public class DefaultImmutableConfiguration extends AbstractConfiguration implements Serializable

An immutable implementation of the Configuration interface.

Version: $Id: DefaultImmutableConfiguration.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $

Author: Avalon Development Team

Field Summary
protected static Configuration[]EMPTY_ARRAY
An empty (length zero) array of configuration objects.
HashMapm_attributes
ArrayListm_children
Stringm_location
Stringm_name
Stringm_namespace
Stringm_prefix
Stringm_value
Constructor Summary
DefaultImmutableConfiguration(Configuration config)
Deep copy constructor.
Method Summary
booleanequals(Object other)
Compare if this configuration is equal to another.
StringgetAttribute(String name)
Returns the value of the attribute specified by its name as a String.
String[]getAttributeNames()
Return an array of all attribute names.
ConfigurationgetChild(String name, boolean createNew)
Return the first Configuration object child of this associated with the given name.
intgetChildCount()
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.
StringgetLocation()
Returns a description of location of element.
StringgetName()
Returns the name of this configuration element.
StringgetNamespace()
Returns the namespace of this configuration element
protected StringgetPrefix()
Returns the prefix of the namespace
StringgetValue(String defaultValue)
Returns the value of the configuration element as a String.
StringgetValue()
Returns the value of the configuration element as a String.
inthashCode()
Obtaine the hashcode for this configuration.

Field Detail

EMPTY_ARRAY

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

m_attributes

private final HashMap m_attributes

m_children

private final ArrayList m_children

m_location

private final String m_location

m_name

private final String m_name

m_namespace

private final String m_namespace

m_prefix

private final String m_prefix

m_value

private final String m_value

Constructor Detail

DefaultImmutableConfiguration

public DefaultImmutableConfiguration(Configuration config)
Deep copy constructor.

Parameters: config the Configuration to do a deep copy of.

Throws: ConfigurationException if an error occurs when copying

Method Detail

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)
Returns the value of the attribute specified by its name as a String.

Parameters: name a String value

Returns: a String value

Throws: ConfigurationException If the attribute is not present.

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()
Returns the namespace of this configuration element

Returns: a String value

Throws: ConfigurationException if an error occurs

Since: 4.1

getPrefix

protected String getPrefix()
Returns the prefix of the namespace

Returns: a String value

Throws: ConfigurationException if prefix is not present (null).

Since: 4.1

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

getValue

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

Returns: a String value

Throws: ConfigurationException If the value is not present.

hashCode

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

Returns: the hashcode.