electric.xml
Class Parent

java.lang.Object
  extended byelectric.xml.Node
      extended byelectric.xml.Child
          extended byelectric.xml.Parent
All Implemented Interfaces:
java.lang.Cloneable, IDOMConstants, IXMLConstants, org.w3c.dom.Node, java.io.Serializable
Direct Known Subclasses:
DocType, Document, Element, Fragment

public abstract class Parent
extends Child

Parent is the abstract root of all nodes that can have children, and includes methods for adding and accessing child nodes.

Author:
webMethods
See Also:
Serialized Form

Field Summary
protected  NodeList children
           
 
Fields inherited from class electric.xml.Child
parent
 
Fields inherited from class electric.xml.Node
list, next, prev
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface electric.xml.IXMLConstants
ATTLIST_START, ATTLIST_STOP, CDATA, CDATA_START, CDATA_STOP, CLOSE_TAG, COLON, COMMENT_START, COMMENT_STOP, DOCTYPE_START, DOCTYPE_STOP, ELEMENTDECL_START, ELEMENTDECL_STOP, ENCODING, ENTITYDECL_START, ENTITYDECL_STOP, ID, ID_CASE, INSTRUCTION_START, INSTRUCTION_STOP, NEGATIVE_INFINITY, NOT_A_NUMBER, NOTATIONDECL_START, NOTATIONDECL_STOP, NULL, OPEN_TAG, POSITIVE_INFINITY, PUBLIC, SPECIALS, STANDALONE, SUBSTITUTES, SYSTEM, UNDEFINED, VERSION, XML, XML_NAMESPACE, XMLDECL_START, XMLDECL_STOP, XMLNS, XMLNS_NAMESPACE
 
Fields inherited from interface electric.xml.IDOMConstants
CDATA_SECTION_NAME, COMMENT_NAME, CORE, DOCUMENT_FRAGMENT_NAME, DOCUMENT_NAME, HIERARCHY_REQUEST_ERR, TEXT_NAME
 
Constructor Summary
Parent()
          Construct a Parent with no children.
Parent(Parent parent)
          Construct a copy of the specified Parent.
 
Method Summary
 Child addChild(Child child)
          Add the specified child to my list of children and return the child.
 void addComment(java.lang.String text)
          Add a Comment node with the specified text.
 Element addElement()
          Add a new Element with no name.
 Element addElement(Element element)
          Add the specified Element.
 Element addElement(java.lang.String name)
          Add a new Element with the specified name.
 Element addElement(java.lang.String prefix, java.lang.String name)
          Add a new Element with the specified namespace prefix name.
protected  void addNamespacePrefixes(java.lang.String namespace, java.util.Vector prefixes, java.util.Vector matches)
          Add all the prefixes that map to a particular namespace value in my context to the specified vector.
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 org.w3c.dom.NodeList getChildNodes()
          Return a NodeList that contains all children of this node.
 Children getChildren()
          Return an enumeration over my children.
 Element getElement(IXPath xpath)
          Return my first Element node with the specified xpath, or null if I have none.
 Element getElement(java.lang.String name)
          Return my first Element node with the specified name, or null if I have none.
 Element getElement(java.lang.String namespace, java.lang.String name)
          Return my first Element node with the specified namespace and name, or null if I have none.
 Element getElementAt(int index)
          Return the Element node at the specified index, using 1 as the base index for Xpath compatibility.
 Elements getElements()
          Return an enumeration of my child Elements.
 Elements getElements(IXPath xpath)
          Return an enumeration over all my Elements with the specified xpath.
 Elements getElements(java.lang.String name)
          Return an enumeration over all my Elements with the specified name.
 Elements getElements(java.lang.String namespace, java.lang.String name)
          Return an enumeration over all my Elements with the specified namespace and name.
 Element getElementWithId(java.lang.String value)
          Return the element whose "id" attribute is equal to the specified value, or null if none exists.
 org.w3c.dom.Node getFirstChild()
          Return the first child of this node.
 Element getFirstElement()
          Return the first Element, or null if there is none.
 org.w3c.dom.Node getLastChild()
          Return the last child of this node.
 java.lang.String getNamespace(java.lang.String prefix)
          Return the value of the namespace with the specified prefix, or null if there is none.
 java.lang.String getNamespacePrefix(java.lang.String namespace)
          Return a prefix that maps to a particular namespace value, searching from the current element up through its parents.
 boolean hasChildNodes()
          Returns whether this node has any children.
 boolean hasChildren()
          Return true if I have one or more children.
 boolean hasElement(java.lang.String name)
          Return true if I have an Element with the specified name.
 boolean hasElements()
          Return true if I have one or more child Elements.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Inserts the node newChild before the existing child node refChild.
 Child insertChild(Child child)
          Insert the specified child to my list of children and return the child.
 void insertComment(java.lang.String text)
          Insert a Comment node with the specified text.
 Element insertElement()
          Insert a new Element with no name.
 Element insertElement(Element element)
          Insert the specified Element.
 Element insertElement(java.lang.String name)
          Insert a new Element with the specified name.
 Element insertElement(java.lang.String prefix, java.lang.String name)
          Insert a new Element with the specified namespace prefix name.
