Top Description Inners Constructors Methods
org.apache.xerces.util

public Class DOMUtil

extends Object
Class Inheritance
Imports
java.util.Hashtable, org.apache.xerces.dom.AttrImpl, .DocumentImpl, org.apache.xerces.impl.xs.opti.ElementImpl, org.w3c.dom.Attr, .DOMException, .Document, .Element, .NamedNodeMap, .Node, org.w3c.dom.ls.LSException

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 929493 2010-03-31 12:15:17Z mrglavas $

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DOMUtil.ThrowableMethods

Holder of methods from java.lang.Throwable.

Constructor Summary

AccessConstructor and Description
protected
DOMUtil()

This class cannot be instantiated.

Method Summary

Modifier and TypeMethod and Description
public static void
copyInto(Node src, Node dest)

Copies the source tree into the specified place in a destination tree.

public static DOMException
createDOMException(short code, Throwable cause)

Creates a DOMException.

public static LSException
createLSException(short code, Throwable cause)

Creates an LSException.

public static String
public static Attr
getAttr(Element elem, String name)

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

public static Attr[]
public static String
public static String
getAttrValueNS(Element elem, String nsUri, String localName)

public static String
getChildText(Node
The node to look at.
node
)

Returns the concatenated child text of the specified node.

public static Document
public static Element
getFirstChildElement(Node parent)

Finds and returns the first child element node.

public static Element
getFirstChildElement(Node parent, String elemName)

Finds and returns the first child node with the given name.

public static Element
getFirstChildElement(Node parent, String[] elemNames)

Finds and returns the first child node with the given name.

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.

public static Element
getFirstChildElementNS(Node parent, String uri, String localpart)

Finds and returns the first child node with the given qualified name.

public static Element
getFirstChildElementNS(Node parent, String[][] elemNames)

Finds and returns the first child node with the given qualified name.

public static Element
getFirstVisibleChildElement(Node parent)

Finds and returns the first visible child element node.

public static Element
getFirstVisibleChildElement(Node parent, Hashtable<K, V> hiddenNodes)

Finds and returns the first visible child element node.

public static Element
getLastChildElement(Node parent)

Finds and returns the last child element node.

public static Element
getLastChildElement(Node parent, String elemName)

Finds and returns the last child node with the given name.

public static Element
getLastChildElement(Node parent, String[] elemNames)

Finds and returns the last child node with the given name.

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.

public static Element
getLastChildElementNS(Node parent, String uri, String localpart)

Finds and returns the last child node with the given qualified name.

public static Element
getLastChildElementNS(Node parent, String[][] elemNames)

Finds and returns the last child node with the given qualified name.

public static Element
getLastVisibleChildElement(Node parent)

Finds and returns the last visible child element node.

public static Element
getLastVisibleChildElement(Node parent, Hashtable<K, V> hiddenNodes)

Finds and returns the last visible child element node.

public static String
getLocalName(Node node)

returns local name of this element if not null, otherwise returns the name of the node

public static String
getName(Node node)

public static String
public static Element
getNextSiblingElement(Node node)

Finds and returns the next sibling element node.

public static Element
getNextSiblingElement(Node node, String elemName)

Finds and returns the next sibling node with the given name.

public static Element
getNextSiblingElement(Node node, String[] elemNames)

Finds and returns the next sibling node with the given name.

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.

public static Element
getNextSiblingElementNS(Node node, String uri, String localpart)

Finds and returns the next sibling node with the given qualified name.

public static Element
getNextSiblingElementNS(Node node, String[][] elemNames)

Finds and returns the next sibling node with the given qualified name.

public static Element
public static Element
getNextVisibleSiblingElement(Node node, Hashtable<K, V> hiddenNodes)

public static Element
public static String
public static Element
public static String
public static String
getValue(Attr attribute)

public static boolean
isHidden(Node node)

public static boolean
isHidden(Node node, Hashtable<K, V> hiddenNodes)

public static void
public static void
setHidden(Node node, Hashtable<K, V> hiddenNodes)

