com.novell.nds.dirxml.util
Class DxDOMUtil

java.lang.Object
  extended by com.novell.nds.dirxml.util.DxDOMUtil

public abstract class DxDOMUtil
extends Object

A utility class for performing various common and useful DOM operations that are not part of the DOM specification.


Field Summary
protected static ExpandedQName SEARCH_NULL_ANY
          Wildcard search name that will match the null namespace URI and any local part.
static String TAG_WILDCARD
          Wildcard value that can be used for both the namespaceURI and localPart parameters to the various "ByTagName" functions
 
Constructor Summary
DxDOMUtil()
           
 
Method Summary
static Document cloneDocument(Document doc)
          Creates clone of a document.
static Node cloneSubtree(Document targetDoc, Node sourceRoot)
          Clone a subtree, possibly into another document
static boolean copyAttributeEx(ElementImpl src, ExpandedQName attrName, ElementImpl dest)
          Copy an attribute from one element to another, but only if the attribute has a non-empty value.
static boolean copyAttributeEx(ElementImpl src, ExpandedQName srcAttrName, ElementImpl dest, ExpandedQName destAttrName)
          Copy an attribute from one element to another, but only if the attribute has a non-empty value.
static boolean copyAttributeNS(Element src, String attrNamespaceURI, String attrLocalName, Element dest)
          Copy an attribute from one element to another, but only if the attribute has a non-empty value
static boolean copyAttributeNS(Element src, String srcAttrNamespaceURI, String srcAttrLocalPart, Element dest, String destAttrNamespaceURI, String destAttrQName)
          Copy an attribute from one element to another, with an new attribute name, but only if the attribute has a non-empty value.
static Element[] elementArrayListToElementArray(ArrayList arrayList)
          Create an array of Elements from an ArrayList containing only Elements.
static ElementImpl[] elementImplArrayListToElementImplArray(ArrayList arrayList)
          creates an array of ElementImpls from an ArrayList containing only ElementImpls.
static void ensureDOMImpl(XmlDocument src)
          Conditionally convert the passed document to the DirXML DOM implementation.
static String getAssociationState(Element element)
          Get the value of the "state" attribute of the first <association> element found under the passed element.
static String getAssociationStateEx(ElementImpl element)
          Get the value of the "state" attribute of the first <association> element found under the passed element.
static String getAssociationValue(Element element)
          Get the value of the first <association> element found under the passed element.
static String getAssociationValueEx(ElementImpl element)
          Get the value of the first <association> element found under the passed element.
static Element[] getChildElements(Node node)
          Get all child elements of a node.
static ElementImpl[] getChildElementsByTagNameEx(NodeImpl node, ExpandedQName qName)
          Get the all child elements of a node with a particular qualified tag name.
static Element[] getChildElementsByTagNameNS(Node node, String namespaceURI, String localPart)
          Get the all child elements of a node with a particular qualified tag name.
static ElementImpl[] getChildElementsByTagNameWithAttrEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName)
          Get all child elements of a node with a particular QName and a particular non-empty attribute.
static Element[] getChildElementsByTagNameWithAttrNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart)
          Get all child elements of a node with a particular qualified tag name and a particular non-empty attribute.
static ElementImpl[] getChildElementsByTagNameWithAttrValueEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get all child elements of a node with a particular QName and a particular attribute/value pair (value is case sensitive)
static ElementImpl[] getChildElementsByTagNameWithAttrValueIgnoreCaseEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get all child elements of a node with a particular QName and a particular attribute/value pair (value is not case sensitive)
static Element[] getChildElementsByTagNameWithAttrValueIgnoreCaseNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get all child elements of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)
static Element[] getChildElementsByTagNameWithAttrValueNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get all child elements of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)
static ElementImpl[] getChildElementsEx(NodeImpl node)
          Get all child elements of a node.
static String getChildText(Node node)
          Get the concatenation of all the child text nodes of the passed node.
static NodeList getElementsByTagNameEx(NodeImpl node, ExpandedQName qName)
          Get all descendant Elements of a node with a particular tag name.
