All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.xmlOnline.tree.Node

java.lang.Object
   |
   +----w3c.xmlOnline.tree.Node

public class Node
extends Object
Base type for all nodes in an XML tree.

Version:
$Id: w3c.xmlOnline.tree.Node.html,v 1.7 1997/06/09 22:26:00 bbos Exp $
Author:
Bert Bos

Variable Index

 o parent
The parent in the XML tree, or null
 o seqno

Constructor Index

 o Node(Node, int)
Create a new Node with the given parent

Method Index

 o addID(String, Element)
Add the caller to the idTable of the root of this tree, with the given ID as key.
 o dumpTree(PrintStream)
A method to write out the content of the node in correct XML synyax.
 o findID(String)
Return the element with a certain ID in the tree around this element.
 o findXPTR(String, int)
Return element pointed to by a TEI xptr.
 o getNodeByNumber(int)
Get the node with seqno n from the subtree below this node.
 o ids()
Return an enumeration of all IDs in the tree.
 o lastSeqno()
Return the highest seqno in the subtree below this node
 o nrNodes()
Return the number of nodes in the subtree below this node
 o parent()
Return the parent of this node.
 o protect(String)
Encode a string with certain characters replaced by numerical character entities.
 o renumber(int[])
Renumber the nodes.
 o replaceBy(Node)
Replace the current node by the given node.
 o replaceBy(Node, Node)
Replace a child node by a different node.
 o replaceBy(Node, Node[])
Replace a child node by a list of different nodes.
 o replaceBy(Node[])
Replace the current node by the given array of nodes.
 o root()
Return the root of the tree.
 o seqno()
Return the sequence number of this node in the tree.
 o setParent(Node)
Set the parent of this node.

Variables

 o parent
 protected Node parent
The parent in the XML tree, or null

 o seqno
 protected int seqno

Constructors

 o Node
 public Node(Node parent,
             int nr)
Create a new Node with the given parent

Parameters:
parent - the parent of the node
nr - the sequence number of the node in the tree
Returns:
the new Node

Methods

 o setParent
 public Node setParent(Node node)
Set the parent of this node.

Parameters:
node - the node to use as parent
Returns:
self
 o parent
 public Node parent()
Return the parent of this node.

Returns:
the parent node, or null
 o replaceBy
 public Node replaceBy(Node nodes[])
Replace the current node by the given array of nodes. This is done by asking the parent to insert the array in its list of children, and then setting the parent of this node to null, so that it isn't a part of the tree anymore.

Parameters:
nodes - an array of nodes to replace this node in the tree
 o replaceBy
 protected Node replaceBy(Node child,
                          Node nodes[])
Replace a child node by a list of different nodes.

Parameters:
child - the child node to replace
nodes - the nodes that are to replace the child
 o replaceBy
 public Node replaceBy(Node node)
Replace the current node by the given node. This is done by asking the parent to insert the node in its list of children, and then setting the parent of this node to null, so that it isn't a part of the tree anymore.

Parameters:
nodes - an array of nodes to replace this node in the tree
 o replaceBy
 protected Node replaceBy(Node child,
                          Node node)
Replace a child node by a different node.

Parameters:
child - the child node to replace
node - the node that is to replace the child
 o seqno
 public int seqno()
Return the sequence number of this node in the tree.

Returns:
the sequence number of this node in the tree.
 o nrNodes
 public int nrNodes()
Return the number of nodes in the subtree below this node

Returns:
the number of nodes in the subtree below this node
 o lastSeqno
 public int lastSeqno()
Return the highest seqno in the subtree below this node

 o renumber
 protected void renumber(int n_in_out[])
Renumber the nodes.

Parameters:
n - the starting number
 o root
 public Node root()
Return the root of the tree. Recursively ask for the parent until there is none anymore.

Returns:
the root of the tree of this node
 o getNodeByNumber
 public Node getNodeByNumber(int n)
Get the node with seqno n from the subtree below this node.

Parameters:
n - the seqno to look for
Returns:
the node with seqno n in the subtree, or null
 o addID
 protected Node addID(String ID,
                      Element elt)
Add the caller to the idTable of the root of this tree, with the given ID as key. An element that has an attribute called "ID" will use this method to add itself to the idTable of its root element. This call percolates up the tree until it reaches a Root element.

Parameters:
ID - the ID to use as key (value of ID attribute)
elt - the element to add
Returns:
this
 o findID
 public Node findID(String ID)
Return the element with a certain ID in the tree around this element. The request is passed up the tree to the Root, which will look up the ID in its hash table.

Parameters:
ID - the ID to look for
Returns:
the element with that ID, or null
 o ids
 public Enumeration ids()
Return an enumeration of all IDs in the tree. If this Root is not the root of the tree, it will pass the request up to the real root.

Returns:
an enumeration of all IDs in the tree
 o findXPTR
 public Node findXPTR(String xptr,
                      int n)
Return element pointed to by a TEI xptr. The passed string is interpreted as a TEI xptr and the instructions in it are followed to find the element it points to. Only the first part is interpreted, the rest of the string is passed on recursively to the element addressed by the first part. The extra argument indicates which of the addressed elements (in case there is more than one) should be returned.

Parameters:
xptr - the TEI xptr
n - which of the set of addresses element is returned (n>=0)
Returns:
the first addressed element
 o dumpTree
 public void dumpTree(PrintStream out)
A method to write out the content of the node in correct XML synyax. Subclasses must overide this method.

Parameters:
out - the PrintStream to write on
 o protect
 public String protect(String s)
Encode a string with certain characters replaced by numerical character entities.

Parameters:
s - string to encode
Returns:
the encoded string

All Packages  Class Hierarchy  This Package  Previous  Next  Index