Class DefaultConfiguration
java.lang.Object
org.apache.avalon.framework.configuration.AbstractConfiguration
org.apache.avalon.framework.configuration.DefaultConfiguration
- All Implemented Interfaces:
Serializable,Configuration,MutableConfiguration
public class DefaultConfiguration
extends AbstractConfiguration
implements MutableConfiguration, Serializable
This is the default
Configuration implementation.- Version:
- CVS $Revision: 1.43 $ $Date: 2004/02/11 14:34:25 $
- Author:
- Avalon Development Team
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Configuration[]An empty (length zero) array of configuration objects. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultConfiguration(String name) Create a newDefaultConfigurationinstance.DefaultConfiguration(String name, String location) Create a newDefaultConfigurationinstance.DefaultConfiguration(String name, String location, String ns, String prefix) Create a newDefaultConfigurationinstance.DefaultConfiguration(Configuration config) Shallow copy constructor, suitable for craeting a writable clone of a read-only configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(Configuration other) Add all the attributes, children and value from specified configuration element to current configuration element.voidaddAllAttributes(Configuration other) Add all attributes from specified configuration element to current configuration element.voidaddAllChildren(Configuration other) Add all childConfigurationobjects from specified configuration element to current configuration element.addAttribute(String name, String value) Deprecated.Use setAttribute() insteadvoidaddChild(Configuration configuration) Add a childConfigurationto this configuration element.voidappendValueData(String value) Deprecated.Use setValue() insteadprotected final voidheck if this configuration is writeable.booleanCompare if this configuration is equal to another.getAttribute(String name) Returns the value of the attribute specified by its name as aString.String[]Return an array of all attribute names.Return the firstConfigurationobject child of this associated with the given name.intReturn count of children.Return an array ofConfigurationelements containing all node children.getChildren(String name) Return an array ofConfigurationobjects children of this associated with the given name.Returns a description of location of element.getMutableChild(String name) Equivalent togetMutableChild( name, true )getMutableChild(String name, boolean autoCreate) Gets a child node of this configuration.Returns an array of mutable children.getMutableChildren(String name) Returns an array of mutable children with the given name.getName()Returns the name of this configuration element.Returns the namespace of this configuration elementprotected StringReturns the prefix of the namespacegetValue()Returns the value of the configuration element as aString.Returns the value of the configuration element as aString.inthashCode()Obtaine the hashcode for this configuration.protected final booleanReturns true iff this DefaultConfiguration has been made read-only.voidMake this configuration read-only.voidremoveChild(Configuration configuration) Remove a childConfigurationto this configuration element.voidsetAttribute(String name, boolean value) Set the value of the specified attribute to the specified boolean.voidsetAttribute(String name, float value) Set the value of the specified attribute to the specified float.voidsetAttribute(String name, int value) Set the value of the specified attribute to the specified int.voidsetAttribute(String name, long value) Set the value of the specified attribute to the specified long.voidsetAttribute(String name, String value) Set the value of the specified attribute to the specified string.voidsetValue(boolean value) Set the value of thisConfigurationobject to the specified boolean.voidsetValue(float value) Set the value of thisConfigurationobject to the specified float.voidsetValue(int value) Set the value of thisConfigurationobject to the specified int.voidsetValue(long value) Set the value of thisConfigurationobject to the specified long.voidSet the value of thisConfigurationobject to the specified string.Methods inherited from class org.apache.avalon.framework.configuration.AbstractConfiguration
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.avalon.framework.configuration.Configuration
getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsFloat, getAttributeAsInteger, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLong, getChild, getValueAsBoolean, getValueAsBoolean, getValueAsFloat, getValueAsFloat, getValueAsInteger, getValueAsInteger, getValueAsLong, getValueAsLong
-
Field Details
-
EMPTY_ARRAY
An empty (length zero) array of configuration objects.
-
-
Constructor Details
-
DefaultConfiguration
Shallow copy constructor, suitable for craeting a writable clone of a read-only configuration. To modify children, usegetChild(),removeChild()andaddChild().- Parameters:
config- theConfigurationto copy- Throws:
ConfigurationException- if an error occurs when copying
-
DefaultConfiguration
Create a newDefaultConfigurationinstance.- Parameters:
name- aStringvalue
-
DefaultConfiguration
Create a newDefaultConfigurationinstance.- Parameters:
name- aStringvaluelocation- aStringvalue
-
DefaultConfiguration
Create a newDefaultConfigurationinstance.- Parameters:
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.- Since:
- 4.1
-
-
Method Details
-
getName
Returns the name of this configuration element.- Specified by:
getNamein interfaceConfiguration- Returns:
- a
Stringvalue
-
getNamespace
Returns the namespace of this configuration element- Specified by:
getNamespacein interfaceConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- if an error occurs- Since:
- 4.1
-
getPrefix
Returns the prefix of the namespace- Specified by:
getPrefixin classAbstractConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- if prefix is not present (null).- Since:
- 4.1
-
getLocation
Returns a description of location of element.- Specified by:
getLocationin interfaceConfiguration- Returns:
- a
Stringvalue
-
getValue
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
Returns the value of the configuration element as aString.- Specified by:
getValuein interfaceConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- If the value is not present.
-
getAttributeNames
Return an array of all attribute names.- Specified by:
getAttributeNamesin interfaceConfiguration- Returns:
- a
String[]value
-
getChildren
Return an array ofConfigurationelements containing all node children.- Specified by:
getChildrenin interfaceConfiguration- Returns:
- The child nodes with name
-
getAttribute
Returns 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
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
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
-
appendValueData
Deprecated.Use setValue() insteadAppend data to the value of this configuration element.- Parameters:
value- aStringvalue
-
setValue
Set the value of thisConfigurationobject to the specified string.- Specified by:
setValuein interfaceMutableConfiguration- Parameters:
value- aStringvalue
-
setValue
public void setValue(int value) Set the value of thisConfigurationobject to the specified int.- Specified by:
setValuein interfaceMutableConfiguration- Parameters:
value- aintvalue
-
setValue
public void setValue(long value) Set the value of thisConfigurationobject to the specified long.- Specified by:
setValuein interfaceMutableConfiguration- Parameters:
value- alongvalue
-
setValue
public void setValue(boolean value) Set the value of thisConfigurationobject to the specified boolean.- Specified by:
setValuein interfaceMutableConfiguration- Parameters:
value- abooleanvalue
-
setValue
public void setValue(float value) Set the value of thisConfigurationobject to the specified float.- Specified by:
setValuein interfaceMutableConfiguration- Parameters:
value- afloatvalue
-
setAttribute
Set the value of the specified attribute to the specified string.- Specified by:
setAttributein interfaceMutableConfiguration- Parameters:
name- name of the attribute to setvalue- aStringvalue
-
setAttribute
Set the value of the specified attribute to the specified int.- Specified by:
setAttributein interfaceMutableConfiguration- Parameters:
name- name of the attribute to setvalue- anintvalue
-
setAttribute
Set the value of the specified attribute to the specified long.- Specified by:
setAttributein interfaceMutableConfiguration- Parameters:
name- name of the attribute to setvalue- anlongvalue
-
setAttribute
Set the value of the specified attribute to the specified boolean.- Specified by:
setAttributein interfaceMutableConfiguration- Parameters:
name- name of the attribute to setvalue- anbooleanvalue
-
setAttribute
Set the value of the specified attribute to the specified float.- Specified by:
setAttributein interfaceMutableConfiguration- Parameters:
name- name of the attribute to setvalue- anfloatvalue
-
addAttribute
Deprecated.Use setAttribute() insteadAdd an attribute to this configuration element, returning its old value or null.- Parameters:
name- aStringvaluevalue- aStringvalue- Returns:
- a
Stringvalue
-
addChild
Add a childConfigurationto this configuration element.- Specified by:
addChildin interfaceMutableConfiguration- Parameters:
configuration- aConfigurationvalue
-
addAll
Add all the attributes, children and value from specified configuration element to current configuration element.- Specified by:
addAllin interfaceMutableConfiguration- Parameters:
other- theConfigurationelement
-
addAllAttributes
Add all attributes from specified configuration element to current configuration element.- Specified by:
addAllAttributesin interfaceMutableConfiguration- Parameters:
other- theConfigurationelement
-
addAllChildren
Add all childConfigurationobjects from specified configuration element to current configuration element.- Specified by:
addAllChildrenin interfaceMutableConfiguration- Parameters:
other- the otherConfigurationvalue
-
removeChild
Remove a childConfigurationto this configuration element.- Specified by:
removeChildin interfaceMutableConfiguration- Parameters:
configuration- aConfigurationvalue
-
getChildCount
public int getChildCount()Return count of children.- Returns:
- an
intvalue
-
makeReadOnly
public void makeReadOnly()Make this configuration read-only. -
checkWriteable
heck if this configuration is writeable.- Throws:
IllegalStateException- if this configuration s read-only
-
isReadOnly
protected final boolean isReadOnly()Returns true iff this DefaultConfiguration has been made read-only. -
getMutableChild
Description copied from interface:MutableConfigurationEquivalent togetMutableChild( name, true )- Specified by:
getMutableChildin interfaceMutableConfiguration- Throws:
ConfigurationException
-
getMutableChild
public MutableConfiguration getMutableChild(String name, boolean autoCreate) throws ConfigurationException Description copied from interface:MutableConfigurationGets a child node of this configuration. If a mutable child with the given name exists, it is returned. If an immutable child with the given name exists, it is converted into a mutable child and returned. In this case, the immutable child will be replaced with the mutable child in this configuration (that is, it will be as if the child node always had been mutable). If no child with the given name exists, andautoCreateistrue, a new mutable child is created and added to this configuration before being returned.- Specified by:
getMutableChildin interfaceMutableConfiguration- Parameters:
name- the name of the child.autoCreate- set to true to create the child node if it doesn't exist.- Returns:
- the child MutableConfiguration, or
nullifautoCreatewas false and no child by the given name existed. - Throws:
ConfigurationException- if an error occurrs.
-
getMutableChildren
Description copied from interface:MutableConfigurationReturns an array of mutable children. Immutable children are converted just as forgetMutableChild.- Specified by:
getMutableChildrenin interfaceMutableConfiguration- Throws:
ConfigurationException- if an error occurrs.
-
getMutableChildren
Description copied from interface:MutableConfigurationReturns an array of mutable children with the given name. Immutable children are converted just as forgetMutableChild.- Specified by:
getMutableChildrenin interfaceMutableConfiguration- Throws:
ConfigurationException- if an error occurrs.
-
equals
Compare if this configuration is equal to another. -
hashCode
public int hashCode()Obtaine the hashcode for this configuration.
-