static NodeList getElementsByTagNameNS(Node node, String namespaceURI, String localPart)
          Get all descendant elements of a node with a particular qualified tag name.
static ElementImpl[] getElementsByTagNameWithAttrEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName)
          Get all descendant elements of an node with a particular QName and a particular non-empty attribute.
static Element[] getElementsByTagNameWithAttrNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart)
          Get all descendant elements of an node with a particular tag name and a particular non-empty attribute.
static ElementImpl[] getElementsByTagNameWithAttrValueEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get all descendant elements of an node with a QName and a particular attribute/value pair (value is case sensitive)
static Element[] getElementsByTagNameWithAttrValueNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get all descendant elements of an node with a particular tag name and a particular attribute/value pair (value is case sensitive)
static ElementImpl getFirstAncestorElementByTagNameEx(NodeImpl node, ExpandedQName elementName)
          Get the nearest ancestor element of an node with a particular QName
static Element getFirstAncestorElementByTagNameNS(Node node, String namespaceURI, String localPart)
          Get the nearest ancestor element of an node with a particular tag name
static ElementImpl getFirstAncestorElementByTagNameWithAttrEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName)
          Get the nearest ancestor element of an node with a particular QName and a particular non-empty attribute.
static Element getFirstAncestorElementByTagNameWithAttrNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart)
          Get the nearest ancestor element of an node with a particular tag name and a particular non-empty attribute.
static Element getFirstChildElement(Node node)
          Get the first child element of a node
static ElementImpl getFirstChildElementByTagNameEx(NodeImpl node, ExpandedQName qName)
          Get the first child element of a node with a particular tag name.
static Element getFirstChildElementByTagNameNS(Node node, String namespaceURI, String localPart)
          Get a node's first child element with a particular qualified tag name.
static ElementImpl getFirstChildElementByTagNameWithAttrValueEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)
static ElementImpl getFirstChildElementByTagNameWithAttrValueIgnoreCaseEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)
static Element getFirstChildElementByTagNameWithAttrValueIgnoreCaseNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)
static Element getFirstChildElementByTagNameWithAttrValueNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)
static ElementImpl getFirstChildElementEx(NodeImpl node)
          Get the first child element of a node
static ElementImpl getFirstElementByTagNameEx(NodeImpl node, ExpandedQName qName)
          Get first descendant element of an node with a particular tag name.
static Element getFirstElementByTagNameNS(Node node, String namespaceURI, String localPart)
          Get first descendant element of an node with a particular tag name.
static ElementImpl getFirstElementByTagNameWithAttrValueEx(NodeImpl node, ExpandedQName elementName, ExpandedQName attrName, String attrValue)
          Get the first descendant element of an node with a particular QName and a particular attribute/value pair (value is case sensitive)
static Element getFirstElementByTagNameWithAttrValueNS(Node node, String namespaceURI, String localPart, String attrNamespaceURI, String attrLocalPart, String attrValue)
          Get the first descendant elements of an node with a particular tag name and a particular attribute/value pair (value is case sensitive)
static Element getFirstValue(Node node, String attrName)
          Get the first <value> element for the passed directory attribute.
static ElementImpl getFirstValueEx(NodeImpl node, String attrName)
          Get the first <value> element for the passed directory attribute.
static String getNodeText(Node node)
          Get the string value for a node (as defined by XPath).
static Date getTimestamp(Element element)
          Get a Date instance from the timestamp attribute for an element
static int getTimestampEventCount(Element element)
          Get the timestamp event count from the timestamp attribute for an element
static int getTimestampEventCountEx(ElementImpl element)
          Get the timestamp event count from the timestamp attribute for an element
static Date getTimestampEx(ElementImpl element)
          Get a Date instance from the timestamp attribute for an element
static void graftSubtree(Node parent, Node sourceRoot)
          Graft a cloned subtree, possibly into another document
static Node[] nodeListToNodeArray(NodeList list)
          Create an array of nodes from a NodeList.
static void removeAllChildren(Node node)
          Remove all the children of a node.
