public class CascadingConfiguration
extends java.lang.Object
implements org.apache.avalon.framework.configuration.Configuration
Constructor and Description |
---|
CascadingConfiguration(org.apache.avalon.framework.configuration.Configuration base,
org.apache.avalon.framework.configuration.Configuration parent)
Create a CascadingConfiguration with specified parent.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAttribute(java.lang.String paramName)
Return the value of specified attribute.
|
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
Returns the value of the attribute specified by its name as a
String , or the default value if no attribute by
that name exists or is empty. |
boolean |
getAttributeAsBoolean(java.lang.String paramName)
Return the
boolean value of the specified parameter contained
in this node. |
boolean |
getAttributeAsBoolean(java.lang.String name,
boolean defaultValue)
Returns the value of the attribute specified by its name as a
boolean , or the default value if no attribute by
that name exists or is empty. |
double |
getAttributeAsDouble(java.lang.String paramName)
Return the
double value of the specified parameter contained
in this node. |
double |
getAttributeAsDouble(java.lang.String name,
double defaultValue)
Returns the value of the attribute specified by its name as a
double , or the default value if no attribute by
that name exists or is empty. |
float |
getAttributeAsFloat(java.lang.String paramName)
Return the
float value of the specified parameter contained
in this node. |
float |
getAttributeAsFloat(java.lang.String name,
float defaultValue)
Returns the value of the attribute specified by its name as a
float , or the default value if no attribute by
that name exists or is empty. |
int |
getAttributeAsInteger(java.lang.String paramName)
Return the
int value of the specified attribute contained
in this node or the parent. |
int |
getAttributeAsInteger(java.lang.String name,
int defaultValue)
Returns the value of the attribute specified by its name as a
int , or the default value if no attribute by
that name exists or is empty. |
long |
getAttributeAsLong(java.lang.String name)
Returns the value of the attribute specified by its name as a
long . |
long |
getAttributeAsLong(java.lang.String name,
long defaultValue)
Returns the value of the attribute specified by its name as a
long , or the default value if no attribute by
that name exists or is empty. |
java.lang.String[] |
getAttributeNames()
Return an array of all attribute names in both base and parent.
|
org.apache.avalon.framework.configuration.Configuration |
getChild(java.lang.String child)
Return a new
CascadingConfiguration instance encapsulating the
specified child node of the base and parent node. |
org.apache.avalon.framework.configuration.Configuration |
getChild(java.lang.String child,
boolean createNew)
Return a
Configuration instance encapsulating the specified
child node. |
org.apache.avalon.framework.configuration.Configuration[] |
getChildren()
Return an
Array of Configuration
elements containing all node children of both base and parent configurations. |
org.apache.avalon.framework.configuration.Configuration[] |
getChildren(java.lang.String name)
Return an
Array of Configuration
elements containing all node children with the specified name from
both base and parent configurations. |
java.lang.String |
getLocation()
Return a string describing location of the base Configuration.
|
java.lang.String |
getName()
Return the name of the base node.
|
java.lang.String |
getNamespace()
Returns the namespace the main Configuration node
belongs to.
|
java.lang.String |
getValue()
Return the
String value of the node. |
java.lang.String |
getValue(java.lang.String defaultValue)
Returns the value of the configuration element as a
String . |
boolean |
getValueAsBoolean()
Return the
boolean value of the node. |
boolean |
getValueAsBoolean(boolean defaultValue)
Returns the value of the configuration element as a
boolean . |
double |
getValueAsDouble()
Return the
double value of the node. |
double |
getValueAsDouble(double defaultValue)
Returns the value of the configuration element as a
double . |
float |
getValueAsFloat()
Return the
float value of the node. |
float |
getValueAsFloat(float defaultValue)
Returns the value of the configuration element as a
float . |
int |
getValueAsInteger()
Return the
int value of the node. |
int |
getValueAsInteger(int defaultValue)
Returns the value of the configuration element as an
int . |
long |
getValueAsLong()
Return the
long value of the node. |
long |
getValueAsLong(long defaultValue)
Returns the value of the configuration element as a
long . |
public CascadingConfiguration(org.apache.avalon.framework.configuration.Configuration base, org.apache.avalon.framework.configuration.Configuration parent)
base
- the base Configurationparent
- the parent Configurationpublic java.lang.String getName()
getName
in interface org.apache.avalon.framework.configuration.Configuration
Configuration
node.public java.lang.String getLocation()
getLocation
in interface org.apache.avalon.framework.configuration.Configuration
public java.lang.String getNamespace() throws org.apache.avalon.framework.configuration.ConfigurationException
getNamespace
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- may be thrown by the underlying configurationpublic org.apache.avalon.framework.configuration.Configuration getChild(java.lang.String child)
CascadingConfiguration
instance encapsulating the
specified child node of the base and parent node.getChild
in interface org.apache.avalon.framework.configuration.Configuration
child
- The name of the child node.public org.apache.avalon.framework.configuration.Configuration getChild(java.lang.String child, boolean createNew)
Configuration
instance encapsulating the specified
child node.getChild
in interface org.apache.avalon.framework.configuration.Configuration
child
- The name of the child node.createNew
- If true
, a new Configuration
will be created and returned if the specified child does not exist in either
the base or parent configuratioin. If false
, null
will be returned when the specified child doesn't exist in either the base or
the parent.public org.apache.avalon.framework.configuration.Configuration[] getChildren()
Array
of Configuration
elements containing all node children of both base and parent configurations.
The array order will reflect the order in the source config file, commencing
with the base configuration.getChildren
in interface org.apache.avalon.framework.configuration.Configuration
public org.apache.avalon.framework.configuration.Configuration[] getChildren(java.lang.String name)
Array
of Configuration
elements containing all node children with the specified name from
both base and parent configurations. The array
order will reflect the order in the source config file commencing
with the base configuration.getChildren
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the children to get.name
public java.lang.String[] getAttributeNames()
The order of attributes in this array can not be relied on. As
with XML, a Configuration
's attributes are an
unordered set. If your code relies on order, eg
conf.getAttributeNames()[0], then it is liable to break if a
different XML parser is used.
getAttributeNames
in interface org.apache.avalon.framework.configuration.Configuration
public java.lang.String getAttribute(java.lang.String paramName) throws org.apache.avalon.framework.configuration.ConfigurationException
getAttribute
in interface org.apache.avalon.framework.configuration.Configuration
paramName
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no attribute with that name exists.public int getAttributeAsInteger(java.lang.String paramName) throws org.apache.avalon.framework.configuration.ConfigurationException
int
value of the specified attribute contained
in this node or the parent.getAttributeAsInteger
in interface org.apache.avalon.framework.configuration.Configuration
paramName
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no parameter with that name exists.
or if conversion to int
fails.public long getAttributeAsLong(java.lang.String name) throws org.apache.avalon.framework.configuration.ConfigurationException
long
.getAttributeAsLong
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no parameter with that name exists.
or if conversion to long
fails.public float getAttributeAsFloat(java.lang.String paramName) throws org.apache.avalon.framework.configuration.ConfigurationException
float
value of the specified parameter contained
in this node.getAttributeAsFloat
in interface org.apache.avalon.framework.configuration.Configuration
paramName
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no parameter with that name exists.
or if conversion to float
fails.public double getAttributeAsDouble(java.lang.String paramName) throws org.apache.avalon.framework.configuration.ConfigurationException
double
value of the specified parameter contained
in this node.getAttributeAsDouble
in interface org.apache.avalon.framework.configuration.Configuration
paramName
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no parameter with that name exists.
or if conversion to float
fails.public boolean getAttributeAsBoolean(java.lang.String paramName) throws org.apache.avalon.framework.configuration.ConfigurationException
boolean
value of the specified parameter contained
in this node.getAttributeAsBoolean
in interface org.apache.avalon.framework.configuration.Configuration
paramName
- The name of the parameter you ask the value of.org.apache.avalon.framework.configuration.ConfigurationException
- If no parameter with that name exists.
or if conversion to boolean
fails.public java.lang.String getValue() throws org.apache.avalon.framework.configuration.ConfigurationException
String
value of the node.getValue
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- May be raised by underlying
base or parent configuration.public int getValueAsInteger() throws org.apache.avalon.framework.configuration.ConfigurationException
int
value of the node.getValueAsInteger
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- If conversion to int
fails.public float getValueAsFloat() throws org.apache.avalon.framework.configuration.ConfigurationException
float
value of the node.getValueAsFloat
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- If conversion to float
fails.public double getValueAsDouble() throws org.apache.avalon.framework.configuration.ConfigurationException
double
value of the node.getValueAsDouble
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- If conversion to double
fails.public boolean getValueAsBoolean() throws org.apache.avalon.framework.configuration.ConfigurationException
boolean
value of the node.getValueAsBoolean
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- If conversion to boolean
fails.public long getValueAsLong() throws org.apache.avalon.framework.configuration.ConfigurationException
long
value of the node.getValueAsLong
in interface org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.configuration.ConfigurationException
- If conversion to long
fails.public java.lang.String getValue(java.lang.String defaultValue)
String
.
If the configuration value is not set, the default value will be
used.getValue
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public int getValueAsInteger(int defaultValue)
int
.
If the configuration value is not set, the default value will be
used.getValueAsInteger
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public long getValueAsLong(long defaultValue)
long
.
If the configuration value is not set, the default value will be
used.getValueAsLong
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public float getValueAsFloat(float defaultValue)
float
.
If the configuration value is not set, the default value will be
used.getValueAsFloat
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public double getValueAsDouble(double defaultValue)
double
.
If the configuration value is not set, the default value will be
used.getValueAsDouble
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public boolean getValueAsBoolean(boolean defaultValue)
boolean
.
If the configuration value is not set, the default value will be
used.getValueAsBoolean
in interface org.apache.avalon.framework.configuration.Configuration
defaultValue
- The default value desired.Configuration
, or default
if none specified.public java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
String
, or the default value if no attribute by
that name exists or is empty.getAttribute
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.public int getAttributeAsInteger(java.lang.String name, int defaultValue)
int
, or the default value if no attribute by
that name exists or is empty.getAttributeAsInteger
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.public long getAttributeAsLong(java.lang.String name, long defaultValue)
long
, or the default value if no attribute by
that name exists or is empty.getAttributeAsLong
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.public float getAttributeAsFloat(java.lang.String name, float defaultValue)
float
, or the default value if no attribute by
that name exists or is empty.getAttributeAsFloat
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.public double getAttributeAsDouble(java.lang.String name, double defaultValue)
double
, or the default value if no attribute by
that name exists or is empty.getAttributeAsDouble
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.public boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
boolean
, or the default value if no attribute by
that name exists or is empty.getAttributeAsBoolean
in interface org.apache.avalon.framework.configuration.Configuration
name
- The name of the attribute you ask the value of.defaultValue
- The default value desired.Copyright © 1997-2003 Apache Software Foundation. All Rights Reserved.