public class DefaultConfiguration
extends AbstractConfiguration
implements MutableConfiguration, Serializable
DefaultConfiguration
public DefaultConfiguration(Configuration config)
throws ConfigurationException Shallow copy constructor, suitable for craeting a writable clone of
a read-only configuration. To modify children, use getChild(),
removeChild() and addChild().
config - the Configuration to copy
DefaultConfiguration
public DefaultConfiguration(String name)
Create a new DefaultConfiguration instance.
DefaultConfiguration
public DefaultConfiguration(String name,
String location) Create a new DefaultConfiguration instance.
name - a String valuelocation - a String value
DefaultConfiguration
public DefaultConfiguration(String name,
String location,
String ns,
String prefix) Create a new DefaultConfiguration instance.
name - config node namelocation - Builder-specific locator stringns - Namespace string (typically a URI). Should not be null; use ""
if no namespace.prefix - A short string prefixed to element names, associating
elements with a longer namespace string. Should not be null; use "" if no
namespace.
addAll
public void addAll(Configuration other)
Add all the attributes, children and value
from specified configuration element to current
configuration element.
other - the Configuration element
addAllAttributes
public void addAllAttributes(Configuration other)
Add all attributes from specified configuration
element to current configuration element.
other - the Configuration element
addAllChildren
public void addAllChildren(Configuration other)
Add all child Configuration objects from specified
configuration element to current configuration element.
other - the other Configuration value
addAttribute
public String addAttribute(String name,
String value)Use setAttribute() instead
Add an attribute to this configuration element, returning its old
value or null.
name - a String valuevalue - a String value
addChild
public void addChild(Configuration configuration)
Add a child Configuration to this configuration element.
configuration - a Configuration value
appendValueData
public void appendValueData(String value)
Use setValue() instead
Append data to the value of this configuration element.
checkWriteable
protected final void checkWriteable()
throws IllegalStateException heck if this configuration is writeable.
equals
public boolean equals(Object other)
Compare if this configuration is equal to another.
other - The other configuration
true if they are the same.
getAttribute
public String getAttribute(String name)
throws ConfigurationException Returns the value of the attribute specified by its name as a
String.
getAttributeNames
public String[] getAttributeNames()
Return an array of all attribute names.
getChild
public Configuration getChild(String name,
boolean createNew) Return the first Configuration object child of this
associated with the given name.
name - a String valuecreateNew - a boolean value
getChildCount
public int getChildCount()
Return count of children.
getChildren
public Configuration[] getChildren()
Return an array of Configuration
elements containing all node children.
- 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.
name - The name of the required children Configuration.
getLocation
public String getLocation()
Returns a description of location of element.
getMutableChild
public MutableConfiguration getMutableChild(String name)
throws ConfigurationException
getMutableChild
public MutableConfiguration getMutableChild(String name,
boolean autoCreate)
throws ConfigurationException
getMutableChildren
public MutableConfiguration[] getMutableChildren()
throws ConfigurationException
getMutableChildren
public MutableConfiguration[] getMutableChildren(String name)
throws ConfigurationException
getName
public String getName()
Returns the name of this configuration element.
getNamespace
public String getNamespace()
throws ConfigurationException Returns the namespace of this configuration element
getPrefix
protected String getPrefix()
throws ConfigurationException Returns the prefix of the namespace
getValue
public String getValue()
throws ConfigurationException Returns the value of the configuration element as a String.
getValue
public String getValue(String defaultValue)
Returns the value of the configuration element as a String.
defaultValue - the default value to return if value malformed or empty
hashCode
public int hashCode()
Obtaine the hashcode for this configuration.
isReadOnly
protected final boolean isReadOnly()
Returns true iff this DefaultConfiguration has been made read-only.
makeReadOnly
public void makeReadOnly()
Make this configuration read-only.
removeChild
public void removeChild(Configuration configuration)
Remove a child Configuration to this configuration element.
configuration - a Configuration value
setAttribute
public void setAttribute(String name,
String value) Set the value of the specified attribute to the specified string.
name - name of the attribute to setvalue - a String value
setAttribute
public void setAttribute(String name,
boolean value) Set the value of the specified attribute to the specified boolean.
name - name of the attribute to setvalue - an boolean value
setAttribute
public void setAttribute(String name,
float value) Set the value of the specified attribute to the specified float.
name - name of the attribute to setvalue - an float value
setAttribute
public void setAttribute(String name,
int value) Set the value of the specified attribute to the specified int.
name - name of the attribute to setvalue - an int value
setAttribute
public void setAttribute(String name,
long value) Set the value of the specified attribute to the specified long.
name - name of the attribute to setvalue - an long value
setValue
public void setValue(String value)
Set the value of this Configuration object to the specified string.
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.
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.