Class DefaultImmutableConfiguration
- java.lang.Object
-
- org.apache.avalon.framework.configuration.AbstractConfiguration
-
- org.apache.avalon.framework.configuration.DefaultImmutableConfiguration
-
- All Implemented Interfaces:
java.io.Serializable,Configuration
public class DefaultImmutableConfiguration extends AbstractConfiguration implements java.io.Serializable
An immutable implementation of theConfigurationinterface.- Version:
- $Id: DefaultImmutableConfiguration.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Configuration[]EMPTY_ARRAYAn empty (length zero) array of configuration objects.private java.util.HashMapm_attributesprivate java.util.ArrayListm_childrenprivate java.lang.Stringm_locationprivate java.lang.Stringm_nameprivate java.lang.Stringm_namespaceprivate java.lang.Stringm_prefixprivate java.lang.Stringm_value
-
Constructor Summary
Constructors Constructor Description DefaultImmutableConfiguration(Configuration config)Deep copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)Compare if this configuration is equal to another.java.lang.StringgetAttribute(java.lang.String name)Returns the value of the attribute specified by its name as aString.java.lang.String[]getAttributeNames()Return an array of all attribute names.ConfigurationgetChild(java.lang.String name, boolean createNew)Return the firstConfigurationobject child of this associated with the given name.intgetChildCount()Return count of children.Configuration[]getChildren()Return an array ofConfigurationelements containing all node children.Configuration[]getChildren(java.lang.String name)Return an array ofConfigurationobjects children of this associated with the given name.java.lang.StringgetLocation()Returns a description of location of element.java.lang.StringgetName()Returns the name of this configuration element.java.lang.StringgetNamespace()Returns the namespace of this configuration elementprotected java.lang.StringgetPrefix()Returns the prefix of the namespacejava.lang.StringgetValue()Returns the value of the configuration element as aString.java.lang.StringgetValue(java.lang.String defaultValue)Returns the value of the configuration element as aString.inthashCode()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
-
-
-
-
Field Detail
-
EMPTY_ARRAY
protected static final Configuration[] EMPTY_ARRAY
An empty (length zero) array of configuration objects.
-
m_name
private final java.lang.String m_name
-
m_location
private final java.lang.String m_location
-
m_namespace
private final java.lang.String m_namespace
-
m_prefix
private final java.lang.String m_prefix
-
m_attributes
private final java.util.HashMap m_attributes
-
m_children
private final java.util.ArrayList m_children
-
m_value
private final java.lang.String m_value
-
-
Constructor Detail
-
DefaultImmutableConfiguration
public DefaultImmutableConfiguration(Configuration config) throws ConfigurationException
Deep copy constructor.- Parameters:
config- theConfigurationto 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:
getNamein interfaceConfiguration- Returns:
- a
Stringvalue
-
getNamespace
public java.lang.String getNamespace() throws ConfigurationExceptionReturns the namespace of this configuration element- Specified by:
getNamespacein interfaceConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- if an error occurs- Since:
- 4.1
-
getPrefix
protected java.lang.String getPrefix() throws ConfigurationExceptionReturns the prefix of the namespace- Specified by:
getPrefixin classAbstractConfiguration- Returns:
- a
Stringvalue - 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:
getLocationin interfaceConfiguration- Returns:
- a
Stringvalue
-
getValue
public java.lang.String getValue(java.lang.String defaultValue)
Returns the value of the configuration element as aString.- Specified by:
getValuein interfaceConfiguration- Overrides:
getValuein classAbstractConfiguration- Parameters:
defaultValue- the default value to return if value malformed or empty- Returns:
- a
Stringvalue
-
getValue
public java.lang.String getValue() throws ConfigurationExceptionReturns the value of the configuration element as aString.- Specified by:
getValuein interfaceConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- If the value is not present.
-
getAttributeNames
public java.lang.String[] getAttributeNames()
Return an array of all attribute names.- Specified by:
getAttributeNamesin interfaceConfiguration- Returns:
- a
String[]value
-
getChildren
public Configuration[] getChildren()
Return an array ofConfigurationelements containing all node children.- Specified by:
getChildrenin interfaceConfiguration- Returns:
- The child nodes with name
-
getAttribute
public java.lang.String getAttribute(java.lang.String name) throws ConfigurationExceptionReturns the value of the attribute specified by its name as aString.- Specified by:
getAttributein interfaceConfiguration- Parameters:
name- aStringvalue- Returns:
- a
Stringvalue - Throws:
ConfigurationException- If the attribute is not present.
-
getChild
public Configuration getChild(java.lang.String name, boolean createNew)
Return the firstConfigurationobject child of this associated with the given name.- Specified by:
getChildin interfaceConfiguration- Overrides:
getChildin classAbstractConfiguration- Parameters:
name- aStringvaluecreateNew- abooleanvalue- Returns:
- a
Configurationvalue
-
getChildren
public Configuration[] getChildren(java.lang.String name)
Return an array ofConfigurationobjects children of this associated with the given name.
The returned array may be empty but is nevernull.- Specified by:
getChildrenin interfaceConfiguration- Parameters:
name- The name of the required childrenConfiguration.- Returns:
- a
Configuration[]value
-
getChildCount
public int getChildCount()
Return count of children.- Returns:
- an
intvalue
-
equals
public boolean equals(java.lang.Object other)
Compare if this configuration is equal to another.- Overrides:
equalsin classjava.lang.Object- Parameters:
other- The other configuration- Returns:
trueif they are the same.
-
hashCode
public int hashCode()
Obtaine the hashcode for this configuration.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashcode.
-
-