org.cdlib.xtf.util
Class EasyNode

Object
  extended by EasyNode

public class EasyNode
extends Object

Provides an easy-to-use wrapper around a Saxon NodeInfo.

Author:
Martin Haye

Field Summary
private  Vector attrNames
          Attribute names for this node
private  Vector attrValues
          Attribute values for this node
private  Vector children
          Child elements for this node
private  NodeInfo wrapped
          The node we are wrapping
 
Constructor Summary
EasyNode(NodeInfo toWrap)
          Wrap a NodeInfo
 
Method Summary
 String attrName(int index)
          Get a specific numbered attribute's name
 String attrValue(int index)
          Get a specific numbered attribute's value
 String attrValue(String name)
          Get a named attribute's value, or null if no such name found.
 EasyNode child(int index)
          Get a specific numbered child of this node
 EasyNode child(String name)
          Get the first child node with the specified name, case insensitive.
private  void getAttrs()
          Iterate the attributes and fill the 'attrNames' and 'attrValues' vectors.
private  void getChildren()
          Iterate the children and fill the 'children' vector.
 NodeInfo getWrappedNode()
          Get the actual node we're wrapping
 boolean hasAttr(String name)
          Check if this node has the given attribute
 boolean isElement()
          Checks if this is an element node
 boolean isText()
          Checks if this is a text node
 String name()
          Get the name of this node
 int nAttrs()
          Get the number of attributes this node has
 int nChildren()
          Get a count of the number of children this node has
 EasyNode parent()
          Get the parent of this node (if any)
 String toString()
          Get the string value of this node
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wrapped

private NodeInfo wrapped
The node we are wrapping


attrNames

private Vector attrNames
Attribute names for this node


attrValues

private Vector attrValues
Attribute values for this node


children

private Vector children
Child elements for this node

Constructor Detail

EasyNode

public EasyNode(NodeInfo toWrap)
Wrap a NodeInfo

Method Detail

getAttrs

private void getAttrs()
Iterate the attributes and fill the 'attrNames' and 'attrValues' vectors. This is a memo function and only has to do actual work once.


getChildren

private void getChildren()
Iterate the children and fill the 'children' vector. This is a memo function and only has to do actual work once.


nAttrs

public int nAttrs()
Get the number of attributes this node has


attrName

public String attrName(int index)
Get a specific numbered attribute's name


attrValue

public String attrValue(int index)
Get a specific numbered attribute's value


hasAttr

public boolean hasAttr(String name)
Check if this node has the given attribute


attrValue

public String attrValue(String name)
Get a named attribute's value, or null if no such name found. The name matching is performed case-insensitive.


nChildren

public int nChildren()
Get a count of the number of children this node has


child

public EasyNode child(int index)
Get a specific numbered child of this node


child

public EasyNode child(String name)
Get the first child node with the specified name, case insensitive. If no such child is found, returns null.


parent

public EasyNode parent()
Get the parent of this node (if any)


name

public String name()
Get the name of this node


isElement

public boolean isElement()
Checks if this is an element node


isText

public boolean isText()
Checks if this is a text node


toString

public String toString()
Get the string value of this node

Overrides:
toString in class Object

getWrappedNode

public NodeInfo getWrappedNode()
Get the actual node we're wrapping