protected  Element needElement(java.lang.String name)
           
protected  Element needElement(java.lang.String namespace, java.lang.String name)
           
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 void removeChildren()
          Remove all of my children.
 Element removeElement(IXPath xpath)
          Remove and return the first element with the specified xpath, or return null if none was found.
 Element removeElement(java.lang.String name)
          Remove and return the first element with the specified name, or return null if none was found.
 Element removeElement(java.lang.String namespace, java.lang.String name)
          Remove and return the first element with the specified namespace and name, or return null if none was found.
 Element removeElementAt(int index)
          Remove and return the Element node at the specified index, using 1 as the base index for Xpath compatibility.
 void removeElements()
          Remove all the elements.
 Elements removeElements(IXPath xpath)
          Remove and return an enumeration over the elements with the specified xpath.
 Elements removeElements(java.lang.String name)
          Remove and return an enumeration over the elements with the specified name.
 Elements removeElements(java.lang.String namespace, java.lang.String name)
          Remove and return an enumeration over the elements with the specified namespace and name.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 Element setElement(java.lang.String name)
          Add a new Element with the specified name, replacing an existing one if present.
 Element setElement(java.lang.String prefix, java.lang.String name)
          Add a new Element with the specified namespace prefix name, replacing an existing one if present.
 Element setElementAt(int index, Element element)
          Set the element node at the specified index, using 1 as the base index for Xpath compatibility, and return the previous value.
 int size()
           
 
Methods inherited from class electric.xml.Child
clone, cloneNode, getByteArray, getByteArray, getByteArray, getBytes, getBytes, getBytes, getDocument, getNextSiblingChild, getOwnerDocument, getParent, getParentNode, getPreviousSiblingChild, getRoot, replaceWith, setNextSiblingChild, setParent, setPreviousSiblingChild, toString, toString, write, write, write
 
Methods inherited from class electric.xml.Node
getAttributes, getLocalName, getNamespaceURI, getNextSibling, getNextSiblingNode, getNode, getNode, getNodeName, getNodes, getNodeType, getNodeValue, getPrefix, getPreviousSibling, getPreviousSiblingNode, hasAttributes, isSupported, normalize, read, remove, setNextSiblingNode, setNodeValue, setPrefix, setPreviousSiblingNode, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected NodeList children
Constructor Detail

Parent

public Parent()
Construct a Parent with no children.


Parent

public Parent(Parent parent)
Construct a copy of the specified Parent.

Parameters:
parent - The parent to copy.
Method Detail

hasChildren

public boolean hasChildren()
Return true if I have one or more children.


getChildren

public Children getChildren()
Return an enumeration over my children.


removeChildren

public void removeChildren()
Remove all of my children.


addChild

public Child addChild(Child child)
Add the specified child to my list of children and return the child.

