org.apache.xerces.util

Class DOMUtil

public class DOMUtil extends Object

Some useful utility methods. This class was modified in Xerces2 with a view to abstracting as much as possible away from the representation of the underlying parsed structure (i.e., the DOM). This was done so that, if Xerces ever adopts an in-memory representation more efficient than the DOM (such as a DTM), we should easily be able to convert our schema parsing to utilize it.

Version: $Id: DOMUtil.java,v 1.11 2005/05/30 04:17:12 mrglavas Exp $

Constructor Summary
protected DOMUtil()
This class cannot be instantiated.
Method Summary
static voidcopyInto(Node src, Node dest)
Copies the source tree into the specified place in a destination tree.
static AttrgetAttr(Element elem, String name)
static AttrgetAttrNS(Element elem, String nsUri, String localName)
static Attr[]getAttrs(Element elem)
static StringgetAttrValue(Element elem, String name)
static StringgetAttrValueNS(Element elem, String nsUri, String localName)
static StringgetChildText(Node node)
Returns the concatenated child text of the specified node.
static DocumentgetDocument(Node node)
static ElementgetFirstChildElement(Node parent)
Finds and returns the first child element node.
static ElementgetFirstChildElement(Node parent, String elemName)
Finds and returns the first child node with the given name.
static ElementgetFirstChildElement(Node parent, String[] elemNames)
Finds and returns the first child node with the given name.
static ElementgetFirstChildElement(Node parent, String elemName, String attrName, String attrValue)
Finds and returns the first child node with the given name and attribute name, value pair.
static ElementgetFirstChildElementNS(Node parent, String uri, String localpart)
Finds and returns the first child node with the given qualified name.
static ElementgetFirstChildElementNS(Node parent, String[][] elemNames)
Finds and returns the first child node with the given qualified name.
static ElementgetFirstVisibleChildElement(Node parent)
Finds and returns the first visible child element node.
static ElementgetFirstVisibleChildElement(Node parent, Hashtable hiddenNodes)
Finds and returns the first visible child element node.
static ElementgetLastChildElement(Node parent)
Finds and returns the last child element node.
static ElementgetLastChildElement(Node parent, String elemName)
Finds and returns the last child node with the given name.
static ElementgetLastChildElement(Node parent, String[] elemNames)
Finds and returns the last child node with the given name.
static ElementgetLastChildElement(Node parent, String elemName, String attrName, String attrValue)
Finds and returns the last child node with the given name and attribute name, value pair.
static ElementgetLastChildElementNS(Node parent, String uri, String localpart)
Finds and returns the last child node with the given qualified name.
static ElementgetLastChildElementNS(Node parent, String[][] elemNames)
Finds and returns the last child node with the given qualified name.
static ElementgetLastVisibleChildElement(Node parent)
Finds and returns the last visible child element node.
static ElementgetLastVisibleChildElement(Node parent, Hashtable hiddenNodes)
Finds and returns the last visible child element node.
static StringgetLocalName(Node node)
returns local name of this element if not null, otherwise returns the name of the node
static StringgetName(Node node)
static StringgetNamespaceURI(Node node)
static ElementgetNextSiblingElement(Node node)
Finds and returns the next sibling element node.
static ElementgetNextSiblingElement(Node node, String elemName)
Finds and returns the next sibling node with the given name.
static ElementgetNextSiblingElement(Node node, String[] elemNames)
Finds and returns the next sibling node with the given name.
static ElementgetNextSiblingElement(Node node, String elemName, String attrName, String attrValue)
Finds and returns the next sibling node with the given name and attribute name, value pair.
static ElementgetNextSiblingElementNS(Node node, String uri, String localpart)
Finds and returns the next sibling node with the given qualified name.
static ElementgetNextSiblingElementNS(Node node, String[][] elemNames)
Finds and returns the next sibling node with the given qualified name.
static ElementgetNextVisibleSiblingElement(Node node)
static ElementgetNextVisibleSiblingElement(Node node, Hashtable hiddenNodes)
static ElementgetParent(Element elem)
static StringgetPrefix(Node node)
static ElementgetRoot(Document doc)
static StringgetSyntheticAnnotation(Node node)
static StringgetValue(Attr attribute)
static booleanisHidden(Node node)
static booleanisHidden(Node node, Hashtable hiddenNodes)
static voidsetHidden(Node node)
static voidsetHidden(Node node, Hashtable hiddenNodes)
static voidsetVisible(Node node)
static voidsetVisible(Node node, Hashtable hiddenNodes)

Constructor Detail

DOMUtil

protected DOMUtil()
This class cannot be instantiated.

Method Detail

copyInto

public static void copyInto(Node src, Node dest)
Copies the source tree into the specified place in a destination tree. The source node and its children are appended as children of the destination node.

Note: This is an iterative implementation.

getAttr

public static Attr getAttr(Element elem, String name)

getAttrNS

public static Attr getAttrNS(Element elem, String nsUri, String localName)

