com.japisoft.fastparser.node
Class SimpleNode

java.lang.Object
  extended bycom.japisoft.fastparser.node.SimpleNode

public class SimpleNode
extends java.lang.Object

Simple node.

Since:
1.0
Version:
1.5
Author:
(c) 2002-2003 JAPISoft

Field Summary
static int COMMENT_NODE
           
static int DOCUMENT_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)
           
SimpleNode(java.lang.String content)
          Create a tag node
 
Method Summary
 void addChildNode(SimpleNode node)
          Insert a new node
 void addNameSpaceDeclaration(java.lang.String prefix, java.lang.String uri)
          Add a declaration for nameSpace
 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.lang.String closeDeclaration()
           
 java.util.Enumeration getAllChild()
          Get all child
 java.lang.Object getApplicationObject()
           
 java.lang.String getAttribute(java.lang.String qname)
           
 java.lang.String getAttribute(java.lang.String qname, java.lang.String defaultValue)
           
 java.lang.String getCachedXPathLocation()
           
 java.lang.String getContent()
           
 java.lang.String getDefaultNamespace()
           
 Document getDocument()
           
 java.lang.String getFirstAttributeValue()
           
 java.util.Enumeration getNameSpaceDeclaration()
           
 java.lang.String getNameSpaceDeclarationURI(java.lang.String prefix)
           
 java.util.Enumeration getNamespaceDeclared()
           
 java.lang.String getNameSpacePrefix()
           
 java.lang.String getNameSpaceURI()
           
 java.util.Enumeration getNodeByCriteria(ValidCriteria criteria, boolean deep)
          Sample of criteria : new OrCriteria( new NodeNameCriteria( "aa" ), new NodeNameCriteria( "bb" ) ) for returning 'aa' or 'bb' node.
 java.util.Enumeration getNodeByName(java.lang.String name, boolean deep)
           
 java.lang.String getNodeContent()
           
 SimpleNode getNodeForXPathLocation(java.lang.String xpath, boolean resolveAlways)
          This feature is limited to a subset of the XPath set : /tag1[ location ]/tag2...
 java.lang.String getQualifiedContent()
           
 java.lang.String getRawXML()
           
 SimpleNode getSimpleParent()
           
 int getStartingLine()
           
 int getStartingOffset()
           
 int getStoppingLine()
           
 int getStoppingOffset()
           
 int getType()
           
 java.lang.String getViewAttribute(java.lang.String name)
           
 java.lang.String getViewAttributeAt(int index)
           
 int getViewAttributeCount()
           
 java.util.Enumeration getViewAttributes()
           
 ViewableNode getViewChildAt(int i)
           
 int getViewChildCount()
           
 java.lang.String getViewContent()
           
 java.lang.String getXPathLocation()
           
 java.lang.String getXPathLocation(SimpleNode node)
           
 boolean hasAttribute(java.lang.String qname)
           
 void insertChildNode(int index, SimpleNode node)
          Insert a childnode at the index location
 boolean isClosedLeaf()
          Particular way to know the tag declaration is in the <A/> form rather than <A></A>
 boolean isComment()
           
 boolean isLeaf()
           
 boolean isNamespaceDeclared(java.lang.String prefix)
           
 boolean isRoot()
           
 boolean isTag()
           
 boolean isText()
           
 boolean isViewComment()
           
 boolean isViewLeaf()
           
 boolean isViewText()
           
 boolean matchContent(java.lang.String val)
           
 java.lang.String openDeclaration()
           
 void removeAllNameSpaceDeclaration()
          Remove all the nameSpace declaration
 void removeChildNode(SimpleNode node)
          Remove the following node
 void removeChildNodeAt(int index)
           
 void removeChildrenNodes()
          Remove all the children
 void removeNameSpaceDeclaration(java.lang.String prefix)
          Remove a nameSpace prefix declaration
 void replaceChildNode(SimpleNode oldNode, SimpleNode newNode)
          Replace this oldNode by this newOne
 void setApplicationObject(java.lang.Object obj)
          Store an application object in this node
 void setAttribute(java.lang.String qname, boolean value)
          Reset the attribute value
 void setAttribute(java.lang.String qname, double value)
          Reset the attribute value
 void setAttribute(java.lang.String qname, int value)
          Reset the attribute value
 void setAttribute(java.lang.String qname, java.lang.String value)
          Set the attribute value.
 void setClosedLeaf(boolean closedLeaf)
          Particular way to know the tag declaration is in the <A/> form rather than <A></A>
 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 setDefaultNamespace(java.lang.String namespaceURI)
          Reset the default namespace
 void setDocument(Document doc)
          Owner document for this node
 void setNameSpace(java.lang.String name, java.lang.String nameSpaceURI)
          Set the namespace
 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 setStartingLine(int line)
          Set the node line location
 void setStartingOffset(int i)
           
 void setStoppingLine(int i)
           
 void setStoppingOffset(int i)
           
 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