static void removeChildElementsByTagNameEx(NodeImpl node, ExpandedQName elementName)
          Remove all child elements of a node with a particular QName.
static void removeChildElementsByTagNameNS(Node node, String namespaceURI, String localPart)
          Remove all child elements of a node with a particular tag name.
static ElementImpl renameElementEx(ElementImpl element, ExpandedQName newName)
          Rename an element.
static Element renameElementNS(Element element, String namespaceURI, String qName)
          Rename an element.
static void setNodeText(Node node, String text)
          Set the string value for a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_WILDCARD

public static final String TAG_WILDCARD
Wildcard value that can be used for both the namespaceURI and localPart parameters to the various "ByTagName" functions

See Also:
Constant Field Values

SEARCH_NULL_ANY

protected static final ExpandedQName SEARCH_NULL_ANY
Wildcard search name that will match the null namespace URI and any local part.

Constructor Detail

DxDOMUtil

public DxDOMUtil()
Method Detail

getNodeText

public static String getNodeText(Node node)
Get the string value for a node (as defined by XPath).

Parameters:
node - the node
Returns:
the string value of the node

getChildText

public static String getChildText(Node node)
Get the concatenation of all the child text nodes of the passed node.

Parameters:
node - the parent node
Returns:
the concatentation of all child text node values

setNodeText

public static void setNodeText(Node node,
                               String text)
Set the string value for a node. This removes all current children and adds a single, new text node child. If the passed text is null or empty no child is added.

Parameters:
node - the parent node
text - the desired text value of the node

getFirstChildElement

public static Element getFirstChildElement(Node node)
Get the first child element of a node

Parameters:
node - the parent node
Returns:
the first child element, or null if no such element exists

getFirstChildElementEx

public static ElementImpl getFirstChildElementEx(NodeImpl node)
Get the first child element of a node

Parameters:
node - the parent node
Returns:
the first child element, or null if no such element exists

getFirstChildElementByTagNameNS

public static Element getFirstChildElementByTagNameNS(Node node,
                                                      String namespaceURI,
                                                      String localPart)
Get a node's first child element with a particular qualified tag name.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
Returns:
the first matching element or null if no such element exists

getFirstChildElementByTagNameEx

public static ElementImpl getFirstChildElementByTagNameEx(NodeImpl node,
                                                          ExpandedQName qName)
Get the first child element of a node with a particular tag name.

Parameters:
node - the node
qName - the expanded QName of the element to find
Returns:
the first matching element or null if no such element exists

getFirstChildElementByTagNameWithAttrValueNS

public static Element getFirstChildElementByTagNameWithAttrValueNS(Node node,
                                                                   String namespaceURI,
                                                                   String localPart,
                                                                   String attrNamespaceURI,
                                                                   String attrLocalPart,
                                                                   String attrValue)
Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
the first matching element or null if no such element exists

getFirstChildElementByTagNameWithAttrValueEx

public static ElementImpl getFirstChildElementByTagNameWithAttrValueEx(NodeImpl node,
                                                                       ExpandedQName elementName,
                                                                       ExpandedQName attrName,
                                                                       String attrValue)
Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
elementName - the qualified element name
attrName - the qualifed attribute name
attrValue - the attribute value
Returns:
the first matching element or null if no such element exists

getFirstChildElementByTagNameWithAttrValueIgnoreCaseNS

public static Element getFirstChildElementByTagNameWithAttrValueIgnoreCaseNS(Node node,
                                                                             String namespaceURI,
                                                                             String localPart,
                                                                             String attrNamespaceURI,
                                                                             String attrLocalPart,
                                                                             String attrValue)
Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
the first matching element or null if no such element exists

getFirstChildElementByTagNameWithAttrValueIgnoreCaseEx

public static ElementImpl getFirstChildElementByTagNameWithAttrValueIgnoreCaseEx(NodeImpl node,
                                                                                 ExpandedQName elementName,
                                                                                 ExpandedQName attrName,
                                                                                 String attrValue)
Get the first child element of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)