public static void
public static void
setVisible(Node node, Hashtable<K, V> hiddenNodes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DOMUtilback to summary
protected DOMUtil()

This class cannot be instantiated.

Method Detail

copyIntoback to summary
public static void copyInto(Node src, Node dest) throws DOMException

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.

createDOMExceptionback to summary
public static DOMException createDOMException(short code, Throwable cause)

Creates a DOMException. On J2SE 1.4 and above the cause for the exception will be set.

createLSExceptionback to summary
public static LSException createLSException(short code, Throwable cause)

Creates an LSException. On J2SE 1.4 and above the cause for the exception will be set.

getAnnotationback to summary
public static String getAnnotation(Node node)
getAttrback to summary
public static Attr getAttr(Element elem, String name)
getAttrNSback to summary
public static Attr getAttrNS(Element elem, String nsUri, String localName)
getAttrsback to summary
public static Attr[] getAttrs(Element elem)
getAttrValueback to summary
public static String getAttrValue(Element elem, String name)
getAttrValueNSback to summary
public static String getAttrValueNS(Element elem, String nsUri, String localName)
getChildTextback to summary
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:Node

The node to look at.

getDocumentback to summary
public static Document getDocument(Node node)
getFirstChildElementback to summary
public static Element getFirstChildElement(Node parent)

Finds and returns the first child element node.

getFirstChildElementback to summary
public static Element getFirstChildElement(Node parent, String elemName)

Finds and returns the first child node with the given name.

getFirstChildElementback to summary
public static Element getFirstChildElement(Node parent, String[] elemNames)

Finds and returns the first child node with the given name.

getFirstChildElementback to summary
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.

getFirstChildElementNSback to summary
public static Element getFirstChildElementNS(Node parent, String uri, String localpart)

Finds and returns the first child node with the given qualified name.

getFirstChildElementNSback to summary
public static Element getFirstChildElementNS(Node parent, String[][] elemNames)

Finds and returns the first child node with the given qualified name.

getFirstVisibleChildElementback to summary
public static Element getFirstVisibleChildElement(Node parent)

Finds and returns the first visible child element node.

getFirstVisibleChildElementback to summary
public static Element getFirstVisibleChildElement(Node parent, Hashtable<K, V> hiddenNodes)

Finds and returns the first visible child element node.

getLastChildElementback to summary
public static Element getLastChildElement(Node parent)

Finds and returns the last child element node. Overload previous method for non-Xerces node impl.

getLastChildElementback to summary
public static Element getLastChildElement(Node parent, String elemName)

Finds and returns the last child node with the given name.

getLastChildElementback to summary
public static Element getLastChildElement(Node parent, String[] elemNames)

Finds and returns the last child node with the given name.

getLastChildElementback to summary
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.

getLastChildElementNSback to summary
public static Element getLastChildElementNS(Node parent, String uri, String localpart)

Finds and returns the last child node with the given qualified name.

getLastChildElementNSback to summary
public static Element getLastChildElementNS(Node parent, String[][] elemNames)

Finds and returns the last child node with the given qualified name.

getLastVisibleChildElementback to summary
public static Element getLastVisibleChildElement(Node parent)

Finds and returns the last visible child element node.

getLastVisibleChildElementback to summary
public static Element getLastVisibleChildElement(Node parent, Hashtable<K, V> hiddenNodes)

Finds and returns the last visible child element node. Overload previous method for non-Xerces node impl

getLocalNameback to summary
public static String getLocalName(Node node)

returns local name of this element if not null, otherwise returns the name of the node

getNameback to summary
public static String getName(Node node)
getNamespaceURIback to summary
public static String getNamespaceURI(Node node)
getNextSiblingElementback to summary
public static Element getNextSiblingElement(Node node)

Finds and returns the next sibling element node.

getNextSiblingElementback to summary
public static Element getNextSiblingElement(Node node, String elemName)

Finds and returns the next sibling node with the given name.

getNextSiblingElementback to summary
public static Element getNextSiblingElement(Node node, String[] elemNames)

Finds and returns the next sibling node with the given name.

getNextSiblingElementback to summary
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.

getNextSiblingElementNSback to summary
public static Element getNextSiblingElementNS(Node node, String uri, String localpart)

Finds and returns the next sibling node with the given qualified name.

getNextSiblingElementNSback to summary
public static Element getNextSiblingElementNS(Node node, String[][] elemNames)

Finds and returns the next sibling node with the given qualified name.

getNextVisibleSiblingElementback to summary
public static Element getNextVisibleSiblingElement(Node node)
getNextVisibleSiblingElementback to summary
public static Element getNextVisibleSiblingElement(Node node, Hashtable<K, V> hiddenNodes)
getParentback to summary
public static Element getParent(Element elem)
getPrefixback to summary
public static String getPrefix(Node node)
getRootback to summary
public static Element getRoot(Document doc)
getSyntheticAnnotationback to summary
public static String getSyntheticAnnotation(Node node)
getValueback to summary
public static String getValue(Attr attribute)
isHiddenback to summary
public static boolean isHidden(Node node)
isHiddenback to summary
public static boolean isHidden(Node node, Hashtable<K, V> hiddenNodes)
setHiddenback to summary
public static void setHidden(Node node)
setHiddenback to summary
public static void setHidden(Node node, Hashtable<K, V> hiddenNodes)
setVisibleback to summary
public static void setVisible(Node node)
setVisibleback to summary
public static void setVisible(Node node, Hashtable<K, V> hiddenNodes)
org.apache.xerces.util back to summary

pack-priv Class DOMUtil.ThrowableMethods

extends Object
Class Inheritance

Holder of methods from java.lang.Throwable.

Field Summary

Modifier and TypeField and Description
private static Method
private static boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fgThrowableInitCauseMethodback to summary
private static Method fgThrowableInitCauseMethod
fgThrowableMethodsAvailableback to summary
private static boolean fgThrowableMethodsAvailable

Constructor Detail

ThrowableMethodsback to summary
private ThrowableMethods()