public class Node extends Object
This class represents a node within a parsed document.
Constructor and Description |
---|
Node(Token token)
Overloaded constructor that requires a
Token object
in the formal parameter. |
Modifier and Type | Method and Description |
---|---|
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() |
public boolean isWellFormed()
Returns true
if the node has a beginning and ending
marker.
true
if node is well-formedpublic void setWellFormed(boolean isWellFormed)
Sets a boolean flag that is true
if the node has a
beginning and ending marker.
isWellFormed
- indicates if the node is well-formedpublic Node getParent()
Returns the parent of the node or null
if the node
is a top-level/root node.
public void setParent(Node parent)
Sets the parent node.
parent
- nodes parentpublic List getChildren()
Returns a List
of child nodes.
public void addChild(Node child)
Adds a child node to the children
collection.
child
- added to this nodepublic Token getToken()
Returns an object that represents the starting and ending offsets within the document that this node represents.
public boolean isEnd()
Returns a true
value if this node is a ending marker.
true
if this is a ending nodepublic void setEnd(boolean isEnd)
Sets the flag indicating that this node is a ending marker.
isEnd
- indicates ending markerpublic Map getAttributes()
Returns a Map collection of node attributes.
public void setAttributes(Map attributes)
Sets a Map collection of Node attributes.
attributes
- of the nodepublic boolean isStart()
Returns true
if the node is a beginning marker.
true
if a beginning markerpublic void setStart(boolean isStart)
Sets a boolean flag indicating that the node is a beginning marker.
isStart
- beginning marker flagpublic String getName()
Returns the node name.
public void setName(String name)
Sets the node name.
name
- of the nodepublic String getQname()
Returns the qualified node name.
public void setQname(String qname)
Sets the qualified node name.
qname
- namespace prefix of the nodepublic String toString()
public boolean isComment()
Returns true
if the node is
a comment; otherwise; the default is false
.
true
if node is a comment or in a commentpublic 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.
isComment
- indicates node is or is in a comment blockpublic boolean isCdata()
Returns true
if the node is
a CDATA; otherwise; the default is false
.
true
if the node is or is in a CDATA blockpublic 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.
isCdata
- indicates the node is in a cdata blockpublic List getNodesByName(String name)
Finds matching nodes by name
searching thru all the children.
name
- of the target nodeCopyright © 2004-2013 Apache Software Foundation. All Rights Reserved.