org.compass.core.util.config
Class PlainConfigurationHelper

java.lang.Object
  extended by org.compass.core.util.config.AbstractConfigurationHelper
      extended by org.compass.core.util.config.PlainConfigurationHelper
All Implemented Interfaces:
Serializable, ConfigurationHelper

public class PlainConfigurationHelper
extends AbstractConfigurationHelper
implements ConfigurationHelper, Serializable

This is the default ConfigurationHelper implementation.

See Also:
Serialized Form

Field Summary
protected static ConfigurationHelper[] EMPTY_ARRAY
          An empty (length zero) array of configuration objects.
 
Constructor Summary
PlainConfigurationHelper(String name)
          Create a new DefaultConfiguration instance.
PlainConfigurationHelper(String name, String location)
          Create a new DefaultConfiguration instance.
PlainConfigurationHelper(String name, String location, String ns, String prefix)
          Create a new DefaultConfiguration instance.
 
Method Summary
 void addAll(ConfigurationHelper other)
          Add all the attributes, children and value from specified configuration element to current configuration element.
 void addAllAttributes(ConfigurationHelper other)
          Add all attributes from specified configuration element to current configuration element.
 void addAllChildren(ConfigurationHelper other)
          Add all child Configuration objects from specified configuration element to current configuration element.
 void addAllChildrenBefore(ConfigurationHelper other)
          Add all child Configuration objects from specified configuration element to current configuration element.
 void addChild(ConfigurationHelper configuration)
          Add a child Configuration to this configuration element.
protected  void checkWriteable()
          heck if this configuration is writeable.
 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.
 String getAttributeOrValue(String paramName)
          First tries to get the attribute based on hte parameter, and there is none, will return the value.
 ConfigurationHelper getChild(String name, boolean createNew)
          Return the first Configuration object child of this associated with the given name.
 int getChildCount()
          Return count of children.
 ConfigurationHelper[] getChildren()
          Return an array of Configuration elements containing all node children.
 ConfigurationHelper[] getChildren(String... names)
           
 ConfigurationHelper[] 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.
protected  boolean isReadOnly()
          Returns true iff this DefaultConfiguration has been made read-only.
 void makeReadOnly()
          Make this configuration read-only.
 void removeChild(ConfigurationHelper configuration)
          Remove a child Configuration to this configuration element.
 void setAttribute(String name, boolean value)
          Set the value of the specified attribute to the specified boolean.
 void setAttribute(String name, float value)
          Set the value of the specified attribute to the specified float.
 void setAttribute(String name, int value)
          Set the value of the specified attribute to the specified int.
 void setAttribute(String name, long value)
          Set the value of the specified attribute to the specified long.
 void setAttribute(String name, String value)
          Set the value of the specified attribute to the specified string.
 void setValue(boolean value)
          Set the value of this Configuration object to the specified boolean.
 void setValue(float value)
          Set the value of this Configuration object to the specified float.
 void setValue(int value)
          Set the value of this Configuration object to the specified int.
 void setValue(long value)
          Set the value of this Configuration object to the specified long.
 void setValue(String value)
          Set the value of this Configuration object to the specified string.
 
Methods inherited from class org.compass.core.util.config.AbstractConfigurationHelper
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.compass.core.util.config.ConfigurationHelper
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong
 

Field Detail

EMPTY_ARRAY

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

Constructor Detail

PlainConfigurationHelper

public PlainConfigurationHelper(String name)
Create a new DefaultConfiguration instance.


PlainConfigurationHelper

public PlainConfigurationHelper(String name,
                                String location)
Create a new DefaultConfiguration instance.


PlainConfigurationHelper

public PlainConfigurationHelper(String name,
                                String location,
                                String ns,
                                String prefix)
Create a new DefaultConfiguration instance.

Method Detail

getName

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

Specified by:
getName in interface ConfigurationHelper

getNamespace

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

