java.io.Serializable, org.apache.avalon.framework.configuration.Configuration, MutableConfigurationpublic class DefaultConfiguration extends AbstractConfiguration implements MutableConfiguration, java.io.Serializable
Configuration implementation.| Modifier and Type | Field | Description |
|---|---|---|
protected static org.apache.avalon.framework.configuration.Configuration[] |
EMPTY_ARRAY |
An empty (length zero) array of configuration objects.
|
private java.util.HashMap |
m_attributes |
|
private java.util.ArrayList |
m_children |
|
private java.lang.String |
m_location |
|
private java.lang.String |
m_name |
|
private java.lang.String |
m_namespace |
|
private java.lang.String |
m_prefix |
|
private boolean |
m_readOnly |
|
private java.lang.String |
m_value |
| Constructor | Description |
|---|---|
DefaultConfiguration(java.lang.String name) |
Create a new
DefaultConfiguration instance. |
DefaultConfiguration(java.lang.String name,
java.lang.String location) |
Create a new
DefaultConfiguration instance. |
DefaultConfiguration(java.lang.String name,
java.lang.String location,
java.lang.String ns,
java.lang.String prefix) |
Create a new
DefaultConfiguration instance. |
DefaultConfiguration(org.apache.avalon.framework.configuration.Configuration config) |
Shallow copy constructor, suitable for craeting a writable clone of
a read-only configuration.
|
DefaultConfiguration(org.apache.avalon.framework.configuration.Configuration config,
boolean deepCopy) |
Copy constructor, to create a clone of another configuration.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addAll(org.apache.avalon.framework.configuration.Configuration other) |
Add all the attributes, children and value
from specified configuration element to current
configuration element.
|
void |
addAll(org.apache.avalon.framework.configuration.Configuration other,
boolean deepCopy) |
Add all the attributes, children and value
from specified configuration element to current
configuration element.
|
void |
addAllAttributes(org.apache.avalon.framework.configuration.Configuration other) |
Add all attributes from specified configuration
element to current configuration element.
|
void |
addAllChildren(org.apache.avalon.framework.configuration.Configuration other) |
Add all child
Configuration objects from specified
configuration element to current configuration element. |
void |
addAllChildren(org.apache.avalon.framework.configuration.Configuration other,
boolean deepCopy) |
Add all child
Configuration objects from specified
configuration element to current configuration element. |
java.lang.String |
addAttribute(java.lang.String name,
java.lang.String value) |
Deprecated.
Use setAttribute() instead
|
void |
addChild(org.apache.avalon.framework.configuration.Configuration configuration) |
Add a child
Configuration to this configuration element. |
void |
appendValueData(java.lang.String value) |
Deprecated.
Use setValue() instead
|
private boolean |
check(java.lang.Object one,
java.lang.Object two) |
|
protected void |
checkWriteable() |
heck if this configuration is writeable.
|
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.
|
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. |
int |
getChildCount() |
Return count of children.
|
org.apache.avalon.framework.configuration.Configuration[] |
getChildren() |
Return an array of
Configuration
elements containing all node children. |
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. |
java.lang.String |
getLocation() |
Returns a description of location of element.
|
MutableConfiguration |
getMutableChild(java.lang.String name) |
Equivalent to
getMutableChild( name, true ) |
MutableConfiguration |
getMutableChild(java.lang.String name,
boolean autoCreate) |
Gets a child node of this configuration.
|
MutableConfiguration[] |
getMutableChildren() |
Returns an array of mutable children.
|
MutableConfiguration[] |
getMutableChildren(java.lang.String name) |
Returns an array of mutable children with the given name.
|
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.
|
protected boolean |
isReadOnly() |
Returns true iff this DefaultConfiguration has been made read-only.
|
void |
makeReadOnly() |
Make this configuration read-only.
|
void |
removeChild(org.apache.avalon.framework.configuration.Configuration configuration) |
Remove a child
Configuration to this configuration element. |
void |
setAttribute(java.lang.String name,
boolean value) |
Set the value of the specified attribute to the specified boolean.
|
void |
setAttribute(java.lang.String name,
double value) |
Set the value of the specified attribute to the specified double.
|
void |
setAttribute(java.lang.String name,
float value) |
Set the value of the specified attribute to the specified float.
|
void |
setAttribute(java.lang.String name,
int value) |
Set the value of the specified attribute to the specified int.
|
void |
setAttribute(java.lang.String name,
long value) |
Set the value of the specified attribute to the specified long.
|
void |
setAttribute(java.lang.String name,
java.lang.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(double value) |
Set the value of this
Configuration object to the specified double. |
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(java.lang.String value) |
Set the value of this
Configuration object to the specified string. |
private MutableConfiguration |
toMutable(org.apache.avalon.framework.configuration.Configuration child) |
Convenience function to convert a child to a mutable configuration.
|
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDouble, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong, toStringgetAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDouble, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLongprotected static final org.apache.avalon.framework.configuration.Configuration[] EMPTY_ARRAY
private final java.lang.String m_name
private final java.lang.String m_location
private final java.lang.String m_namespace
private final java.lang.String m_prefix
private java.util.HashMap m_attributes
private java.util.ArrayList m_children
private java.lang.String m_value
private boolean m_readOnly
public DefaultConfiguration(org.apache.avalon.framework.configuration.Configuration config,
boolean deepCopy)
throws org.apache.avalon.framework.configuration.ConfigurationException
getChild(),
removeChild() and addChild().config - the Configuration to copydeepCopy - true will cause clones of the children to be added,
false will add the original instances and is thus
faster.org.apache.avalon.framework.configuration.ConfigurationException - if an error occurs when copyingpublic DefaultConfiguration(org.apache.avalon.framework.configuration.Configuration config)
throws org.apache.avalon.framework.configuration.ConfigurationException
getChild(),
removeChild() and addChild().config - the Configuration to copyorg.apache.avalon.framework.configuration.ConfigurationException - if an error occurs when copyingpublic DefaultConfiguration(java.lang.String name)
DefaultConfiguration instance.name - a String valuepublic DefaultConfiguration(java.lang.String name,
java.lang.String location)
DefaultConfiguration instance.name - a String valuelocation - a String valuepublic DefaultConfiguration(java.lang.String name,
java.lang.String location,
java.lang.String ns,
java.lang.String prefix)
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.public java.lang.String getName()
getName in interface org.apache.avalon.framework.configuration.ConfigurationString valuepublic java.lang.String getNamespace()
throws org.apache.avalon.framework.configuration.ConfigurationException
getNamespace in interface org.apache.avalon.framework.configuration.ConfigurationString valueorg.apache.avalon.framework.configuration.ConfigurationException - if an error occursprotected java.lang.String getPrefix()
throws org.apache.avalon.framework.configuration.ConfigurationException
getPrefix in class AbstractConfigurationString valueorg.apache.avalon.framework.configuration.ConfigurationException - if prefix is not present (null).public java.lang.String getLocation()
getLocation in interface org.apache.avalon.framework.configuration.ConfigurationString valuepublic java.lang.String getValue(java.lang.String defaultValue)
String.getValue in interface org.apache.avalon.framework.configuration.ConfigurationgetValue in class AbstractConfigurationdefaultValue - the default value to return if value malformed or emptyString valuepublic java.lang.String getValue()
throws org.apache.avalon.framework.configuration.ConfigurationException
String.getValue in interface org.apache.avalon.framework.configuration.ConfigurationString valueorg.apache.avalon.framework.configuration.ConfigurationException - If the value is not present.public java.lang.String[] getAttributeNames()
getAttributeNames in interface org.apache.avalon.framework.configuration.ConfigurationString[] valuepublic org.apache.avalon.framework.configuration.Configuration[] getChildren()
Configuration
elements containing all node children.getChildren in interface org.apache.avalon.framework.configuration.Configurationpublic java.lang.String getAttribute(java.lang.String name)
throws org.apache.avalon.framework.configuration.ConfigurationException
String.getAttribute in interface org.apache.avalon.framework.configuration.Configurationname - a String valueString valueorg.apache.avalon.framework.configuration.ConfigurationException - If the attribute is not present.public org.apache.avalon.framework.configuration.Configuration getChild(java.lang.String name,
boolean createNew)
Configuration object child of this
associated with the given name.getChild in interface org.apache.avalon.framework.configuration.ConfigurationgetChild in class AbstractConfigurationname - a String valuecreateNew - a boolean valueConfiguration valuepublic org.apache.avalon.framework.configuration.Configuration[] getChildren(java.lang.String name)
Configuration objects
children of this associated with the given name.
null.getChildren in interface org.apache.avalon.framework.configuration.Configurationname - The name of the required children Configuration.Configuration[] valuepublic void appendValueData(java.lang.String value)
value - a String valuepublic void setValue(java.lang.String value)
Configuration object to the specified string.setValue in interface MutableConfigurationvalue - a String valuepublic void setValue(int value)
Configuration object to the specified int.setValue in interface MutableConfigurationvalue - a int valuepublic void setValue(long value)
Configuration object to the specified long.setValue in interface MutableConfigurationvalue - a long valuepublic void setValue(boolean value)
Configuration object to the specified boolean.setValue in interface MutableConfigurationvalue - a boolean valuepublic void setValue(float value)
Configuration object to the specified float.setValue in interface MutableConfigurationvalue - a float valuepublic void setValue(double value)
Configuration object to the specified double.setValue in interface MutableConfigurationvalue - a double valuepublic void setAttribute(java.lang.String name,
java.lang.String value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - a String valuepublic void setAttribute(java.lang.String name,
int value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - an int valuepublic void setAttribute(java.lang.String name,
long value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - an long valuepublic void setAttribute(java.lang.String name,
boolean value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - an boolean valuepublic void setAttribute(java.lang.String name,
float value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - an float valuepublic void setAttribute(java.lang.String name,
double value)
setAttribute in interface MutableConfigurationname - name of the attribute to setvalue - an double valuepublic java.lang.String addAttribute(java.lang.String name,
java.lang.String value)
name - a String valuevalue - a String valueString valuepublic void addChild(org.apache.avalon.framework.configuration.Configuration configuration)
Configuration to this configuration element.addChild in interface MutableConfigurationconfiguration - a Configuration valuepublic void addAll(org.apache.avalon.framework.configuration.Configuration other,
boolean deepCopy)
throws org.apache.avalon.framework.configuration.ConfigurationException
other - the Configuration elementdeepCopy - true will cause clones of the children to be added,
false will add the original instances and is thus
faster.
throws ConfigurationException If there are any problems cloning the
children.org.apache.avalon.framework.configuration.ConfigurationExceptionpublic void addAll(org.apache.avalon.framework.configuration.Configuration other)
addAll in interface MutableConfigurationother - the Configuration elementpublic void addAllAttributes(org.apache.avalon.framework.configuration.Configuration other)
addAllAttributes in interface MutableConfigurationother - the Configuration elementpublic void addAllChildren(org.apache.avalon.framework.configuration.Configuration other,
boolean deepCopy)
throws org.apache.avalon.framework.configuration.ConfigurationException
Configuration objects from specified
configuration element to current configuration element.deepCopy - true will cause clones of the children to be added,
false will add the original instances and is thus
faster.other - the other Configuration value
throws ConfigurationException If there are any problems cloning the
children.org.apache.avalon.framework.configuration.ConfigurationExceptionpublic void addAllChildren(org.apache.avalon.framework.configuration.Configuration other)
Configuration objects from specified
configuration element to current configuration element.addAllChildren in interface MutableConfigurationother - the other Configuration valuepublic void removeChild(org.apache.avalon.framework.configuration.Configuration configuration)
Configuration to this configuration element.removeChild in interface MutableConfigurationconfiguration - a Configuration valuepublic int getChildCount()
int valuepublic void makeReadOnly()
protected final void checkWriteable()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if this configuration s read-onlyprotected final boolean isReadOnly()
private MutableConfiguration toMutable(org.apache.avalon.framework.configuration.Configuration child) throws org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.configuration.ConfigurationExceptionpublic MutableConfiguration getMutableChild(java.lang.String name) throws org.apache.avalon.framework.configuration.ConfigurationException
MutableConfigurationgetMutableChild( name, true )getMutableChild in interface MutableConfigurationorg.apache.avalon.framework.configuration.ConfigurationExceptionpublic MutableConfiguration getMutableChild(java.lang.String name, boolean autoCreate) throws org.apache.avalon.framework.configuration.ConfigurationException
MutableConfigurationautoCreate
is true, a new mutable child is created and added to
this configuration before being returned.getMutableChild in interface MutableConfigurationname - the name of the child.autoCreate - set to true to create the child node if it doesn't exist.null if autoCreate
was false and no child by the given name existed.org.apache.avalon.framework.configuration.ConfigurationException - if an error occurrs.public MutableConfiguration[] getMutableChildren() throws org.apache.avalon.framework.configuration.ConfigurationException
MutableConfigurationgetMutableChild.getMutableChildren in interface MutableConfigurationorg.apache.avalon.framework.configuration.ConfigurationException - if an error occurrs.public MutableConfiguration[] getMutableChildren(java.lang.String name) throws org.apache.avalon.framework.configuration.ConfigurationException
MutableConfigurationgetMutableChild.getMutableChildren in interface MutableConfigurationorg.apache.avalon.framework.configuration.ConfigurationException - if an error occurrs.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - The other configurationtrue if they are the same.private boolean check(java.lang.Object one,
java.lang.Object two)
public int hashCode()
hashCode in class java.lang.Object