net.sourceforge.jeuclid.biparser
Class BiNode

java.lang.Object
  extended by net.sourceforge.jeuclid.biparser.AbstractBiNode
      extended by net.sourceforge.jeuclid.biparser.BiNode
All Implemented Interfaces:
IBiNode

public final class BiNode
extends AbstractBiNode

this class is used to store specific information about a composite xml-node. the node can have one child, many attributes and can be invalid

Version:
$Revision: 0b66106c7ff7 $

Constructor Summary
BiNode(int co, String ns, String n, Attributes a)
          creates a new BiNode, length must be set afterwards. constructor does not create a DOM-node
 
Method Summary
 void addChild(IBiNode c)
          add a child to this node, if node has already a child, forward to child.
 Node createDOMSubtree(Document doc)
          create a DOM-tree from node and all children (recursive).
 IBiNode getChild()
          get the child of the node.
 int getLengthOfChildren()
          calculate the length of all children.
 String getNodeName()
          get the name of the node (tagname).
 BiType getType()
          get the type of node.
 void insert(BiTree biTree, int offset, int length, int totalOffset)
          insert characters to node.
 void remove(BiTree biTree, int offset, int length, int totalOffset)
          remove characters from node.
 TextPosition searchNode(Node node, int totalOffset)
          search a DOM node in this node. if nodes are equal return offset to begin of inputtext, else null
 void setChild(IBiNode c)
          set child for this node.
 String toString()
           
 String toString(int level)
          print biNode.
 
Methods inherited from class net.sourceforge.jeuclid.biparser.AbstractBiNode
addSibling, changeLengthRec, formatLength, forwardToSibling, getLength, getNode, getParent, getPrevious, getSibling, setLength, setNode, setPrevious, setSibling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BiNode

public BiNode(int co,
              String ns,
              String n,
              Attributes a)
creates a new BiNode, length must be set afterwards. constructor does not create a DOM-node

Parameters:
co - offset to child from node begin (length of open tag)
ns - DOM-info
n - DOM-info
a - DOM-info
Method Detail

getNodeName

public String getNodeName()
get the name of the node (tagname).

Returns:
nodename

addChild

public void addChild(IBiNode c)
add a child to this node, if node has already a child, forward to child.

Parameters:
c - new child for this node

getChild

public IBiNode getChild()
get the child of the node.

Returns:
child

setChild

public void setChild(IBiNode c)
set child for this node.

Parameters:
c - new child for this node

getType

public BiType getType()
get the type of node.

Returns:
NODE

insert

public void insert(BiTree biTree,
                   int offset,
                   int length,
                   int totalOffset)
            throws ReparseException,
                   NonIncrementalElementException
insert characters to node.

Parameters:
biTree - reference to BiTree to which this node contains
offset - position to insert characters
length - number of characters to insert
totalOffset - offset of node to begin of text
Throws:
ReparseException - if a reparse at upper level is needed
NonIncrementalElementException - if the subtree contains an element which cannot be incrementally updated.

remove

public void remove(BiTree biTree,
                   int offset,
                   int length,
                   int totalOffset)
            throws ReparseException,
                   NonIncrementalElementException
remove characters from node.

Parameters:
biTree - reference to BiTree to which this node contains
offset - position to remove characters
length - number of characters to remove
totalOffset - offset of node to begin of text
Throws:
ReparseException - if a reparse at upper level is needed
NonIncrementalElementException - if the subtree contains an element which cannot be incrementally updated.

getLengthOfChildren

public int getLengthOfChildren()
calculate the length of all children.

Returns:
length of children

createDOMSubtree

public Node createDOMSubtree(Document doc)
create a DOM-tree from node and all children (recursive).

Parameters:
doc - Document to create DOM-tree
Returns:
root of DOM-tree

searchNode

public TextPosition searchNode(Node node,
                               int totalOffset)
search a DOM node in this node. if nodes are equal return offset to begin of inputtext, else null

Specified by:
searchNode in interface IBiNode
Overrides:
searchNode in class AbstractBiNode
Parameters:
node - DOM node to search for
totalOffset - offset of node to begin of inputtext
Returns:
position of node in inputtext

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(int level)
print biNode.

Parameters:
level - level of recursion tree
Returns:
biNode


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.