Parameters:
child - The child.

insertChild

public Child insertChild(Child child)
Insert the specified child to my list of children and return the child.

Parameters:
child - The child.

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Return the value of the namespace with the specified prefix, or null if there is none. This operation searches up the element hierarchy starting at this element.

Parameters:
prefix - The prefix.

addNamespacePrefixes

protected void addNamespacePrefixes(java.lang.String namespace,
                                    java.util.Vector prefixes,
                                    java.util.Vector matches)
Add all the prefixes that map to a particular namespace value in my context to the specified vector.

Parameters:
namespace - The namespace to match
prefixes - All the prefixes so far.
matches - All the prefixes that matched.

getNamespacePrefix

public java.lang.String getNamespacePrefix(java.lang.String namespace)
Return a prefix that maps to a particular namespace value, searching from the current element up through its parents. Return null if none is found.

Parameters:
namespace - The namespace to match.

addComment

public void addComment(java.lang.String text)
Add a Comment node with the specified text.

Parameters:
text - The text.

insertComment

public void insertComment(java.lang.String text)
Insert a Comment node with the specified text.

Parameters:
text - The text.

hasElements

public boolean hasElements()
Return true if I have one or more child Elements.


getElements

public Elements getElements()
Return an enumeration of my child Elements.


getElement

public Element getElement(java.lang.String name)
Return my first Element node with the specified name, or null if I have none.

Parameters:
name - The name.

getElement

public Element getElement(java.lang.String namespace,
                          java.lang.String name)
Return my first Element node with the specified namespace and name, or null if I have none.

Parameters:
namespace - The namespace.
name - The name.

getElement

public Element getElement(IXPath xpath)
Return my first Element node with the specified xpath, or null if I have none.

Parameters:
xpath - The XPath.

hasElement

public boolean hasElement(java.lang.String name)
Return true if I have an Element with the specified name.

Parameters:
name - The name.

getElementAt

public Element getElementAt(int index)
                     throws java.lang.IndexOutOfBoundsException
Return the Element node at the specified index, using 1 as the base index for Xpath compatibility.

Throws:
java.lang.IndexOutOfBoundsException - If the index was illegal.

getFirstElement

public Element getFirstElement()
Return the first Element, or null if there is none.


setElementAt

public Element setElementAt(int index,
                            Element element)
                     throws java.lang.IndexOutOfBoundsException
Set the element node at the specified index, using 1 as the base index for Xpath compatibility, and return the previous value.

Parameters:
index - The index.
element - The element.
Throws:
java.lang.IndexOutOfBoundsException - If the index was illegal.

setElement

public Element setElement(java.lang.String name)
Add a new Element with the specified name, replacing an existing one if present.

Parameters:
name - The name of the Element to add.
Returns:
The new element.

setElement

public Element setElement(java.lang.String prefix,
                          java.lang.String name)
Add a new Element with the specified namespace prefix name, replacing an existing one if present.

Parameters:
prefix - The namespace prefix.
name - The name of the Element to add.
Returns:
The new element.

removeElementAt

public Element removeElementAt(int index)
Remove and return the Element node at the specified index, using 1 as the base index for Xpath compatibility.

Parameters:
index - The index.
Throws:
java.lang.IndexOutOfBoundsException - If the index was illegal.

getElements

public Elements getElements(java.lang.String name)
Return an enumeration over all my Elements with the specified name.

Parameters:
name - The name.

getElements

public Elements getElements(java.lang.String namespace,
                            java.lang.String name)
Return an enumeration over all my Elements with the specified namespace and name.

Parameters:
namespace - The namespace.
name - The name.

getElements

public Elements getElements(IXPath xpath)
Return an enumeration over all my Elements with the specified xpath.

Parameters:
xpath - The XPath.

addElement

public Element addElement(Element element)
Add the specified Element.

Parameters:
element - The Element.
Returns:
The new element.

addElement

public Element addElement()
Add a new Element with no name.

Returns:
The new element.

addElement