DOCUMENT_NODE

public static final int DOCUMENT_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(java.lang.String content)
Create a tag node


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

getStartingOffset

public int getStartingOffset()
Returns:
the current tag starting offset

getStoppingOffset

public int getStoppingOffset()
Returns:
the current tag stopping offset

setStartingOffset

public void setStartingOffset(int i)
Parameters:
i - the current tag starting offset

setStoppingOffset

public void setStoppingOffset(int i)
Parameters:
i - the current tag stopping offset

setStartingLine

public void setStartingLine(int line)
Set the node line location


getStartingLine

public int getStartingLine()
Returns:
the starting line location

getStoppingLine

public int getStoppingLine()
Returns:
the stopping line

setStoppingLine

public void setStoppingLine(int i)
Parameters:
i - reset the stopping line

addNameSpaceDeclaration

public void addNameSpaceDeclaration(java.lang.String prefix,
                                    java.lang.String uri)
Add a declaration for nameSpace

Parameters:
prefix - NameSpace prefix
uri - NameSpace URI

removeNameSpaceDeclaration

public void removeNameSpaceDeclaration(java.lang.String prefix)
Remove a nameSpace prefix declaration


removeAllNameSpaceDeclaration

public void removeAllNameSpaceDeclaration()
Remove all the nameSpace declaration


getNameSpaceDeclaration

public java.util.Enumeration getNameSpaceDeclaration()
Returns:
nameSpace prefix support

getNameSpaceDeclarationURI

public java.lang.String getNameSpaceDeclarationURI(java.lang.String prefix)
Returns:
a nameSpace declaration URI for this prefix

isNamespaceDeclared

public boolean isNamespaceDeclared(java.lang.String prefix)
Returns:
true if this prefix is delcared inside this node

getNamespaceDeclared

public java.util.Enumeration getNamespaceDeclared()
Returns:
the list of namespaces declared

setNameSpace

public void setNameSpace(java.lang.String name,
                         java.lang.String nameSpaceURI)
Set the namespace

Parameters:
name - Namespace prefix

getNameSpacePrefix

public java.lang.String getNameSpacePrefix()
Returns:
the namespace prefix

getNameSpaceURI

public java.lang.String getNameSpaceURI()
Returns:
the namespace URI

setDefaultNamespace

public void setDefaultNamespace(java.lang.String namespaceURI)
Reset the default namespace


getDefaultNamespace

public java.lang.String getDefaultNamespace()
Returns:
the default namespace

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

matchContent

public boolean matchContent(java.lang.String val)

getQualifiedContent

public java.lang.String getQualifiedContent()
Returns:
the content with a namespace prefix if needed

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


replaceChildNode

public void replaceChildNode(SimpleNode oldNode,
                             SimpleNode newNode)
Replace this oldNode by this newOne


addChildNode

public void addChildNode(SimpleNode node)
Insert a new node


removeChildrenNodes

public void removeChildrenNodes()
Remove all the children


