org.spicefactory.cinnamon.config.shared
Class ElementWrapper

java.lang.Object
  extended by org.spicefactory.cinnamon.config.shared.ElementWrapper

public abstract class ElementWrapper
extends Object

Wrapper for XML elements hiding the XML DOM API in use. Since Cinnamons builtin XML configuration parser uses XOM while Spring uses the W3C DOM API, this wrapper hides the API so that the two common parser classes contained in this package can share the same logic for both configuration modes. Implements only the logic needed for reading XML attributes and iterating over child nodes.

Author:
Jens Halm

Constructor Summary
ElementWrapper()
           
 
Method Summary
abstract  String getAttribute(String name)
          Returns the value for the attribute with the given name.
 String getAttribute(String name, String defaultValue)
          Returns the value vor the attribute with the given name.
abstract  Iterator<ElementWrapper> getChildren(String name)
          Returns an Iterator for all child elements with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementWrapper

public ElementWrapper()
Method Detail

getAttribute

public abstract String getAttribute(String name)
Returns the value for the attribute with the given name.

Parameters:
name - the name of the attribute
Returns:
the value of the attribute or null if no such attribute exists

getAttribute

public String getAttribute(String name,
                           String defaultValue)
Returns the value vor the attribute with the given name. If the attribute does not exist, the given default value will be returned instead.

Parameters:
name - the name of the attribute
defaultValue - the default value to use if the attribute does not exist
Returns:
the value of the attribute or the given default value if no such attribute exists

getChildren

public abstract Iterator<ElementWrapper> getChildren(String name)
Returns an Iterator for all child elements with the given name.

Parameters:
name - the name of the child elements to include in the Iterator
Returns:
an Iterator for all child elements with the given name