public Element addElement(java.lang.String name)
Add a new Element with the specified name.

Parameters:
name - The name of the Element to add.
Returns:
The new element.

addElement

public Element addElement(java.lang.String prefix,
                          java.lang.String name)
Add a new Element with the specified namespace prefix name.

Parameters:
prefix - The namespace prefix.
name - The name of the Element to add.
Returns:
The new element.

insertElement

public Element insertElement(Element element)
Insert the specified Element.

Parameters:
element - The Element.
Returns:
The new element.

insertElement

public Element insertElement()
Insert a new Element with no name.

Returns:
The new element.

insertElement

public Element insertElement(java.lang.String name)
Insert a new Element with the specified name.

Parameters:
name - The name of the Element to add.
Returns:
The new element.

insertElement

public Element insertElement(java.lang.String prefix,
                             java.lang.String name)
Insert a new Element with the specified namespace prefix name.

Parameters:
prefix - The namespace prefix.
name - The name of the Element to add.
Returns:
The new element.

removeElements

public void removeElements()
Remove all the elements.


removeElement

public Element removeElement(java.lang.String name)
Remove and return the first element with the specified name, or return null if none was found.

Parameters:
name - The name.

removeElement

public Element removeElement(java.lang.String namespace,
                             java.lang.String name)
Remove and return the first element with the specified namespace and name, or return null if none was found.

Parameters:
namespace - The namespace.
name - The name.

removeElement

public Element removeElement(IXPath xpath)
Remove and return the first element with the specified xpath, or return null if none was found.

Parameters:
xpath - The XPath.

removeElements

public Elements removeElements(java.lang.String name)
Remove and return an enumeration over the elements with the specified name.

Parameters:
name - The name.

removeElements

public Elements removeElements(java.lang.String namespace,
                               java.lang.String name)
Remove and return an enumeration over the elements with the specified namespace and name.

Parameters:
namespace - The namespace.
name - The name.

removeElements

public Elements removeElements(IXPath xpath)
Remove and return an enumeration over the elements with the specified xpath.

Parameters:
xpath - The XPath.

needElement

protected Element needElement(java.lang.String name)
                       throws java.lang.NumberFormatException
Parameters:
name - The name.
Throws:
java.lang.NumberFormatException

needElement

protected Element needElement(java.lang.String namespace,
                              java.lang.String name)
                       throws java.lang.NumberFormatException
Parameters:
namespace - The namespace.
name - The name.
Throws:
java.lang.NumberFormatException

getElementWithId

public Element getElementWithId(java.lang.String value)
Return the element whose "id" attribute is equal to the specified value, or null if none exists.

Parameters:
value -

size

public int size()
Overrides:
size in class Node

hasChildNodes

public boolean hasChildNodes()
Returns whether this node has any children.

Specified by:
hasChildNodes in interface org.w3c.dom.Node
Overrides:
hasChildNodes in class Node

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Return a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.

Specified by:
getChildNodes in interface org.w3c.dom.Node
Overrides:
getChildNodes in class Node

getFirstChild

public org.w3c.dom.Node getFirstChild()
Return the first child of this node. If there is no such node, this returns null.

Specified by:
getFirstChild in interface org.w3c.dom.Node
Overrides:
getFirstChild in class Node

getLastChild

public org.w3c.dom.Node getLastChild()
Return the last child of this node. If there is no such node, this returns null.

Specified by:
getLastChild in interface org.w3c.dom.Node
Overrides:
getLastChild in class Node

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.

Specified by:
appendChild in interface org.w3c.dom.Node
Overrides:
appendChild in class Node
Parameters:
newChild - The node to add.If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface org.w3c.dom.Node
Overrides:
removeChild in class Node
Parameters:
oldChild - The node being removed.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

Specified by:
insertBefore in interface org.w3c.dom.Node
Overrides:
insertBefore in class Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.

Specified by:
replaceChild in interface org.w3c.dom.Node
Overrides:
replaceChild in class Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.


copyright© 2001-2004 by webMethods All Rights Reserved.