Class DefaultImmutableConfiguration

  • All Implemented Interfaces:
    java.io.Serializable, org.apache.avalon.framework.configuration.Configuration

    public class DefaultImmutableConfiguration
    extends AbstractConfiguration
    implements java.io.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
    See Also:
    Serialized Form
    • Field Detail

      • EMPTY_ARRAY

        protected static final org.apache.avalon.framework.configuration.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​(org.apache.avalon.framework.configuration.Configuration config)
                                      throws org.apache.avalon.framework.configuration.ConfigurationException
        Deep copy constructor.
        Parameters:
        config - the Configuration to do a deep copy of.
        Throws:
        org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.Configuration
        Returns:
        a String value
      • getNamespace

        public java.lang.String getNamespace()
                                      throws org.apache.avalon.framework.configuration.ConfigurationException
        Returns the namespace of this configuration element
        Specified by:
        getNamespace in interface org.apache.avalon.framework.configuration.Configuration
        Returns:
        a String value
        Throws:
        org.apache.avalon.framework.configuration.ConfigurationException - if an error occurs
        Since:
        4.1
      • getPrefix

        protected java.lang.String getPrefix()
                                      throws org.apache.avalon.framework.configuration.ConfigurationException
        Returns the prefix of the namespace
        Specified by:
        getPrefix in class AbstractConfiguration
        Returns:
        a String value
        Throws:
        org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.ConfigurationException
        Returns the value of the configuration element as a String.
        Specified by:
        getValue in interface org.apache.avalon.framework.configuration.Configuration
        Returns:
        a String value
        Throws:
        org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.Configuration
        Returns:
        a String[] value
      • getChildren

        public org.apache.avalon.framework.configuration.Configuration[] getChildren()
        Return an array of Configuration elements containing all node children.
        Specified by:
        getChildren in interface org.apache.avalon.framework.configuration.Configuration
        Returns:
        The child nodes with name
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String name)
                                      throws org.apache.avalon.framework.configuration.ConfigurationException
        Returns the value of the attribute specified by its name as a String.
        Specified by:
        getAttribute in interface org.apache.avalon.framework.configuration.Configuration
        Parameters:
        name - a String value
        Returns:
        a String value
        Throws:
        org.apache.avalon.framework.configuration.ConfigurationException - If the attribute is not present.
      • getChild

        public org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.Configuration
        Overrides:
        getChild in class AbstractConfiguration
        Parameters:
        name - a String value
        createNew - a boolean value
        Returns:
        a Configuration value
      • getChildren

        public org.apache.avalon.framework.configuration.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 org.apache.avalon.framework.configuration.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.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - The other configuration
        Returns:
        true if they are the same.
      • hashCode

        public int hashCode()
        Obtaine the hashcode for this configuration.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode.