org.apache.shale.clay.parser
Class Node

java.lang.Object
  extended by org.apache.shale.clay.parser.Node

public class Node
extends Object

This class represents a node within a parsed document.


Constructor Summary
Node(Token token)
          Overloaded constructor that requires a Token object in the formal parameter.
 
Method Summary
 void addChild(Node child)
          Adds a child node to the children collection.
 Map getAttributes()
          Returns a Map collection of node attributes.
 List getChildren()
          Returns a List of child nodes.
 String getName()
          Returns the node name.
 String getNamespaceURI(String prefix)
          Walks up the tree looking for a uri namespace matching the prefix.
 List getNodesByName(String name)
          Finds matching nodes by name searching thru all the children.
 Node getParent()
          Returns the parent of the node or null if the node is a top-level/root node.
 String getQname()
          Returns the qualified node name.
 Token getToken()
          Returns an object that represents the starting and ending offsets within the document that this node represents.
 boolean isCdata()
           Returns true if the node is a CDATA; otherwise; the default is false.
 boolean isComment()
           Returns true if the node is a comment; otherwise; the default is false.
 boolean isEnd()
          Returns a true value if this node is a ending marker.
 boolean isStart()
          Returns true if the node is a beginning marker.
 boolean isWellFormed()
          Returns true if the node has a beginning and ending marker.
 void setAttributes(Map attributes)
          Sets a Map collection of Node attributes.
 void setCdata(boolean isCdata)
          Sets a boolean value that identifies this node as being a CDATA.
 void setComment(boolean isComment)
          Sets a boolean value that identifies this node as being a comment.
 void setEnd(boolean isEnd)
          Sets the flag indicating that this node is a ending marker.
 void setName(String name)
          Sets the node name.
 void setParent(Node parent)
          Sets the parent node.
 void setQname(String qname)
          Sets the qualified node name.
 void setStart(boolean isStart)
          Sets a boolean flag indicating that the node is a beginning marker.
 void setWellFormed(boolean isWellFormed)
          Sets a boolean flag that is true if the node has a beginning and ending marker.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(Token token)

Overloaded constructor that requires a Token object in the formal parameter.

Parameters:
token - document token offset of this node
Method Detail

isWellFormed

public boolean isWellFormed()

Returns true if the node has a beginning and ending marker.

Returns:
true if node is well-formed

setWellFormed

public void setWellFormed(boolean isWellFormed)

Sets a boolean flag that is true if the node has a beginning and ending marker.

Parameters:
isWellFormed - indicates if the node is well-formed

getParent

public Node getParent()

Returns the parent of the node or null if the node is a top-level/root node.

Returns:
parent node

setParent

public void setParent(Node parent)

Sets the parent node.

Parameters:
parent - nodes parent

getChildren

public List getChildren()

Returns a List of child nodes.

Returns:
children of this node

addChild

public void addChild(Node child)

Adds a child node to the children collection.

Parameters:
child - added to this node

getToken

public Token getToken()

Returns an object that represents the starting and ending offsets within the document that this node represents.

Returns:
document offset token for this node

isEnd

public boolean isEnd()

Returns a true value if this node is a ending marker.

Returns:
true if this is a ending node

setEnd

public void setEnd(boolean isEnd)

Sets the flag indicating that this node is a ending marker.

Parameters:
isEnd - indicates ending marker

getAttributes

public Map getAttributes()

Returns a Map collection of node attributes.

Returns:
node attributes

setAttributes

public void setAttributes(Map attributes)

Sets a Map collection of Node attributes.

Parameters:
attributes - of the node

isStart

public boolean isStart()

Returns true if the node is a beginning marker.

Returns:
true if a beginning marker

setStart

public void setStart(boolean isStart)

Sets a boolean flag indicating that the node is a beginning marker.

Parameters:
isStart - beginning marker flag

getName

public String getName()

Returns the node name.

Returns:
name of the ndoe

setName

public void setName(String name)

Sets the node name.

Parameters:
name - of the node

getQname

public String getQname()

Returns the qualified node name.

Returns:
the namespace prefix of the node

setQname

public void setQname(String qname)

Sets the qualified node name.

Parameters:
qname - namespace prefix of the node

toString

public String toString()
Overrides:
toString in class Object
Returns:
Describes the objects state

isComment

public boolean isComment()

Returns true if the node is a comment; otherwise; the default is false.

.

Returns:
true if node is a comment or in a comment

setComment

public void setComment(boolean isComment)

Sets a boolean value that identifies this node as being a comment. This could be a starting, ending or within the body.

Parameters:
isComment - indicates node is or is in a comment block

isCdata

public boolean isCdata()

Returns true if the node is a CDATA; otherwise; the default is false.

.

Returns:
true if the node is or is in a CDATA block

setCdata

public void setCdata(boolean isCdata)

Sets a boolean value that identifies this node as being a CDATA. This could be a starting, ending or within the body.

Parameters:
isCdata - indicates the node is in a cdata block

getNodesByName

public List getNodesByName(String name)

Finds matching nodes by name searching thru all the children.

Parameters:
name - of the target node
Returns:
list of nodes found by name

getNamespaceURI

public String getNamespaceURI(String prefix)

Walks up the tree looking for a uri namespace matching the prefix. A null prefix will search for the default uri namespace.

Parameters:
prefix - node qname namespace prefix
Returns:
url matching the namespace prefix


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.