Throws:
ConfigurationException

getPrefix

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

Specified by:
getPrefix in class AbstractConfigurationHelper
Returns:
A non-null String (defaults to "")
Throws:
ConfigurationException - if no prefix was defined (prefix is null.

getLocation

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

Specified by:
getLocation in interface ConfigurationHelper

getValue

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

Specified by:
getValue in interface ConfigurationHelper
Overrides:
getValue in class AbstractConfigurationHelper

getAttributeOrValue

public String getAttributeOrValue(String paramName)
Description copied from interface: ConfigurationHelper
First tries to get the attribute based on hte parameter, and there is none, will return the value.

Specified by:
getAttributeOrValue in interface ConfigurationHelper

getValue

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

Specified by:
getValue in interface ConfigurationHelper
Throws:
ConfigurationException

getAttributeNames

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

Specified by:
getAttributeNames in interface ConfigurationHelper

getChildren

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

Specified by:
getChildren in interface ConfigurationHelper

getAttribute

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

Specified by:
getAttribute in interface ConfigurationHelper
Throws:
ConfigurationException

getChild

public ConfigurationHelper getChild(String name,
                                    boolean createNew)
Return the first Configuration object child of this associated with the given name.

Specified by:
getChild in interface ConfigurationHelper
Overrides:
getChild in class AbstractConfigurationHelper

getChildren

public ConfigurationHelper[] 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.

Specified by:
getChildren in interface ConfigurationHelper

getChildren

public ConfigurationHelper[] getChildren(String... names)
Specified by:
getChildren in interface ConfigurationHelper

setValue

public void setValue(String value)
Set the value of this Configuration object to the specified string.


setValue

public void setValue(int value)
Set the value of this Configuration object to the specified int.


setValue

public void setValue(long value)
Set the value of this Configuration object to the specified long.


setValue

public void setValue(boolean value)
Set the value of this Configuration object to the specified boolean.


setValue

public void setValue(float value)
Set the value of this Configuration object to the specified float.


setAttribute

public void setAttribute(String name,
                         String value)
Set the value of the specified attribute to the specified string.


setAttribute

public void setAttribute(String name,
                         int value)
Set the value of the specified attribute to the specified int.


setAttribute

public void setAttribute(String name,
                         long value)
Set the value of the specified attribute to the specified long.


setAttribute

public void setAttribute(String name,
                         boolean value)
Set the value of the specified attribute to the specified boolean.


setAttribute

public void setAttribute(String name,
                         float value)
Set the value of the specified attribute to the specified float.


addChild

public void addChild(ConfigurationHelper configuration)
Add a child Configuration to this configuration element.


addAll

public void addAll(ConfigurationHelper other)
Add all the attributes, children and value from specified configuration element to current configuration element.


addAllAttributes

public void addAllAttributes(ConfigurationHelper other)
Add all attributes from specified configuration element to current configuration element.


addAllChildren

public void addAllChildren(ConfigurationHelper other)
Add all child Configuration objects from specified configuration element to current configuration element.


addAllChildrenBefore

public void addAllChildrenBefore(ConfigurationHelper other)
Add all child Configuration objects from specified configuration element to current configuration element.


removeChild

public void removeChild(ConfigurationHelper configuration)
Remove a child Configuration to this configuration element.


getChildCount

public int getChildCount()
Return count of children.


makeReadOnly

public void makeReadOnly()
Make this configuration read-only.

Specified by:
makeReadOnly in interface ConfigurationHelper

checkWriteable

protected final void checkWriteable()
                             throws IllegalStateException
heck if this configuration is writeable.

Throws:
IllegalStateException

isReadOnly

protected final boolean isReadOnly()
Returns true iff this DefaultConfiguration has been made read-only.


equals

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

Overrides:
equals in class Object

hashCode

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

Overrides:
hashCode in class Object


Copyright (c) 2004-2009 The Compass Project.