getAttrs

public static Attr[] getAttrs(Element elem)

getAttrValue

public static String getAttrValue(Element elem, String name)

getAttrValueNS

public static String getAttrValueNS(Element elem, String nsUri, String localName)

getChildText

public static String getChildText(Node node)
Returns the concatenated child text of the specified node. This method only looks at the immediate children of type Node.TEXT_NODE or the children of any child node that is of type Node.CDATA_SECTION_NODE for the concatenation.

Parameters: node The node to look at.

getDocument

public static Document getDocument(Node node)

getFirstChildElement

public static Element getFirstChildElement(Node parent)
Finds and returns the first child element node.

getFirstChildElement

public static Element getFirstChildElement(Node parent, String elemName)
Finds and returns the first child node with the given name.

getFirstChildElement

public static Element getFirstChildElement(Node parent, String[] elemNames)
Finds and returns the first child node with the given name.

getFirstChildElement

public static Element getFirstChildElement(Node parent, String elemName, String attrName, String attrValue)
Finds and returns the first child node with the given name and attribute name, value pair.

getFirstChildElementNS

public static Element getFirstChildElementNS(Node parent, String uri, String localpart)
Finds and returns the first child node with the given qualified name.

getFirstChildElementNS

public static Element getFirstChildElementNS(Node parent, String[][] elemNames)
Finds and returns the first child node with the given qualified name.

getFirstVisibleChildElement

public static Element getFirstVisibleChildElement(Node parent)
Finds and returns the first visible child element node.

getFirstVisibleChildElement

public static Element getFirstVisibleChildElement(Node parent, Hashtable hiddenNodes)
Finds and returns the first visible child element node.

getLastChildElement

public static Element getLastChildElement(Node parent)
Finds and returns the last child element node. Overload previous method for non-Xerces node impl.

getLastChildElement

public static Element getLastChildElement(Node parent, String elemName)
Finds and returns the last child node with the given name.

getLastChildElement

public static Element getLastChildElement(Node parent, String[] elemNames)
Finds and returns the last child node with the given name.

getLastChildElement

public static Element getLastChildElement(Node parent, String elemName, String attrName, String attrValue)
Finds and returns the last child node with the given name and attribute name, value pair.

getLastChildElementNS

public static Element getLastChildElementNS(Node parent, String uri, String localpart)
Finds and returns the last child node with the given qualified name.

getLastChildElementNS

public static Element getLastChildElementNS(Node parent, String[][] elemNames)
Finds and returns the last child node with the given qualified name.

getLastVisibleChildElement

public static Element getLastVisibleChildElement(Node parent)
Finds and returns the last visible child element node.

getLastVisibleChildElement

public static Element getLastVisibleChildElement(Node parent, Hashtable hiddenNodes)
Finds and returns the last visible child element node. Overload previous method for non-Xerces node impl

getLocalName

public static String getLocalName(Node node)
returns local name of this element if not null, otherwise returns the name of the node

getName

public static String getName(Node node)

getNamespaceURI

public static String getNamespaceURI(Node node)

getNextSiblingElement

public static Element getNextSiblingElement(Node node)
Finds and returns the next sibling element node.

getNextSiblingElement

public static Element getNextSiblingElement(Node node, String elemName)
Finds and returns the next sibling node with the given name.

getNextSiblingElement

public static Element getNextSiblingElement(Node node, String[] elemNames)
Finds and returns the next sibling node with the given name.

getNextSiblingElement

public static Element getNextSiblingElement(Node node, String elemName, String attrName, String attrValue)
Finds and returns the next sibling node with the given name and attribute name, value pair. Since only elements have attributes, the node returned will be of type Node.ELEMENT_NODE.

getNextSiblingElementNS

public static Element getNextSiblingElementNS(Node node, String uri, String localpart)
Finds and returns the next sibling node with the given qualified name.

getNextSiblingElementNS

public static Element getNextSiblingElementNS(Node node, String[][] elemNames)
Finds and returns the next sibling node with the given qualified name.

getNextVisibleSiblingElement

public static Element getNextVisibleSiblingElement(Node node)

getNextVisibleSiblingElement

public static Element getNextVisibleSiblingElement(Node node, Hashtable hiddenNodes)

getParent

public static Element getParent(Element elem)

getPrefix

public static String getPrefix(Node node)

getRoot

public static Element getRoot(Document doc)

getSyntheticAnnotation

public static String getSyntheticAnnotation(Node node)

getValue

public static String getValue(Attr attribute)

isHidden

public static boolean isHidden(Node node)

isHidden

public static boolean isHidden(Node node, Hashtable hiddenNodes)

setHidden

public static void setHidden(Node node)

setHidden

public static void setHidden(Node node, Hashtable hiddenNodes)

setVisible

public static void setVisible(Node node)

setVisible

public static void setVisible(Node node, Hashtable hiddenNodes)
Copyright © 1999-2005 Apache XML Project. All Rights Reserved.