org.apache.avalon.framework.configuration
Class DefaultImmutableConfiguration

java.lang.Object
  extended byorg.apache.avalon.framework.configuration.AbstractConfiguration
      extended byorg.apache.avalon.framework.configuration.DefaultImmutableConfiguration
All Implemented Interfaces:
Configuration, java.io.Serializable

public class DefaultImmutableConfiguration
extends AbstractConfiguration
implements java.io.Serializable

An immutable implementation of the Configuration interface.

Version:
$Id: DefaultImmutableConfiguration.java 30977 2004-07-30 08:57:54Z niclas $
Author:
Avalon Development Team
See Also:
Serialized Form

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(java.lang.Object other)
          Compare if this configuration is equal to another.
 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 array of Configuration elements containing all node children.
 Configuration[] getChildren(java.lang.String name)
          Return an array 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 getNamespace()
          Returns the namespace of this configuration element
protected  java.lang.String getPrefix()
          Returns the prefix of the namespace
 java.lang.String getValue()
          Returns the value of the configuration element as a String.
 java.lang.String getValue(java.lang.String defaultValue)
          Returns the value of the configuration element as a String.
 int hashCode()
          Obtaine the hashcode for this configuration.
 
Methods inherited from class org.apache.avalon.framework.configuration.AbstractConfiguration
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDouble, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

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

Constructor Detail

DefaultImmutableConfiguration

public DefaultImmutableConfiguration(Configuration config)
                              throws ConfigurationException
Deep copy constructor.

Parameters:
config - the Configuration to do a deep copy of.
Throws:
ConfigurationException - if an error occurs when copying
Method Detail

getName

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

Specified by:
getName in interface Configuration
Returns:
a String value

getNamespace

public java.lang.String getNamespace()
                              throws ConfigurationException
Returns the namespace of this configuration element

Specified by:
getNamespace in interface Configuration
Returns:
a String value
Throws:
ConfigurationException - if an error occurs
Since:
4.1

getPrefix

protected java.lang.String getPrefix()
                              throws ConfigurationException
Returns the prefix of the namespace

Specified by:
getPrefix in class AbstractConfiguration
Returns:
a String value
Throws:
ConfigurationException - if prefix is not present (null).
Since:
4.1

getLocation

public java.lang.String getLocation()
Returns a description of location of element.

Specified by:
getLocation in interface Configuration
Returns:
a String value

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
Overrides:
getValue in class AbstractConfiguration
Parameters:
defaultValue - the default value to return if value malformed or empty
Returns:
a String value

getValue

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

Specified by:
getValue in interface Configuration
Returns:
a String value
Throws:
ConfigurationException - If the value is not present.

getAttributeNames

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

Specified by:
getAttributeNames in interface Configuration
Returns:
a String[] value

getChildren

public Configuration[] getChildren()
Return an array of Configuration elements containing all node children.

Specified by:
getChildren in interface Configuration
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.

Specified by:
getAttribute in interface Configuration
Parameters:
name - a String value
Returns:
a String value
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.

Specified by:
getChild in interface Configuration
Overrides:
getChild in class AbstractConfiguration
Parameters:
name - a String value
createNew - a boolean value
Returns:
a Configuration value

getChildren

public Configuration[] getChildren(java.lang.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.

Specified by:
getChildren in interface Configuration
Parameters:
name - The name of the required children Configuration.
Returns:
a Configuration[] value

getChildCount

public int getChildCount()
Return count of children.

Returns:
an int value

equals

public boolean equals(java.lang.Object other)
Compare if this configuration is equal to another.

Parameters:
other - The other configuration
Returns:
true if they are the same.

hashCode

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

Returns:
the hashcode.


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.