org.springframework.extensions.config.element
Class ConfigElementAdapter

java.lang.Object
  extended by org.springframework.extensions.config.element.ConfigElementAdapter
All Implemented Interfaces:
Serializable, ConfigElement
Direct Known Subclasses:
GenericConfigElement, RemoteConfigElement, ServerConfigElement, WebFrameworkConfigElement, WebStudioConfigElement

public abstract class ConfigElementAdapter
extends Object
implements ConfigElement

Adapter class for implementing ConfigElement's. Extend this class and provide the implementation specific behaviour.

Author:
gavinc
See Also:
Serialized Form

Field Summary
protected  Map<String,String> attributes
           
protected  List<ConfigElement> children
           
protected  String name
           
protected  String value
           
 
Constructor Summary
ConfigElementAdapter(String name)
          Default constructor
 
Method Summary
abstract  ConfigElement combine(ConfigElement configElement)
          Combines the given config element with this config element and returns a new instance containing the resulting combination.
 String getAttribute(String name)
          Gets the value of the attrbiute with the given name
 int getAttributeCount()
          Returns the number of attributes this config element has
 Map<String,String> getAttributes()
          Returns the list of attributes held by this config element
 ConfigElement getChild(String name)
          Returns a child config element of the given name
 int getChildCount()
          Returns the number of children this config element has
 List<ConfigElement> getChildren()
          Returns a list of children held by this ConfigElement
 List<ConfigElement> getChildren(String name)
          Returns a list of children held by this ConfigElement with the given name.
 Map<String,List<ConfigElement>> getChildrenMap()
           
 String getChildValue(String name)
          Shortcut method to return a child config element value of the given name.
 String getName()
          Returns the name of this config element
 String getValue()
          Gets the value of this config element.
 boolean hasAttribute(String name)
          Determines whether the config element has the named attribute
 boolean hasChildren()
          Determines whether this config element has any children.
 void setValue(String value)
          Sets the value of this config element
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

value

protected String value

attributes

protected Map<String,String> attributes

children

protected List<ConfigElement> children
Constructor Detail

ConfigElementAdapter

public ConfigElementAdapter(String name)
Default constructor

Parameters:
name - Name of the config element
Method Detail

getAttribute

public String getAttribute(String name)
Description copied from interface: ConfigElement
Gets the value of the attrbiute with the given name

Specified by:
getAttribute in interface ConfigElement
Parameters:
name - The name of the attrbiute to get the value for
Returns:
The value of the attrbiute or null if the attribute doesn't exist

getAttributes

public Map<String,String> getAttributes()
Description copied from interface: ConfigElement
Returns the list of attributes held by this config element

Specified by:
getAttributes in interface ConfigElement
Returns:
The list of attrbiutes

getAttributeCount

public int getAttributeCount()
Description copied from interface: ConfigElement
Returns the number of attributes this config element has

Specified by:
getAttributeCount in interface ConfigElement
Returns:
The number of attributes

getChildren

public List<ConfigElement> getChildren()
Description copied from interface: ConfigElement
Returns a list of children held by this ConfigElement

Specified by:
getChildren in interface ConfigElement
Returns:
The list of children.

getChildren

public List<ConfigElement> getChildren(String name)
Description copied from interface: ConfigElement
Returns a list of children held by this ConfigElement with the given name.

Specified by:
getChildren in interface ConfigElement
Parameters:
name - The name of the config element to retrieve
Returns:
The list of children.

getChildCount

public int getChildCount()
Description copied from interface: ConfigElement
Returns the number of children this config element has

Specified by:
getChildCount in interface ConfigElement
Returns:
The number of children

getChild

public ConfigElement getChild(String name)
Description copied from interface: ConfigElement
Returns a child config element of the given name

Specified by:
getChild in interface ConfigElement
Parameters:
name - The name of the config element to retrieve
Returns:
The ConfigElement or null if it does not exist

getChildValue

public String getChildValue(String name)
Description copied from interface: ConfigElement
Shortcut method to return a child config element value of the given name. Returns null as the value if the element does not exist.

Specified by:
getChildValue in interface ConfigElement
Parameters:
name - The name of the config element to retrieve the value from.
Returns:
The ConfigElement value or null if it does not exist

getChildrenMap

public Map<String,List<ConfigElement>> getChildrenMap()

getName

public String getName()
Description copied from interface: ConfigElement
Returns the name of this config element

Specified by:
getName in interface ConfigElement
Returns:
Name of this config element

getValue

public String getValue()
Description copied from interface: ConfigElement
Gets the value of this config element. If this config element has children then this method may return null

Specified by:
getValue in interface ConfigElement
Returns:
Value of this config element or null if there is no value

setValue

public void setValue(String value)
Sets the value of this config element

Parameters:
value - The value to set.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: ConfigElement
Determines whether the config element has the named attribute

Specified by:
hasAttribute in interface ConfigElement
Parameters:
name - Name of the attribute to check existence for
Returns:
true if it exists, false otherwise

hasChildren

public boolean hasChildren()
Description copied from interface: ConfigElement
Determines whether this config element has any children. It is more effecient to call this method rather than getChildren().size() as a collection is not created if it is not required

Specified by:
hasChildren in interface ConfigElement
Returns:
true if it has children, false otherwise

toString

public String toString()
Overrides:
toString in class Object

combine

public abstract ConfigElement combine(ConfigElement configElement)
Description copied from interface: ConfigElement
Combines the given config element with this config element and returns a new instance containing the resulting combination. The combination of the two objects MUST NOT change this instance.

Specified by:
combine in interface ConfigElement
Parameters:
configElement - The config element to combine into this one
Returns:
The combined ConfigElement


Copyright © 2009 SpringSource, Inc. All Rights Reserved.