Parameters:
node - the node
elementName - the qualified element name
attrName - the qualifed attribute name
attrValue - the attribute value
Returns:
the first matching element or null if no such element exists

getChildElements

public static Element[] getChildElements(Node node)
Get all child elements of a node.

Parameters:
node - the parent node
Returns:
array containing the all the child elements of the element, possibly 0 length, but never null

getChildElementsEx

public static ElementImpl[] getChildElementsEx(NodeImpl node)
Get all child elements of a node.

Parameters:
node - the parent node
Returns:
array containing the all the child elements of the element, possibly 0 length, but never null

getChildElementsByTagNameNS

public static Element[] getChildElementsByTagNameNS(Node node,
                                                    String namespaceURI,
                                                    String localPart)
Get the all child elements of a node with a particular qualified tag name.

Parameters:
node - the parent node
namespaceURI - element name's namespace URI
localPart - the element name's local part
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameEx

public static ElementImpl[] getChildElementsByTagNameEx(NodeImpl node,
                                                        ExpandedQName qName)
Get the all child elements of a node with a particular qualified tag name.

Parameters:
node - the parent node
qName - the element name
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrNS

public static Element[] getChildElementsByTagNameWithAttrNS(Node node,
                                                            String namespaceURI,
                                                            String localPart,
                                                            String attrNamespaceURI,
                                                            String attrLocalPart)
Get all child elements of a node with a particular qualified tag name and a particular non-empty attribute.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrEx

public static ElementImpl[] getChildElementsByTagNameWithAttrEx(NodeImpl node,
                                                                ExpandedQName elementName,
                                                                ExpandedQName attrName)
Get all child elements of a node with a particular QName and a particular non-empty attribute.

Parameters:
node - the parent node
elementName - the QName of the elements to find
attrName - the QName of the non-empty attribute
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrValueNS

public static Element[] getChildElementsByTagNameWithAttrValueNS(Node node,
                                                                 String namespaceURI,
                                                                 String localPart,
                                                                 String attrNamespaceURI,
                                                                 String attrLocalPart,
                                                                 String attrValue)
Get all child elements of a node with a particular tag name and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrValueEx

public static ElementImpl[] getChildElementsByTagNameWithAttrValueEx(NodeImpl node,
                                                                     ExpandedQName elementName,
                                                                     ExpandedQName attrName,
                                                                     String attrValue)
Get all child elements of a node with a particular QName and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
elementName - the child elements' QName
attrName - the attributes' QName
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrValueIgnoreCaseNS

public static Element[] getChildElementsByTagNameWithAttrValueIgnoreCaseNS(Node node,
                                                                           String namespaceURI,
                                                                           String localPart,
                                                                           String attrNamespaceURI,
                                                                           String attrLocalPart,
                                                                           String attrValue)
