Package org.apache.xerces.util
Class DOMUtil
- java.lang.Object
-
- org.apache.xerces.util.DOMUtil
-
public class DOMUtil extends java.lang.ObjectSome 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 $
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDOMUtil()This class cannot be instantiated.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyInto(org.w3c.dom.Node src, org.w3c.dom.Node dest)Copies the source tree into the specified place in a destination tree.static org.w3c.dom.DOMExceptioncreateDOMException(short code, java.lang.Throwable cause)Creates a DOMException.static org.w3c.dom.ls.LSExceptioncreateLSException(short code, java.lang.Throwable cause)Creates an LSException.static java.lang.StringgetAnnotation(org.w3c.dom.Node node)static org.w3c.dom.AttrgetAttr(org.w3c.dom.Element elem, java.lang.String name)static org.w3c.dom.AttrgetAttrNS(org.w3c.dom.Element elem, java.lang.String nsUri, java.lang.String localName)static org.w3c.dom.Attr[]getAttrs(org.w3c.dom.Element elem)static java.lang.StringgetAttrValue(org.w3c.dom.Element elem, java.lang.String name)static java.lang.StringgetAttrValueNS(org.w3c.dom.Element elem, java.lang.String nsUri, java.lang.String localName)static java.lang.StringgetChildText(org.w3c.dom.Node node)Returns the concatenated child text of the specified node.static org.w3c.dom.DocumentgetDocument(org.w3c.dom.Node node)static org.w3c.dom.ElementgetFirstChildElement(org.w3c.dom.Node parent)Finds and returns the first child element node.static org.w3c.dom.ElementgetFirstChildElement(org.w3c.dom.Node parent, java.lang.String elemName)Finds and returns the first child node with the given name.static org.w3c.dom.ElementgetFirstChildElement(org.w3c.dom.Node parent, java.lang.String[] elemNames)Finds and returns the first child node with the given name.static org.w3c.dom.ElementgetFirstChildElement(org.w3c.dom.Node parent, java.lang.String elemName, java.lang.String attrName, java.lang.String attrValue)Finds and returns the first child node with the given name and attribute name, value pair.static org.w3c.dom.ElementgetFirstChildElementNS(org.w3c.dom.Node parent, java.lang.String[][] elemNames)Finds and returns the first child node with the given qualified name.static org.w3c.dom.ElementgetFirstChildElementNS(org.w3c.dom.Node parent, java.lang.String uri, java.lang.String localpart)Finds and returns the first child node with the given qualified name.static org.w3c.dom.ElementgetFirstVisibleChildElement(org.w3c.dom.Node parent)Finds and returns the first visible child element node.static org.w3c.dom.ElementgetFirstVisibleChildElement(org.w3c.dom.Node parent, java.util.Hashtable hiddenNodes)Finds and returns the first visible child element node.static org.w3c.dom.ElementgetLastChildElement(org.w3c.dom.Node parent)Finds and returns the last child element node.static org.w3c.dom.ElementgetLastChildElement(org.w3c.dom.Node parent, java.lang.String elemName)Finds and returns the last child node with the given name.static org.w3c.dom.ElementgetLastChildElement(org.w3c.dom.Node parent, java.lang.String[] elemNames)Finds and returns the last child node with the given name.static org.w3c.dom.ElementgetLastChildElement(org.w3c.dom.Node parent, java.lang.String elemName, java.lang.String attrName, java.lang.String attrValue)Finds and returns the last child node with the given name and attribute name, value pair.static org.w3c.dom.ElementgetLastChildElementNS(org.w3c.dom.Node parent, java.lang.String[][] elemNames)Finds and returns the last child node with the given qualified name.static org.w3c.dom.ElementgetLastChildElementNS(org.w3c.dom.Node parent, java.lang.String uri, java.lang.String localpart)Finds and returns the last child node with the given qualified name.static org.w3c.dom.ElementgetLastVisibleChildElement(org.w3c.dom.Node parent)Finds and returns the last visible child element node.static org.w3c.dom.ElementgetLastVisibleChildElement(org.w3c.dom.Node parent, java.util.Hashtable hiddenNodes)Finds and returns the last visible child element node.static java.lang.StringgetLocalName(org.w3c.dom.Node node)returns local name of this element if not null, otherwise returns the name of the nodestatic java.lang.StringgetName(org.w3c.dom.Node node)static java.lang.StringgetNamespaceURI(org.w3c.dom.Node node)static org.w3c.dom.ElementgetNextSiblingElement(org.w3c.dom.Node node)Finds and returns the next sibling element node.static org.w3c.dom.ElementgetNextSiblingElement(org.w3c.dom.Node node, java.lang.String elemName)Finds and returns the next sibling node with the given name.static org.w3c.dom.ElementgetNextSiblingElement(org.w3c.dom.Node node, java.lang.String[] elemNames)Finds and returns the next sibling node with the given name.static org.w3c.dom.ElementgetNextSiblingElement(org.w3c.dom.Node node, java.lang.String elemName, java.lang.String attrName, java.lang.String attrValue)Finds and returns the next sibling node with the given name and attribute name, value pair.static org.w3c.dom.ElementgetNextSiblingElementNS(org.w3c.dom.Node node, java.lang.String[][] elemNames)Finds and returns the next sibling node with the given qualified name.static org.w3c.dom.ElementgetNextSiblingElementNS(org.w3c.dom.Node node, java.lang.String uri, java.lang.String localpart)Finds and returns the next sibling node with the given qualified name.static org.w3c.dom.ElementgetNextVisibleSiblingElement(org.w3c.dom.Node node)static org.w3c.dom.ElementgetNextVisibleSiblingElement(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)static org.w3c.dom.ElementgetParent(org.w3c.dom.Element elem)static java.lang.StringgetPrefix(org.w3c.dom.Node node)static org.w3c.dom.ElementgetRoot(org.w3c.dom.Document doc)static java.lang.StringgetSyntheticAnnotation(org.w3c.dom.Node node)static java.lang.StringgetValue(org.w3c.dom.Attr attribute)static booleanisHidden(org.w3c.dom.Node node)static booleanisHidden(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)static voidsetHidden(org.w3c.dom.Node node)static voidsetHidden(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)static voidsetVisible(org.w3c.dom.Node node)static voidsetVisible(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)
-
-
-
Method Detail
-
copyInto
public static void copyInto(org.w3c.dom.Node src, org.w3c.dom.Node dest) throws org.w3c.dom.DOMExceptionCopies 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.
- Throws:
org.w3c.dom.DOMException
-
getFirstChildElement
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent)
Finds and returns the first child element node.
-
getFirstVisibleChildElement
public static org.w3c.dom.Element getFirstVisibleChildElement(org.w3c.dom.Node parent)
Finds and returns the first visible child element node.
-
getFirstVisibleChildElement
public static org.w3c.dom.Element getFirstVisibleChildElement(org.w3c.dom.Node parent, java.util.Hashtable hiddenNodes)Finds and returns the first visible child element node.
-
getLastChildElement
public static org.w3c.dom.Element getLastChildElement(org.w3c.dom.Node parent)
Finds and returns the last child element node. Overload previous method for non-Xerces node impl.
-
getLastVisibleChildElement
public static org.w3c.dom.Element getLastVisibleChildElement(org.w3c.dom.Node parent)
Finds and returns the last visible child element node.
-
getLastVisibleChildElement
public static org.w3c.dom.Element getLastVisibleChildElement(org.w3c.dom.Node parent, java.util.Hashtable hiddenNodes)Finds and returns the last visible child element node. Overload previous method for non-Xerces node impl
-
getNextSiblingElement
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node node)
Finds and returns the next sibling element node.
-
getNextVisibleSiblingElement
public static org.w3c.dom.Element getNextVisibleSiblingElement(org.w3c.dom.Node node)
-
getNextVisibleSiblingElement
public static org.w3c.dom.Element getNextVisibleSiblingElement(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)
-
setHidden
public static void setHidden(org.w3c.dom.Node node)
-
setHidden
public static void setHidden(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)
-
setVisible
public static void setVisible(org.w3c.dom.Node node)
-
setVisible
public static void setVisible(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)
-
isHidden
public static boolean isHidden(org.w3c.dom.Node node)
-
isHidden
public static boolean isHidden(org.w3c.dom.Node node, java.util.Hashtable hiddenNodes)
-
getFirstChildElement
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent, java.lang.String elemName)Finds and returns the first child node with the given name.
-
getLastChildElement
public static org.w3c.dom.Element getLastChildElement(org.w3c.dom.Node parent, java.lang.String elemName)Finds and returns the last child node with the given name.
-
getNextSiblingElement
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node node, java.lang.String elemName)Finds and returns the next sibling node with the given name.
-
getFirstChildElementNS
public static org.w3c.dom.Element getFirstChildElementNS(org.w3c.dom.Node parent, java.lang.String uri, java.lang.String localpart)Finds and returns the first child node with the given qualified name.
-
getLastChildElementNS
public static org.w3c.dom.Element getLastChildElementNS(org.w3c.dom.Node parent, java.lang.String uri, java.lang.String localpart)Finds and returns the last child node with the given qualified name.
-
getNextSiblingElementNS
public static org.w3c.dom.Element getNextSiblingElementNS(org.w3c.dom.Node node, java.lang.String uri, java.lang.String localpart)Finds and returns the next sibling node with the given qualified name.
-
getFirstChildElement
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent, java.lang.String[] elemNames)Finds and returns the first child node with the given name.
-
getLastChildElement
public static org.w3c.dom.Element getLastChildElement(org.w3c.dom.Node parent, java.lang.String[] elemNames)Finds and returns the last child node with the given name.
-
getNextSiblingElement
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node node, java.lang.String[] elemNames)Finds and returns the next sibling node with the given name.
-
getFirstChildElementNS
public static org.w3c.dom.Element getFirstChildElementNS(org.w3c.dom.Node parent, java.lang.String[][] elemNames)Finds and returns the first child node with the given qualified name.
-
getLastChildElementNS
public static org.w3c.dom.Element getLastChildElementNS(org.w3c.dom.Node parent, java.lang.String[][] elemNames)Finds and returns the last child node with the given qualified name.
-
getNextSiblingElementNS
public static org.w3c.dom.Element getNextSiblingElementNS(org.w3c.dom.Node node, java.lang.String[][] elemNames)Finds and returns the next sibling node with the given qualified name.
-
getFirstChildElement
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent, java.lang.String elemName, java.lang.String attrName, java.lang.String attrValue)Finds and returns the first child node with the given name and attribute name, value pair.
-
getLastChildElement
public static org.w3c.dom.Element getLastChildElement(org.w3c.dom.Node parent, java.lang.String elemName, java.lang.String attrName, java.lang.String attrValue)Finds and returns the last child node with the given name and attribute name, value pair.
-
getNextSiblingElement
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node node, java.lang.String elemName, java.lang.String attrName, java.lang.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.
-
getChildText
public static java.lang.String getChildText(org.w3c.dom.Node node)
Returns the concatenated child text of the specified node. This method only looks at the immediate children of typeNode.TEXT_NODEor the children of any child node that is of typeNode.CDATA_SECTION_NODEfor the concatenation.- Parameters:
node- The node to look at.
-
getName
public static java.lang.String getName(org.w3c.dom.Node node)
-
getLocalName
public static java.lang.String getLocalName(org.w3c.dom.Node node)
returns local name of this element if not null, otherwise returns the name of the node
-
getParent
public static org.w3c.dom.Element getParent(org.w3c.dom.Element elem)
-
getDocument
public static org.w3c.dom.Document getDocument(org.w3c.dom.Node node)
-
getRoot
public static org.w3c.dom.Element getRoot(org.w3c.dom.Document doc)
-
getAttr
public static org.w3c.dom.Attr getAttr(org.w3c.dom.Element elem, java.lang.String name)
-
getAttrNS
public static org.w3c.dom.Attr getAttrNS(org.w3c.dom.Element elem, java.lang.String nsUri, java.lang.String localName)
-
getAttrs
public static org.w3c.dom.Attr[] getAttrs(org.w3c.dom.Element elem)
-
getValue
public static java.lang.String getValue(org.w3c.dom.Attr attribute)
-
getAttrValue
public static java.lang.String getAttrValue(org.w3c.dom.Element elem, java.lang.String name)
-
getAttrValueNS
public static java.lang.String getAttrValueNS(org.w3c.dom.Element elem, java.lang.String nsUri, java.lang.String localName)
-
getPrefix
public static java.lang.String getPrefix(org.w3c.dom.Node node)
-
getNamespaceURI
public static java.lang.String getNamespaceURI(org.w3c.dom.Node node)
-
getAnnotation
public static java.lang.String getAnnotation(org.w3c.dom.Node node)
-
getSyntheticAnnotation
public static java.lang.String getSyntheticAnnotation(org.w3c.dom.Node node)
-
createDOMException
public static org.w3c.dom.DOMException createDOMException(short code, java.lang.Throwable cause)Creates a DOMException. On J2SE 1.4 and above the cause for the exception will be set.
-
createLSException
public static org.w3c.dom.ls.LSException createLSException(short code, java.lang.Throwable cause)Creates an LSException. On J2SE 1.4 and above the cause for the exception will be set.
-
-