com.japisoft.fastparser.node
Class SimpleNode

java.lang.Object
  |
  +--com.japisoft.fastparser.node.SimpleNode
All Implemented Interfaces:
MutableNode, ViewableNode

public class SimpleNode
extends java.lang.Object
implements MutableNode, ViewableNode

Simple node.

Since:
1.0
Author:
(c) 2002 JAPISoft

Field Summary
static int COMMENT_NODE
           
static int TAG_NODE
           
static int TEXT_NODE
           
 
Constructor Summary
SimpleNode(int type, java.lang.String content)
           
SimpleNode(SimpleNode parent, int type, java.lang.String content)
           
 
Method Summary
 void addChildNode(SimpleNode node)
          Insert a new node
 void addNode(MutableNode node)
          Reset the children
 SimpleNode childAt(int index)
           
 int childCount()
           
 int childNodeIndex(SimpleNode node)
           
 SimpleNode clone(boolean deep)
          Clone the current node, include subchild if deep is true
 java.util.Enumeration getAllChild()
          Get all child
 java.lang.String getAttribute(java.lang.String name)
           
 java.lang.String getContent()
           
 Document getDocument()
           
 java.lang.String getNodeContent()
           
 SimpleNode getSimpleParent()
           
 int getType()
           
 java.lang.String getViewAttribute(java.lang.String name)
           
 java.util.Enumeration getViewAttributes()
           
 ViewableNode getViewChildAt(int i)
           
 int getViewChildCount()
           
 java.lang.String getViewContent()
           
 boolean hasAttribute(java.lang.String name)
           
 void insertChildNode(int index, SimpleNode node)
          Insert a childnode at the index location
 boolean isComment()
           
 boolean isLeaf()
           
 boolean isRoot()
           
 boolean isTag()
           
 boolean isText()
           
 boolean isViewComment()
           
 boolean isViewLeaf()
           
 boolean isViewText()
           
 void removeChildNode(SimpleNode node)
          Remove the following node
 void setAttribute(java.lang.String name, java.lang.String value)
          Set the attribute value.
 void setContent(java.lang.String content)
          Update the node content, for tag this is the tag name, for text this is the content, for comment this is the content
 void setDocument(Document doc)
          Owner document for this node
 void setNodeAttribute(java.lang.String name, java.lang.String value)
          Reset the node attribute
 void setNodeContent(java.lang.String content)
          Reset the node content
 void setNodeParent(MutableNode node)
          Reset the node parent
 void setSimpleParent(SimpleNode node)
          reset the parent node
 void setType(int type)
          Update the node type, this is TEXT_NODE, TAG_NODE or COMMENT_NODE
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXT_NODE

public static final int TEXT_NODE
See Also:
Constant Field Values

TAG_NODE

public static final int TAG_NODE
See Also:
Constant Field Values

COMMENT_NODE

public static final int COMMENT_NODE
See Also:
Constant Field Values
Constructor Detail

SimpleNode

public SimpleNode(int type,
                  java.lang.String content)
Parameters:
type - Node type : TEXT_NODE, TAG_NODE or COMMENT_NODE
content - the tag content

SimpleNode

public SimpleNode(SimpleNode parent,
                  int type,
                  java.lang.String content)
Parameters:
type - Node type : TEXT_NODE, TAG_NODE or COMMENT_NODE
content - the tag content
Method Detail

setDocument

public void setDocument(Document doc)
Owner document for this node


getDocument

public Document getDocument()
Returns:
the owner document

clone

public SimpleNode clone(boolean deep)
Clone the current node, include subchild if deep is true


setSimpleParent

public void setSimpleParent(SimpleNode node)
reset the parent node


getSimpleParent

public SimpleNode getSimpleParent()
Returns:
the parent node or null for the root node

isRoot

public boolean isRoot()
Returns:
true for the root node

setContent

public void setContent(java.lang.String content)
Update the node content, for tag this is the tag name, for text this is the content, for comment this is the content


getContent

public java.lang.String getContent()
Returns:
the node content

setType

public void setType(int type)
Update the node type, this is TEXT_NODE, TAG_NODE or COMMENT_NODE


getType

public int getType()
Returns:
the node type TEXT_NODE, TAG_NODE or COMMENT_NODE

isText

public boolean isText()
Returns:
true for text node

isTag

public boolean isTag()
Returns:
true for tag node

isComment

public boolean isComment()
Returns:
true for comment node

insertChildNode

public void insertChildNode(int index,
                            SimpleNode node)
Insert a childnode at the index location


addChildNode

public void addChildNode(SimpleNode node)
Insert a new node


removeChildNode

public void removeChildNode(SimpleNode node)
Remove the following node


childNodeIndex

public int childNodeIndex(SimpleNode node)
Returns:
the child node index. -1 for unknown child

childCount

public int childCount()
Returns:
the children count

getAllChild

public java.util.Enumeration getAllChild()
Get all child


childAt

public SimpleNode childAt(int index)
Returns:
the children at the index position starting from 0

isLeaf

public boolean isLeaf()
Returns:
true for leaf node

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Set the attribute value. If value is null the attribute is removed


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns:
an attribute value. null is returned for unknown attribute name

hasAttribute

public boolean hasAttribute(java.lang.String name)
Returns:
true is the name attribute exists

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setNodeContent

public void setNodeContent(java.lang.String content)
Reset the node content

Specified by:
setNodeContent in interface MutableNode

getNodeContent

public java.lang.String getNodeContent()
Specified by:
getNodeContent in interface MutableNode
Returns:
the node content

setNodeParent

public void setNodeParent(MutableNode node)
Reset the node parent

Specified by:
setNodeParent in interface MutableNode

setNodeAttribute

public void setNodeAttribute(java.lang.String name,
                             java.lang.String value)
Reset the node attribute

Specified by:
setNodeAttribute in interface MutableNode

addNode

public void addNode(MutableNode node)
Reset the children

Specified by:
addNode in interface MutableNode

getViewAttributes

public java.util.Enumeration getViewAttributes()
Specified by:
getViewAttributes in interface ViewableNode
Returns:
the list of attributs or null

getViewAttribute

public java.lang.String getViewAttribute(java.lang.String name)
Specified by:
getViewAttribute in interface ViewableNode
Returns:
the attribute value for the name or null

getViewContent

public java.lang.String getViewContent()
Specified by:
getViewContent in interface ViewableNode
Returns:
the content of the node

isViewLeaf

public boolean isViewLeaf()
Specified by:
isViewLeaf in interface ViewableNode
Returns:
true is the node is a leaf

getViewChildCount

public int getViewChildCount()
Specified by:
getViewChildCount in interface ViewableNode
Returns:
the child count

getViewChildAt

public ViewableNode getViewChildAt(int i)
Specified by:
getViewChildAt in interface ViewableNode
Returns:
a child starting from 0

isViewText

public boolean isViewText()
Specified by:
isViewText in interface ViewableNode
Returns:
true for text node

isViewComment

public boolean isViewComment()
Specified by:
isViewComment in interface ViewableNode
Returns:
true for comment node