Class DefaultConfiguration
- java.lang.Object
-
- org.apache.avalon.framework.configuration.AbstractConfiguration
-
- org.apache.avalon.framework.configuration.DefaultConfiguration
-
- All Implemented Interfaces:
java.io.Serializable
,Configuration
public class DefaultConfiguration extends AbstractConfiguration implements java.io.Serializable
This is the defaultConfiguration
implementation.- Version:
- CVS $Revision: 1.32 $ $Date: 2003/02/11 16:19:27 $
- Author:
- Avalon Development Team
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Configuration[]
EMPTY_ARRAY
An empty (length zero) array of configuration objects.
-
Constructor Summary
Constructors Constructor Description DefaultConfiguration(java.lang.String name)
Create a newDefaultConfiguration
instance.DefaultConfiguration(java.lang.String name, java.lang.String location)
Create a newDefaultConfiguration
instance.DefaultConfiguration(java.lang.String name, java.lang.String location, java.lang.String ns, java.lang.String prefix)
Create a newDefaultConfiguration
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAll(Configuration other)
Add all the attributes, children and value from specified configuration element to current configuration element.void
addAllAttributes(Configuration other)
Add all attributes from specified configuration element to current configuration element.void
addAllChildren(Configuration other)
Add all childConfiguration
objects from specified configuration element to current configuration element.java.lang.String
addAttribute(java.lang.String name, java.lang.String value)
Deprecated.Use setAttribute() insteadvoid
addChild(Configuration configuration)
Add a childConfiguration
to this configuration element.void
appendValueData(java.lang.String value)
Deprecated.Use setValue() insteadprotected void
checkWriteable()
heck if this configuration is writeable.java.lang.String
getAttribute(java.lang.String name)
Returns the value of the attribute specified by its name as aString
.java.lang.String[]
getAttributeNames()
Return an array of all attribute names.Configuration
getChild(java.lang.String name, boolean createNew)
Return the firstConfiguration
object child of this associated with the given name.int
getChildCount()
Return count of children.Configuration[]
getChildren()
Return an array ofConfiguration
elements containing all node children.Configuration[]
getChildren(java.lang.String name)
Return an array ofConfiguration
objects children of this associated with the given name.java.lang.String
getLocation()
Returns a description of location of element.java.lang.String
getName()
Returns the name of this configuration element.java.lang.String
getNamespace()
Returns the namespace of this configuration elementprotected java.lang.String
getPrefix()
Returns the prefix of the namespacejava.lang.String
getValue()
Returns the value of the configuration element as aString
.java.lang.String
getValue(java.lang.String defaultValue)
Returns the value of the configuration element as aString
.void
makeReadOnly()
Make this configuration read-only.void
removeChild(Configuration configuration)
Remove a childConfiguration
to this configuration element.void
setAttribute(java.lang.String name, java.lang.String value)
Set the value of the specified attribute to the specified string.void
setValue(java.lang.String value)
Set the value of thisConfiguration
object 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
-
-
-
-
Field Detail
-
EMPTY_ARRAY
protected static final Configuration[] EMPTY_ARRAY
An empty (length zero) array of configuration objects.
-
-
Constructor Detail
-
DefaultConfiguration
public DefaultConfiguration(java.lang.String name)
Create a newDefaultConfiguration
instance.- Parameters:
name
- aString
value
-
DefaultConfiguration
public DefaultConfiguration(java.lang.String name, java.lang.String location)
Create a newDefaultConfiguration
instance.- Parameters:
name
- aString
valuelocation
- aString
value
-
DefaultConfiguration
public DefaultConfiguration(java.lang.String name, java.lang.String location, java.lang.String ns, java.lang.String prefix)
Create a newDefaultConfiguration
instance.- 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 Detail
-
getName
public java.lang.String getName()
Returns the name of this configuration element.- Specified by:
getName
in interfaceConfiguration
- Returns:
- a
String
value
-
getNamespace
public java.lang.String getNamespace() throws ConfigurationException
Returns the namespace of this configuration element- Specified by:
getNamespace
in interfaceConfiguration
- Returns:
- a
String
value - Throws:
ConfigurationException
- if an error occurs- Since:
- 4.1
-
getPrefix
protected java.lang.String getPrefix() throws ConfigurationException
Returns the prefix of the namespace- Specified by:
getPrefix
in classAbstractConfiguration
- Returns:
- a
String
value - Throws:
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 interfaceConfiguration
- Returns:
- a
String
value
-
getValue
public java.lang.String getValue(java.lang.String defaultValue)
Returns the value of the configuration element as aString
.- Specified by:
getValue
in interfaceConfiguration
- Overrides:
getValue
in classAbstractConfiguration
- Parameters:
defaultValue
- the default value to return if value malformed or empty- Returns:
- a
String
value
-
getValue
public java.lang.String getValue() throws ConfigurationException
Returns the value of the configuration element as aString
.- Specified by:
getValue
in interfaceConfiguration
- Returns:
- a
String
value - Throws:
ConfigurationException
- If the value is not present.
-
getAttributeNames
public java.lang.String[] getAttributeNames()
Return an array of all attribute names.- Specified by:
getAttributeNames
in interfaceConfiguration
- Returns:
- a
String[]
value
-
getChildren
public Configuration[] getChildren()
Return an array ofConfiguration
elements containing all node children.- Specified by:
getChildren
in interfaceConfiguration
- Returns:
- The child nodes with name
-
getAttribute
public java.lang.String getAttribute(java.lang.String name) throws ConfigurationException
Returns the value of the attribute specified by its name as aString
.- Specified by:
getAttribute
in interfaceConfiguration
- Parameters:
name
- aString
value- Returns:
- a
String
value - Throws:
ConfigurationException
- If the attribute is not present.
-
getChild
public Configuration getChild(java.lang.String name, boolean createNew)
Return the firstConfiguration
object child of this associated with the given name.- Specified by:
getChild
in interfaceConfiguration
- Overrides:
getChild
in classAbstractConfiguration
- Parameters:
name
- aString
valuecreateNew
- aboolean
value- Returns:
- a
Configuration
value
-
getChildren
public Configuration[] getChildren(java.lang.String name)
Return an array ofConfiguration
objects children of this associated with the given name.
The returned array may be empty but is nevernull
.- Specified by:
getChildren
in interfaceConfiguration
- Parameters:
name
- The name of the required childrenConfiguration
.- Returns:
- a
Configuration[]
value
-
appendValueData
public void appendValueData(java.lang.String value)
Deprecated.Use setValue() insteadAppend data to the value of this configuration element.- Parameters:
value
- aString
value
-
setValue
public void setValue(java.lang.String value)
Set the value of thisConfiguration
object to the specified string.- Parameters:
value
- aString
value
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)
Set the value of the specified attribute to the specified string.- Parameters:
name
- name of the attribute to setvalue
- aString
value
-
addAttribute
public java.lang.String addAttribute(java.lang.String name, java.lang.String value)
Deprecated.Use setAttribute() insteadAdd an attribute to this configuration element, returning its old value or null.- Parameters:
name
- aString
valuevalue
- aString
value- Returns:
- a
String
value
-
addChild
public void addChild(Configuration configuration)
Add a childConfiguration
to this configuration element.- Parameters:
configuration
- aConfiguration
value
-
addAll
public void addAll(Configuration other)
Add all the attributes, children and value from specified configuration element to current configuration element.- Parameters:
other
- theConfiguration
element
-
addAllAttributes
public void addAllAttributes(Configuration other)
Add all attributes from specified configuration element to current configuration element.- Parameters:
other
- theConfiguration
element
-
addAllChildren
public void addAllChildren(Configuration other)
Add all childConfiguration
objects from specified configuration element to current configuration element.- Parameters:
other
- the otherConfiguration
value
-
removeChild
public void removeChild(Configuration configuration)
Remove a childConfiguration
to this configuration element.- Parameters:
configuration
- aConfiguration
value
-
getChildCount
public int getChildCount()
Return count of children.- Returns:
- an
int
value
-
makeReadOnly
public void makeReadOnly()
Make this configuration read-only.
-
checkWriteable
protected final void checkWriteable() throws java.lang.IllegalStateException
heck if this configuration is writeable.- Throws:
java.lang.IllegalStateException
- if this configuration s read-only
-
-