All Packages Class Hierarchy This Package Previous Next Index
Class w3c.xmlOnline.tree.Element
java.lang.Object
|
+----w3c.xmlOnline.tree.Node
|
+----w3c.xmlOnline.tree.Element
- public class Element
- extends Node
Class that holds an element node in the XML tree. It has a
dictionary of attributes and values, and a list of children.
The children and attributes can be other
elements, processing instructions,
comments or text nodes. By convention, all element names and
attribute names are stored in lowercase (but nothing in this
class checks or enforces that).
- Version:
- $Id: w3c.xmlOnline.tree.Element.html,v 1.7 1997/06/09 22:25:51 bbos Exp $
- Author:
- Bert Bos
-
attrs
-
-
children
-
-
name
-
-
Element(Node, String, int)
- Create a new XML Element node with the given name.
-
addAttribute(String, String)
- Add (or change) an attribute/value pair to this element.
-
addChild(Node)
- Add a child node at the end of the list of children
of this element.
-
addID(String, Element)
- Add the caller to the idTable of the root of this tree,
with the given ID as key.
-
attributes()
- Return an Enumeration of the attribute names of this element.
-
attributeValue(String)
- Return the value of the attribute with name `name', or
null if the attribute doesn't exist.
-
children()
- Return an Enumeration of the child nodes of this element.
-
data()
- Return the concatenation of all Data nodes inside the
element.
-
dumpTree(PrintStream)
- A method to write out the content of
the node in correct XML synyax.
-
findID(String)
- Return the element with a certain ID in the tree
around this element.
-
getChild(int)
- Get n'th child (n >= 1).
-
getNodeByNumber(int)
- Get the node with seqno n from the subtree below this node.
-
ids()
- Return an enumeration of all IDs in the tree.
-
lastSeqno()
- Return the highest seqno in the subtree of this node.
-
name()
- Return the name of this element, or null.
-
nrChildren()
- Return the number of children.
-
nrNodes()
- Return the number of nodes in the subtree below this node
-
renumber(int[])
- Renumber the nodes.
-
replaceBy(Node, Node)
- Replace a child node by a different node.
-
replaceBy(Node, Node[])
- Replace a child node by a list of different nodes.
-
setName(String)
- Set the name of the element
name
protected String name
attrs
protected Hashtable attrs
children
protected Vector children
Element
public Element(Node parent,
String name,
int nr)
- Create a new XML Element node with the given name.
- Parameters:
- parent - the parent of the node
- name - the name of the new element node
- nr - the sequence number of the node in the tree
- Returns:
- the new Element node
setName
public Element setName(String name)
- Set the name of the element
- Parameters:
- root - the name of the start element
- Returns:
- the new Root node
name
public String name()
- Return the name of this element, or null.
- Returns:
- the name of this element, or null
addChild
public Element addChild(Node c)
- Add a child node at the end of the list of children
of this element.
- Parameters:
- c - the node to add
- Returns:
- this
children
public Enumeration children()
- Return an Enumeration of the child nodes of this element.
- Returns:
- an Enumeration of the child nodes of this element
- See Also:
- Enumeration
nrChildren
public int nrChildren()
- Return the number of children.
- Returns:
- the number of children
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
- Overrides:
- replaceBy in class Node
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
- Overrides:
- replaceBy in class Node
addAttribute
public Element addAttribute(String name,
String value)
- Add (or change) an attribute/value pair to this element.
If the attribute name is "ID", the element is added
to the table of elements indexed on ID, that is kept
by the root.
- Parameters:
- name - the name of the attribute
- value - the value of the attribute
- Returns:
- this
attributes
public Enumeration attributes()
- Return an Enumeration of the attribute names of this element.
- Returns:
- an Enumeration of the attribute names
attributeValue
public String attributeValue(String name)
- Return the value of the attribute with name `name', or
null if the attribute doesn't exist.
- Parameters:
- name - the name of an attribute (lowercase)
- Returns:
- the value of the attribute, or null
getChild
public Node getChild(int n)
- Get n'th child (n >= 1).
If n is too large, it returns null.
- Parameters:
- n - the number of the child to return
- Returns:
- the child, or null
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
- Overrides:
- getNodeByNumber in class Node
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
- Overrides:
- nrNodes in class Node
lastSeqno
public int lastSeqno()
- Return the highest seqno in the subtree of this node.
- Overrides:
- lastSeqno in class Node
renumber
protected void renumber(int n_in_out[])
- Renumber the nodes.
- Parameters:
- n - the starting number
- Overrides:
- renumber in class Node
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
- Overrides:
- addID in class Node
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
- Overrides:
- findID in class Node
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
- Overrides:
- ids in class Node
data
public String data()
- Return the concatenation of all Data nodes inside the
element.
dumpTree
public void dumpTree(PrintStream out)
- A method to write out the content of
the node in correct XML synyax.
- Parameters:
- out - the PrintStream to write on
- Overrides:
- dumpTree in class Node
All Packages Class Hierarchy This Package Previous Next Index