com.codemonster.surinam.parser
Class XNode

java.lang.Object
  extended by com.codemonster.surinam.parser.XNode

public class XNode
extends Object

This is a wrapper of convenience to make it easier and more intuitive to work with any node objects that are returned. It is also possible to get the w3c Node that this object wraps. However, this object also has some additional accessors for immediate children, that do not require working with the inner nodes.


Constructor Summary
XNode(Node node)
           
 
Method Summary
 float getChildFloatValue(String tagname)
          Designed for use in terminating lists where the leaves/fields are children of list elements.
 int getChildIntValue(String tagname)
          Designed for use in terminating lists where the leaves/fields are children of list elements.
 long getChildLongValue(String tagname)
          Designed for use in terminating lists where the leaves/fields are children of list elements.
 List<XNode> getChildren()
           
 String getChildStringValue(String tagname)
          Designed for use in terminating lists where the leaves/fields are children of list elements.
 String getName()
           
 List<XNode> getNamedChildren(String tagname)
           
 Node getNode()
           
 String getValue()
           
 void setNode(Node node)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XNode

public XNode(Node node)
Method Detail

getName

public String getName()
Returns:
Returns the name of this node.

getValue

public String getValue()
Returns:
Returns the value of this element as a string.

getChildStringValue

public String getChildStringValue(String tagname)
                           throws ElementDoesNotExistException,
                                  MultipleTargetElementsException
Designed for use in terminating lists where the leaves/fields are children of list elements.

Parameters:
tagname - name of the child tag we are looking for.
Returns:
Returns the text content of the child tag.
Throws:
ElementDoesNotExistException - Thrown if the element does not exist.
MultipleTargetElementsException - There should be one and only one child with this name.

getChildIntValue

public int getChildIntValue(String tagname)
                     throws MultipleTargetElementsException,
                            ElementDoesNotExistException
Designed for use in terminating lists where the leaves/fields are children of list elements.

Parameters:
tagname - name of the child tag we are looking for.
Returns:
Returns the text content of the child tag.
Throws:
ElementDoesNotExistException - Thrown if the element does not exist.
MultipleTargetElementsException - There should be one and only one child with this name.

getChildLongValue

public long getChildLongValue(String tagname)
                       throws MultipleTargetElementsException,
                              ElementDoesNotExistException
Designed for use in terminating lists where the leaves/fields are children of list elements.

Parameters:
tagname - name of the child tag we are looking for.
Returns:
Returns the text content of the child tag.
Throws:
ElementDoesNotExistException - Thrown if the element does not exist.
MultipleTargetElementsException - There should be one and only one child with this name.

getChildFloatValue

public float getChildFloatValue(String tagname)
                         throws MultipleTargetElementsException,
                                ElementDoesNotExistException
Designed for use in terminating lists where the leaves/fields are children of list elements.

Parameters:
tagname - name of the child tag we are looking for.
Returns:
Returns the text content of the child tag.
Throws:
ElementDoesNotExistException - Thrown if the element does not exist.
MultipleTargetElementsException - There should be one and only one child with this name.

getChildren

public List<XNode> getChildren()

getNamedChildren

public List<XNode> getNamedChildren(String tagname)
Parameters:
tagname - The name of the tag we are searching for.
Returns:
Returns a List of XNode objects that have the given tag name.

getNode

public Node getNode()

setNode

public void setNode(Node node)


Copyright © 2010. All Rights Reserved.