Get all child elements of a node with a particular tag name and a particular attribute/value pair (value is not case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getChildElementsByTagNameWithAttrValueIgnoreCaseEx

public static ElementImpl[] getChildElementsByTagNameWithAttrValueIgnoreCaseEx(NodeImpl node,
                                                                               ExpandedQName elementName,
                                                                               ExpandedQName attrName,
                                                                               String attrValue)
Get all child elements of a node with a particular QName and a particular attribute/value pair (value is not case sensitive)

Parameters:
node - the parent node
elementName - the child elements' QName
attrName - the attributes' QName
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getElementsByTagNameNS

public static NodeList getElementsByTagNameNS(Node node,
                                              String namespaceURI,
                                              String localPart)
Get all descendant elements of a node with a particular qualified tag name.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
Returns:
NodeList containing any matching elements

getElementsByTagNameEx

public static NodeList getElementsByTagNameEx(NodeImpl node,
                                              ExpandedQName qName)
Get all descendant Elements of a node with a particular tag name.

Wildcards may be used, either by passing ExpandedQName.WILDCARD_QNAME, or by constructing an ExpandedQName instance using some combination of NamespaceName.WILDCARD_NAMESPACE and ExpandedQName.WILDCARD_LOCALPART.

Parameters:
node - the node whose descendants are to be found
qName - the QName of the descendant Elements to find
Returns:
list containing the matching Elements

getElementsByTagNameWithAttrNS

public static Element[] getElementsByTagNameWithAttrNS(Node node,
                                                       String namespaceURI,
                                                       String localPart,
                                                       String attrNamespaceURI,
                                                       String attrLocalPart)
Get all descendant elements of an node with a particular tag name and a particular non-empty attribute.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
Returns:
array containing the matching elements, possibly 0 length, but never null

getElementsByTagNameWithAttrEx

public static ElementImpl[] getElementsByTagNameWithAttrEx(NodeImpl node,
                                                           ExpandedQName elementName,
                                                           ExpandedQName attrName)
Get all descendant elements of an node with a particular QName and a particular non-empty attribute.

Parameters:
node - the parent node
elementName - the QName of the desired elements
attrName - the QName of the attribute
Returns:
array containing the matching elements, possibly 0 length, but never null

getElementsByTagNameWithAttrValueNS

public static Element[] getElementsByTagNameWithAttrValueNS(Node node,
                                                            String namespaceURI,
                                                            String localPart,
                                                            String attrNamespaceURI,
                                                            String attrLocalPart,
                                                            String attrValue)
Get all descendant elements of an node with a particular tag name and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getElementsByTagNameWithAttrValueEx

public static ElementImpl[] getElementsByTagNameWithAttrValueEx(NodeImpl node,
                                                                ExpandedQName elementName,
                                                                ExpandedQName attrName,
                                                                String attrValue)
Get all descendant elements of an node with a QName and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
elementName - the QName of the desired elements
attrName - the QName of the attribute
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

removeChildElementsByTagNameNS

public static void removeChildElementsByTagNameNS(Node node,
                                                  String namespaceURI,
                                                  String localPart)
Remove all child elements of a node with a particular tag name.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name

removeChildElementsByTagNameEx

public static void removeChildElementsByTagNameEx(NodeImpl node,
                                                  ExpandedQName elementName)
Remove all child elements of a node with a particular QName.

Parameters:
node - the parent node
elementName - the elements' QName

getFirstElementByTagNameNS

public static Element getFirstElementByTagNameNS(Node node,
                                                 String namespaceURI,
                                                 String localPart)
Get first descendant element of an node with a particular tag name.

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
Returns:
the first matching element or null if no such element exists

getFirstElementByTagNameEx

public static ElementImpl getFirstElementByTagNameEx(NodeImpl node,
                                                     ExpandedQName qName)
Get first descendant element of an node with a particular tag name.

Parameters:
node - the node
qName - the tag name to find
Returns:
the first matching element or null if no such element exists

getFirstElementByTagNameWithAttrValueNS

public static Element getFirstElementByTagNameWithAttrValueNS(Node node,
                                                              String namespaceURI,
                                                              String localPart,
                                                              String attrNamespaceURI,
                                                              String attrLocalPart,
                                                              String attrValue)
Get the first descendant elements of an node with a particular tag name and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
namespaceURI - the namespace URI of the qualified tag name
localPart - the local part of the qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

getFirstElementByTagNameWithAttrValueEx

public static ElementImpl getFirstElementByTagNameWithAttrValueEx(NodeImpl node,
                                                                  ExpandedQName elementName,
                                                                  ExpandedQName attrName,
                                                                  String attrValue)
Get the first descendant element of an node with a particular QName and a particular attribute/value pair (value is case sensitive)

Parameters:
node - the parent node
elementName - the child elements' QName
attrName - the attributes' QName
attrValue - the attribute value
Returns:
array containing the matching elements, possibly 0 length, but never null

cloneSubtree

public static Node cloneSubtree(Document targetDoc,
                                Node sourceRoot)
Clone a subtree, possibly into another document

Parameters:
targetDoc - target document for the cloned document
sourceRoot - root of subtree to clone
Returns:
root of the cloned subtree, or null if not cloneable

graftSubtree

public static void graftSubtree(Node parent,
                                Node sourceRoot)
Graft a cloned subtree, possibly into another document

Parameters:
parent - target parent
sourceRoot - root of subtree to clone

cloneDocument

public static Document cloneDocument(Document doc)
Creates clone of a document. NOTE: only clones the tree structure, ie. ignores any document attributes

Parameters:
doc - document to clone
Returns:
cloned document

renameElementNS

public static Element renameElementNS(Element element,
                                      String namespaceURI,
                                      String qName)
Rename an element. May replace the element with a new one that has the same attributes and children.

Parameters:
element - element to be renamed
namespaceURI - the namespace URI of the new qualified tag name
qName - "[prefix:]local part" of the new qualified tag name
Returns:
the renamed element

renameElementEx

public static ElementImpl renameElementEx(ElementImpl element,
                                          ExpandedQName newName)
Rename an element.

Parameters:
element - element to be renamed
newName - the new QName for the element
Returns:
the renamed element

removeAllChildren

public static void removeAllChildren(Node node)
Remove all the children of a node.

Parameters:
node - the parent node

getFirstAncestorElementByTagNameNS

public static Element getFirstAncestorElementByTagNameNS(Node node,
                                                         String namespaceURI,
                                                         String localPart)
Get the nearest ancestor element of an node with a particular tag name

Parameters:
node - the starting node
namespaceURI - the namespace URI of the ancestor's qualified tag name
localPart - the local part of the ancestor's qualified tag name
Returns:
the first matching element, or null if no such element exists

getFirstAncestorElementByTagNameEx

public static ElementImpl getFirstAncestorElementByTagNameEx(NodeImpl node,
                                                             ExpandedQName elementName)
Get the nearest ancestor element of an node with a particular QName

Parameters:
node - the node from which to start
elementName - the ancestor element's QName
Returns:
the first matching element or null if no such element exists

getFirstAncestorElementByTagNameWithAttrNS

public static Element getFirstAncestorElementByTagNameWithAttrNS(Node node,
                                                                 String namespaceURI,
                                                                 String localPart,
                                                                 String attrNamespaceURI,
                                                                 String attrLocalPart)
Get the nearest ancestor element of an node with a particular tag name and a particular non-empty attribute.

Parameters:
node - the starting node
namespaceURI - the namespace URI of the ancestor's qualified tag name
localPart - the local part of the ancestor's qualified tag name
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
Returns:
the first matching element or null if no such element exists

getFirstAncestorElementByTagNameWithAttrEx

public static ElementImpl getFirstAncestorElementByTagNameWithAttrEx(NodeImpl node,
                                                                     ExpandedQName elementName,
                                                                     ExpandedQName attrName)
Get the nearest ancestor element of an node with a particular QName and a particular non-empty attribute.

Parameters:
node - the node from which to start
elementName - the ancestor element's QName
attrName - the attribute name
Returns:
the first matching element or null if no such element exists

nodeListToNodeArray

public static Node[] nodeListToNodeArray(NodeList list)
Create an array of nodes from a NodeList.

Parameters:
list - the NodeList
Returns:
array of nodes containing the same members as list

elementArrayListToElementArray

public static Element[] elementArrayListToElementArray(ArrayList arrayList)
Create an array of Elements from an ArrayList containing only Elements.

Parameters:
arrayList - the list
Returns:
array containing the same members as the arrayList

elementImplArrayListToElementImplArray

public static ElementImpl[] elementImplArrayListToElementImplArray(ArrayList arrayList)
creates an array of ElementImpls from an ArrayList containing only ElementImpls.

Parameters:
arrayList - the list
Returns:
array of ElementImpls containing the same members as the parameter

getAssociationValue

public static String getAssociationValue(Element element)
Get the value of the first <association> element found under the passed element.

Parameters:
element - the element
Returns:
association value (possibly empty, but never null)

getAssociationValueEx

public static String getAssociationValueEx(ElementImpl element)
Get the value of the first <association> element found under the passed element.

Parameters:
element - the element
Returns:
association value (possibly empty, but never null)

getAssociationState

public static String getAssociationState(Element element)
Get the value of the "state" attribute of the first <association> element found under the passed element.

Parameters:
element - the element
Returns:
association state (possibly empty, but never null)

getAssociationStateEx

public static String getAssociationStateEx(ElementImpl element)
Get the value of the "state" attribute of the first <association> element found under the passed element.

Parameters:
element - the element
Returns:
association state (possibly empty, but never null)

getFirstValue

public static Element getFirstValue(Node node,
                                    String attrName)
Get the first <value> element for the passed directory attribute.

Parameters:
node - the node at which to start
attrName - the directory attribute name
Returns:
the first matching <value> element or null if no such element exists

getFirstValueEx

public static ElementImpl getFirstValueEx(NodeImpl node,
                                          String attrName)
Get the first <value> element for the passed directory attribute.

Parameters:
node - the node at which to start
attrName - the directory attribute name
Returns:
the first matching <value> element or null if no such element exists

copyAttributeNS

public static boolean copyAttributeNS(Element src,
                                      String attrNamespaceURI,
                                      String attrLocalName,
                                      Element dest)
Copy an attribute from one element to another, but only if the attribute has a non-empty value

Parameters:
src - source element
attrNamespaceURI - the namespace URI of the attribute's qualified name
attrLocalPart - the local part of the attribute's qualified name
dest - destination element
Returns:
true if an attribute was copied

copyAttributeEx

public static boolean copyAttributeEx(ElementImpl src,
                                      ExpandedQName attrName,
                                      ElementImpl dest)
Copy an attribute from one element to another, but only if the attribute has a non-empty value.

Parameters:
src - source element containing the attribute to copy
attrName - QName of the attribute
dest - destination element for the attribute
Returns:
true if an attribute was copied

copyAttributeNS

public static boolean copyAttributeNS(Element src,
                                      String srcAttrNamespaceURI,
                                      String srcAttrLocalPart,
                                      Element dest,
                                      String destAttrNamespaceURI,
                                      String destAttrQName)
Copy an attribute from one element to another, with an new attribute name, but only if the attribute has a non-empty value.

Parameters:
src - source element
srcAttrNamespaceURI - the namespace URI of the source attribute's qualified name
srcAttrLocalPart - the local part of the source attribute's qualified name
dest - destination element
destAttrNamespaceURI - the namespace URI of the destination attribute's qualified name
destAttrQName - "[prefix:]local part" of the destination attribute's qualified name
Returns:
true if an attribute was copied

copyAttributeEx

public static boolean copyAttributeEx(ElementImpl src,
                                      ExpandedQName srcAttrName,
                                      ElementImpl dest,
                                      ExpandedQName destAttrName)
Copy an attribute from one element to another, but only if the attribute has a non-empty value.

Parameters:
src - source element containing the attribute to copy
srcAttrName - QName of the source attribute
dest - destination element for the attribute
destAttrName - QName of the destination attribute
Returns:
true if there was an attribute to copy

ensureDOMImpl

public static void ensureDOMImpl(XmlDocument src)
Conditionally convert the passed document to the DirXML DOM implementation.

Parameters:
src - document

getTimestamp

public static Date getTimestamp(Element element)
Get a Date instance from the timestamp attribute for an element

Parameters:
element - the element containing the "timestamp" attribute
Returns:
timestamp if available, null otherwise

getTimestampEx

public static Date getTimestampEx(ElementImpl element)
Get a Date instance from the timestamp attribute for an element

Parameters:
element - the element containing the "timestamp" attribute
Returns:
timestamp if available, null otherwise

getTimestampEventCount

public static int getTimestampEventCount(Element element)
Get the timestamp event count from the timestamp attribute for an element

Parameters:
element - an element containing the "timestamp" attribute
Returns:
timestamp event count if available, 0 otherwise

getTimestampEventCountEx

public static int getTimestampEventCountEx(ElementImpl element)
Get the timestamp event count from the timestamp attribute for an element

Parameters:
element - an element containing the "timestamp" attribute
Returns:
timestamp event count if available, 0 otherwise