removeChildNode

public void removeChildNode(SimpleNode node)
Remove the following node


removeChildNodeAt

public void removeChildNodeAt(int index)

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 qname,
                         java.lang.String value)
Set the attribute value. If value is null the attribute is removed

Parameters:
qname - Qualified name (namespace prefix + local name )
value - value for this attribute

setAttribute

public void setAttribute(java.lang.String qname,
                         int value)
Reset the attribute value


setAttribute

public void setAttribute(java.lang.String qname,
                         double value)
Reset the attribute value


setAttribute

public void setAttribute(java.lang.String qname,
                         boolean value)
Reset the attribute value


getAttribute

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

getFirstAttributeValue

public java.lang.String getFirstAttributeValue()
Returns:
the first attribute value

getNodeByName

public java.util.Enumeration getNodeByName(java.lang.String name,
                                           boolean deep)
Returns:
all nodes matching the following name

getNodeByCriteria

public java.util.Enumeration getNodeByCriteria(ValidCriteria criteria,
                                               boolean deep)
Sample of criteria : new OrCriteria( new NodeNameCriteria( "aa" ), new NodeNameCriteria( "bb" ) ) for returning 'aa' or 'bb' node.

Returns:
all nodes matching this criteria

getAttribute

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

hasAttribute

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

toString

public java.lang.String toString()

setNodeContent

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


getNodeContent

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

setNodeParent

public void setNodeParent(MutableNode node)
Reset the node parent


setNodeAttribute

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


addNode

public void addNode(MutableNode node)
Reset the children


getViewAttributes

public java.util.Enumeration getViewAttributes()
Returns:
the list of attributs or null

getViewAttributeAt

public java.lang.String getViewAttributeAt(int index)
Returns:
the attribute for this index

getViewAttributeCount

public int getViewAttributeCount()
Returns:
the number of attribute

getViewAttribute

public java.lang.String getViewAttribute(java.lang.String name)
Returns:
the attribute value for the name or null

getViewContent

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

isViewLeaf

public boolean isViewLeaf()
Returns:
true is the node is a leaf

getViewChildCount

public int getViewChildCount()
Returns:
the child count

getViewChildAt

public ViewableNode getViewChildAt(int i)
Returns:
a child starting from 0

isViewText

public boolean isViewText()
Returns:
true for text node

isViewComment

public boolean isViewComment()
Returns:
true for comment node

getNodeForXPathLocation

public SimpleNode getNodeForXPathLocation(java.lang.String xpath,
                                          boolean resolveAlways)
This feature is limited to a subset of the XPath set : /tag1[ location ]/tag2...

Returns:
a node for a single xpath location. 'resolveAlways' will help to return the best location even if a sub path is not available

getXPathLocation

public java.lang.String getXPathLocation()
Returns:
the XPath location for the current node

getCachedXPathLocation

public java.lang.String getCachedXPathLocation()
Returns:
the current XPath location caching the last value. This is only useful for readonly document

getXPathLocation

public java.lang.String getXPathLocation(SimpleNode node)
Returns:
the XPath location for the tied child node

getRawXML

public java.lang.String getRawXML()
Returns:
a raw text view of this XML node

openDeclaration

public java.lang.String openDeclaration()
Returns:
a string with the opening value. This is only for tag type

closeDeclaration

public java.lang.String closeDeclaration()
Returns:
a string with the closing value. This is only for tag type

setClosedLeaf

public void setClosedLeaf(boolean closedLeaf)
Particular way to know the tag declaration is in the <A/> form rather than <A></A>


isClosedLeaf

public boolean isClosedLeaf()
Particular way to know the tag declaration is in the <A/> form rather than <A></A>


setApplicationObject

public void setApplicationObject(java.lang.Object obj)
Store an application object in this node


getApplicationObject

public java.lang.Object getApplicationObject()
Returns:
the current application object


Copyright © 2006 JAPISoft. All Rights Reserved.