xades4j.utils
Class DOMHelper

java.lang.Object
  extended by xades4j.utils.DOMHelper

public class DOMHelper
extends Object

Utility methods for DOM nodes.

Author:
Luís

Method Summary
static Element createElement(Document doc, String name, String prefix, String namespaceURI)
          Creates an element on the given document.
static Element createElementInTempDocument(String name, String prefix, String namespaceURI)
           
static Element getFirstChildElement(Node node)
          Gets the first child element of a node.
static Element getFirstDescendant(Element e, String nameSpace, String localName)
          Gets the first element with the specified qualified name that is descendant of e.
static Element getLastChildElement(Node node)
          Gets the last child element of a node.
static Element getNextSiblingElement(Node node)
          Gets the next sibling of a node that is an element.
static Document getOwnerDocument(Node node)
          Gets the owner document of a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOwnerDocument

public static Document getOwnerDocument(Node node)
Gets the owner document of a node.

Parameters:
node - the node
Returns:
the node's document or the node itself if it is a document node
Throws:
NullPointerException - if node is null

createElement

public static Element createElement(Document doc,
                                    String name,
                                    String prefix,
                                    String namespaceURI)
Creates an element on the given document. Exceptions are as in Document.createElementNS(java.lang.String, java.lang.String). The qualified name is obtained by prefix:name if the prefix is not null.

Parameters:
doc - the owner document
name - the element's local name
prefix - the element's prefix (may be null)
namespaceURI - the element's uri (null for no namespace)
Returns:
the created element
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createElementInTempDocument

public static Element createElementInTempDocument(String name,
                                                  String prefix,
                                                  String namespaceURI)

getFirstChildElement

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

Parameters:
node - the node to get the child from
Returns:
the first element child of node or null if none
Throws:
NullPointerException - if node is null

getLastChildElement

public static Element getLastChildElement(Node node)
Gets the last child element of a node.

Parameters:
node - the node to get the child from
Returns:
the last element child of node or null if none
Throws:
NullPointerException - if node is null

getNextSiblingElement

public static Element getNextSiblingElement(Node node)
Gets the next sibling of a node that is an element.

Parameters:
node - the node
Returns:
the next sibling element or null if none
Throws:
NullPointerException - if node is null

getFirstDescendant

public static Element getFirstDescendant(Element e,
                                         String nameSpace,
                                         String localName)
Gets the first element with the specified qualified name that is descendant of e.

Returns:
the element or null if there is no such element


Copyright © 2012. All Rights Reserved.