|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.dna.impl.AbstractFreezable
org.codehaus.dna.impl.DefaultConfiguration
In memory Configuration implementation.
The developer should create the DefaultConfiguration,
associate value, attributes and/or child elements configuration
and then invoke makeReadOnly()
before passing the
Configuration to the client component.
Constructor Summary | |
DefaultConfiguration(java.lang.String name,
java.lang.String location,
java.lang.String path)
Create a DefaultConfiguration instance. |
Method Summary | |
void |
addChild(Configuration configuration)
Add a child configuration element. |
protected void |
checkWriteable()
Check if the resource has been "frozen" and thus is read only. |
protected java.lang.String |
generateLocation()
Generate a location string that postfixes autogenerated marker. |
java.lang.String |
getAttribute(java.lang.String name)
Return attribute value with specified name. |
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
Return attribute value with specified name. |
boolean |
getAttributeAsBoolean(java.lang.String name)
Return attribute value with specified name as a boolean. |
boolean |
getAttributeAsBoolean(java.lang.String name,
boolean defaultValue)
Return attribute value with specified name as a boolean. |
float |
getAttributeAsFloat(java.lang.String name)
Return attribute value with specified name as afloat. |
float |
getAttributeAsFloat(java.lang.String name,
float defaultValue)
Return attribute value with specified name as a float. |
int |
getAttributeAsInteger(java.lang.String name)
Return attribute value with specified name as an integer. |
int |
getAttributeAsInteger(java.lang.String name,
int defaultValue)
Return attribute value with specified name as an integer. |
long |
getAttributeAsLong(java.lang.String name)
Return attribute value with specified name as a long. |
long |
getAttributeAsLong(java.lang.String name,
long defaultValue)
Return attribute value with specified name as a long. |
protected java.util.Map |
getAttributeMap()
Return the backing map for attributes. |
java.lang.String[] |
getAttributeNames()
Return an array of all the attribute names. |
Configuration |
getChild(java.lang.String name)
Return a child Configuration element with specified name. |
Configuration |
getChild(java.lang.String name,
boolean createChild)
Return a child Configuration element with specified name. |
protected java.util.List |
getChildList()
Return the list of child configuration objects. |
Configuration[] |
getChildren()
Return an array of all the child elements. |
Configuration[] |
getChildren(java.lang.String name)
Return an array of all the child elements with specified name. |
java.lang.String |
getLocation()
Return the location of configuration element. |
java.lang.String |
getName()
Return the name of the configuration element. |
java.lang.String |
getPath()
Return the path to the configuration element. |
java.lang.String |
getValue()
Return text value of element. |
java.lang.String |
getValue(java.lang.String defaultValue)
Return text value of element. |
boolean |
getValueAsBoolean()
Return text value of element as a boolean. |
boolean |
getValueAsBoolean(boolean defaultValue)
Return text value of element as a boolean. |
float |
getValueAsFloat()
Return text value of element as a float. |
float |
getValueAsFloat(float defaultValue)
Return text value of element as a float. |
int |
getValueAsInteger()
Return text value of element as an integer. |
int |
getValueAsInteger(int defaultValue)
Return text value of element as an integer. |
long |
getValueAsLong()
Return text value of element as a long. |
long |
getValueAsLong(long defaultValue)
Return text value of element as a long. |
protected boolean |
isReadOnly()
Return true if resource has been made read-only or frozen. |
void |
makeReadOnly()
Mark the configuration and child configurations as read only. |
void |
setAttribute(java.lang.String key,
java.lang.String value)
Set an attribute of configuration. |
void |
setValue(java.lang.String value)
Set the value of the configuration element. |
protected void |
throwMixedContentException()
Throw an IllegalStateException warning about mixed content. |
java.lang.String |
toString()
Overide toString to improve ability to debug implementation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DefaultConfiguration(java.lang.String name, java.lang.String location, java.lang.String path)
name
- the name of configuration elementlocation
- the location of configuration element in sourcepath
- the path of configuration element in documentMethod Detail |
public java.lang.String getName()
getName
in interface Configuration
public final java.lang.String getPath()
getPath
in interface Configuration
public java.lang.String getLocation()
getLocation
in interface Configuration
public Configuration[] getChildren()
getChildren
in interface Configuration
public Configuration[] getChildren(java.lang.String name)
getChildren
in interface Configuration
name
- the name of child configuration objects
public Configuration getChild(java.lang.String name)
getChild
in interface Configuration
name
- the name of child configuration object
public Configuration getChild(java.lang.String name, boolean createChild)
getChild
in interface Configuration
name
- the name of child configuration objectcreateChild
- true if child should be created if it does not exist
public java.lang.String getValue() throws ConfigurationException
getValue
in interface Configuration
ConfigurationException
- if no value in elementpublic java.lang.String getValue(java.lang.String defaultValue)
getValue
in interface Configuration
defaultValue
- the default value
public boolean getValueAsBoolean() throws ConfigurationException
getValueAsBoolean
in interface Configuration
ConfigurationException
- if no value in element
or value can not be converted to correct typepublic boolean getValueAsBoolean(boolean defaultValue)
getValueAsBoolean
in interface Configuration
defaultValue
- the default value
public int getValueAsInteger() throws ConfigurationException
getValueAsInteger
in interface Configuration
ConfigurationException
- if no value in element
or value can not be converted to correct typepublic int getValueAsInteger(int defaultValue)
getValueAsInteger
in interface Configuration
defaultValue
- the default value
public long getValueAsLong() throws ConfigurationException
getValueAsLong
in interface Configuration
ConfigurationException
- if no value in element
or value can not be converted to correct typepublic long getValueAsLong(long defaultValue)
getValueAsLong
in interface Configuration
defaultValue
- the default value
public float getValueAsFloat() throws ConfigurationException
getValueAsFloat
in interface Configuration
ConfigurationException
- if no value in element
or value can not be converted to correct typepublic float getValueAsFloat(float defaultValue)
getValueAsFloat
in interface Configuration
defaultValue
- the default value
public java.lang.String[] getAttributeNames()
getAttributeNames
in interface Configuration
public java.lang.String getAttribute(java.lang.String name) throws ConfigurationException
getAttribute
in interface Configuration
name
- the attribute name
ConfigurationException
- if no attribute with
specified namepublic java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
getAttribute
in interface Configuration
name
- the attribute namedefaultValue
- the default value
public boolean getAttributeAsBoolean(java.lang.String name) throws ConfigurationException
getAttributeAsBoolean
in interface Configuration
name
- the attribute name
ConfigurationException
- if no attribute with
specified name or attribute can not be converted
to correct typepublic boolean getAttributeAsBoolean(java.lang.String name, boolean defaultValue)
getAttributeAsBoolean
in interface Configuration
name
- the attribute namedefaultValue
- the default value
public int getAttributeAsInteger(java.lang.String name) throws ConfigurationException
getAttributeAsInteger
in interface Configuration
name
- the attribute name
ConfigurationException
- if no attribute with
specified name or attribute can not be converted
to correct typepublic int getAttributeAsInteger(java.lang.String name, int defaultValue)
getAttributeAsInteger
in interface Configuration
name
- the attribute namedefaultValue
- the default value
public long getAttributeAsLong(java.lang.String name) throws ConfigurationException
getAttributeAsLong
in interface Configuration
name
- the attribute name
ConfigurationException
- if no attribute with
specified name or attribute can not be converted
to correct typepublic long getAttributeAsLong(java.lang.String name, long defaultValue)
getAttributeAsLong
in interface Configuration
name
- the attribute namedefaultValue
- the default value
public float getAttributeAsFloat(java.lang.String name) throws ConfigurationException
getAttributeAsFloat
in interface Configuration
name
- the attribute name
ConfigurationException
- if no attribute with
specified name or attribute can not be converted
to correct typepublic float getAttributeAsFloat(java.lang.String name, float defaultValue)
getAttributeAsFloat
in interface Configuration
name
- the attribute namedefaultValue
- the default value
public void makeReadOnly()
makeReadOnly
in interface Freezable
public void setAttribute(java.lang.String key, java.lang.String value)
key
- the attribute keyvalue
- the attribute valuepublic void addChild(Configuration configuration)
configuration
- the child configuration element.public void setValue(java.lang.String value)
value
- the value of the configuration element.public java.lang.String toString()
protected final java.util.List getChildList()
protected final java.util.Map getAttributeMap()
protected final java.lang.String generateLocation()
protected final void throwMixedContentException()
protected final void checkWriteable()
java.lang.IllegalStateException
- if resource is read-onlyprotected final boolean isReadOnly()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |