Package gov.aps.jca.configuration
Class DefaultConfiguration
- java.lang.Object
-
- gov.aps.jca.configuration.AbstractConfiguration
-
- gov.aps.jca.configuration.DefaultConfiguration
-
- All Implemented Interfaces:
Configuration,Serializable
public class DefaultConfiguration extends AbstractConfiguration implements Serializable
This is the defaultConfigurationimplementation.- Version:
- 1.0
- Author:
- Federico Barbieri, Stefano Mazzocchi, Pierpaolo Fumagalli, Peter Donald
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Configuration[]EMPTY_ARRAYAn empty (length zero) array of configuration objects.
-
Constructor Summary
Constructors Constructor Description DefaultConfiguration(String name)DefaultConfiguration(String name, String location)Create a newDefaultConfigurationinstance.DefaultConfiguration(String name, String location, String ns, String prefix)Create a newDefaultConfigurationinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringaddAttribute(String name, String value)Deprecated.Use setAttribute() insteadvoidaddChild(Configuration configuration)Add a childConfigurationto this configuration element.voidappendValueData(String value)Deprecated.Use setValue() insteadprotected voidcheckWriteable()heck if this configuration is writeable.StringgetAttribute(String name)Returns the value of the attribute specified by its name as aString.String[]getAttributeNames()Return an array of all attribute names.ConfigurationgetChild(String name, boolean createNew)Return the firstConfigurationobject child of this associated with the given name.intgetChildCount()Return count of children.Configuration[]getChildren()Return anIteratorofConfigurationelements containing all node children.Configuration[]getChildren(String name)Return anEnumerationofConfigurationobjects children of this associated with the given name.StringgetLocation()Returns a description of location of element.StringgetName()Returns the name of this configuration element.StringgetNamespace()Returns the namespace of this configuration elementprotected StringgetPrefix()Returns the prefix of the namespaceStringgetValue()Returns the value of the configuration element as aString.StringgetValue(String defaultValue)Returns the value of the configuration element as aString.voidmakeReadOnly()Make this configuration read-only.voidremoveChild(Configuration configuration)Remove a childConfigurationto this configuration element.voidsetAttribute(String name, String value)Set the value of the specified attribute to the specified string.voidsetValue(String value)Set the value of thisConfigurationobject to the specified string.-
Methods inherited from class gov.aps.jca.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(String name)
-
DefaultConfiguration
public DefaultConfiguration(String name, String location)
Create a newDefaultConfigurationinstance.- Parameters:
name- aStringvaluelocation- aStringvalue
-
DefaultConfiguration
public DefaultConfiguration(String name, String location, String ns, String prefix)
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.
-
-
Method Detail
-
getName
public String getName()
Returns the name of this configuration element.- Specified by:
getNamein interfaceConfiguration- Returns:
- a
Stringvalue
-
getNamespace
public String getNamespace() throws ConfigurationException
Returns the namespace of this configuration element- Specified by:
getNamespacein interfaceConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- if an error occurs
-
getPrefix
protected String getPrefix() throws ConfigurationException
Returns the prefix of the namespace- Specified by:
getPrefixin classAbstractConfiguration- Returns:
- a
Stringvalue - Throws:
ConfigurationException- if prefix is not present (null).
-
getLocation
public String getLocation()
Returns a description of location of element.- Specified by:
getLocationin interfaceConfiguration- Returns:
- a
Stringvalue
-
getValue
public String getValue(String defaultValue)
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
public String getValue() throws ConfigurationException
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
public String[] getAttributeNames()
Return an array of all attribute names.- Specified by:
getAttributeNamesin interfaceConfiguration- Returns:
- a
String[]value
-
getChildren
public Configuration[] getChildren()
Return anIteratorofConfigurationelements containing all node children.- Specified by:
getChildrenin interfaceConfiguration- Returns:
- The child nodes with name
-
getAttribute
public String getAttribute(String name) throws ConfigurationException
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
public Configuration getChild(String name, boolean createNew)
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
public Configuration[] getChildren(String name)
Return anEnumerationofConfigurationobjects children of this associated with the given name.
The returnedEnumerationmay be empty.- Specified by:
getChildrenin interfaceConfiguration- Parameters:
name- The name of the required childrenConfiguration.- Returns:
- a
Configuration[]value
-
appendValueData
public void appendValueData(String value)
Deprecated.Use setValue() insteadAppend data to the value of this configuration element.- Parameters:
value- aStringvalue
-
setValue
public void setValue(String value)
Set the value of thisConfigurationobject to the specified string.- Parameters:
value- aStringvalue
-
setAttribute
public void setAttribute(String name, String value)
Set the value of the specified attribute to the specified string.- Parameters:
name- name of the attribute to setvalue- aStringvalue
-
addAttribute
public String addAttribute(String name, String value)
Deprecated.Use setAttribute() insteadAdd an attribute to this configuration element, returning its old value or null.- Parameters:
name- aStringvaluevalue- aStringvalue- Returns:
- a
Stringvalue
-
addChild
public void addChild(Configuration configuration)
Add a childConfigurationto this configuration element.- Parameters:
configuration- aConfigurationvalue
-
removeChild
public void removeChild(Configuration configuration)
Remove a childConfigurationto this configuration element.- Parameters:
configuration- aConfigurationvalue
-
getChildCount
public int getChildCount()
Return count of children.- Returns:
- an
intvalue
-
makeReadOnly
public void makeReadOnly()
Make this configuration read-only.
-
checkWriteable
protected final void checkWriteable() throws IllegalStateExceptionheck if this configuration is writeable.- Throws:
IllegalStateException- if this configuration s read-only
-
-