org.enhydra.xml.dom
Class DOMOps

java.lang.Object
  |
  +--org.enhydra.xml.dom.DOMOps

public final class DOMOps
extends Object

Various static methods the do simple operations on the DOM.


Method Summary
static Node adoptNode(Document doc, Node node)
          Deprecated. no replacement - use DOM3 Document.adoptNode(Node) instead
static int countChildren(Node node)
          Count the number of children in a node has.
static Node getActualNode(Node node)
          Get the real DOM node, bypassing an XMLC-generated container.
static Document getDocument(Node node)
          Get the owner document object for a node.
static String getEncoding(Document doc)
          Deprecated. no replacement - use DOM3 Document.getXmlEncoding() instead
static String getEncoding(Entity entity)
          Deprecated. no replacement - use DOM3 Entity.getXmlEncoding() instead
static boolean getStandalone(Document doc)
          Deprecated. no replacement - use DOM3 Document.getXmlStandalone() instead
static boolean getStrictErrorChecking(Document doc)
          Deprecated. no replacement - use DOM3 Document.getStrictErrorChecking() instead
static String getVersion(Document doc)
          Deprecated. no replacement - use DOM3 Document.getXmlVersion() instead
static boolean isLazyDOMInstance(Document doc)
          Determine if a document is a LazyDOM instance document.
static boolean isNodeOfType(Node node, short ofType)
          Provides null-safe, inline evaluation of the node type.
static Node replaceNode(Node srcNode, Node destNode)
          Replace a node with one imported from another document.
static void setEncoding(Document doc, String enc)
          Deprecated. Xerces DOM Internal - normally Read-only - corresponds to Document.getXmlEncoding() which, itself, has no corresponding public mutator (was part of early DOM3 draft, but removed in the final specification)
static void setEncoding(Entity entity, String enc)
          Deprecated. no replacement - Read-only - part of early DOM3 draft but removed in final DOM3 specification
static void setStandalone(Document doc, boolean val)
          Deprecated. no replacement - use DOM3 Document.setXmlStandalone(boolean) instead
static void setStrictErrorChecking(Document doc, boolean val)
          Deprecated. no replacement - use DOM3 Document.setStrictErrorChecking(boolean) instead
static void setVersion(Document doc, String version)
          Deprecated. no replacement - use DOM3 Document.setXmlVersion(String) instead
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocument

public static Document getDocument(Node node)
Get the owner document object for a node. This gets the actual document. If a XMLC document class instance the contained document is returned.

getActualNode

public static Node getActualNode(Node node)
Get the real DOM node, bypassing an XMLC-generated container. If a XMLC document class instance the contained document is returned. Otherwise the node is returned.

replaceNode

public static Node replaceNode(Node srcNode,
                               Node destNode)
Replace a node with one imported from another document.
Parameters:
srcNode - The node to clone and insert
destNode - The node to be replaced
Returns:
The new node that replaces the destination node.

countChildren

public static int countChildren(Node node)
Count the number of children in a node has.

isLazyDOMInstance

public static boolean isLazyDOMInstance(Document doc)
Determine if a document is a LazyDOM instance document.
Returns:
true if its a LazyDOM instance, false if its a LazyDOM template or not a LazyDOM at all.

getStandalone

public static boolean getStandalone(Document doc)
Deprecated. no replacement - use DOM3 Document.getXmlStandalone() instead

Call Document#getStandalone() on doc if supported. By using reflection, this method avoids problems when Document.getStandalone() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
Returns:
true if the document is standalone, false else
Throws:
UnsupportedOperationException - if doc does not support the method

setStandalone

public static void setStandalone(Document doc,
                                 boolean val)
Deprecated. no replacement - use DOM3 Document.setXmlStandalone(boolean) instead

Call Document#setStandalone(val) on doc if supported. By using reflection, this method avoids problems when Document.setStandalone() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
val - the new value
Throws:
UnsupportedOperationException - if doc does not support the method

getEncoding

public static String getEncoding(Document doc)
Deprecated. no replacement - use DOM3 Document.getXmlEncoding() instead

Call Document#getEncoding() on doc if supported. By using reflection, this method avoids problems when Document.getEncoding() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
Returns:
the encoding
Throws:
UnsupportedOperationException - if doc does not support the method

setEncoding

public static void setEncoding(Document doc,
                               String enc)
Deprecated. Xerces DOM Internal - normally Read-only - corresponds to Document.getXmlEncoding() which, itself, has no corresponding public mutator (was part of early DOM3 draft, but removed in the final specification)

Call Document#setEncoding(enc) on doc if supported. By using reflection, this method avoids problems when Document.setEncoding() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
enc - the encoding
Returns:
the encoding
Throws:
UnsupportedOperationException - if doc does not support the method

getStrictErrorChecking

public static boolean getStrictErrorChecking(Document doc)
Deprecated. no replacement - use DOM3 Document.getStrictErrorChecking() instead

Call Document#getStrictErrorChecking() on doc if supported. By using reflection, this method avoids problems when Document.getStrictErrorChecking() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
Returns:
true if the document has strict error checking, false else
Throws:
UnsupportedOperationException - if doc does not support the method

setStrictErrorChecking

public static void setStrictErrorChecking(Document doc,
                                          boolean val)
Deprecated. no replacement - use DOM3 Document.setStrictErrorChecking(boolean) instead

Call Document#setStrictErrorChecking(val) on doc if supported. By using reflection, this method avoids problems when Document.setStrictErrorChecking() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
val - the new value
Throws:
UnsupportedOperationException - if doc does not support the method

getVersion

public static String getVersion(Document doc)
Deprecated. no replacement - use DOM3 Document.getXmlVersion() instead

Call Document#getVersion() on doc if supported. By using reflection, this method avoids problems when Document.getVersion() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
Returns:
the version
Throws:
UnsupportedOperationException - if doc does not support the method

setVersion

public static void setVersion(Document doc,
                              String version)
Deprecated. no replacement - use DOM3 Document.setXmlVersion(String) instead

Call Document#setVersion(version) on doc if supported. By using reflection, this method avoids problems when Document.setVersion() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
version - the version
Returns:
the version
Throws:
UnsupportedOperationException - if doc does not support the method

adoptNode

public static Node adoptNode(Document doc,
                             Node node)
                      throws DOMException
Deprecated. no replacement - use DOM3 Document.adoptNode(Node) instead

Call Document#adoptNode(node) on doc if supported. By using reflection, this method avoids problems when Document.adoptNode() is not supported by the given implementation of org.w3c.dom.Document (e.g. the one provided by JDK 1.4).
Parameters:
doc - the document
node - the node
Returns:
the adopted node, or null if this operation fails, such as when the source node comes from a different implementation.
Throws:
UnsupportedOperationException - if doc does not support the method
DOMException - NOT_SUPPORTED_ERR: Raised if the source node is of type DOCUMENT, DOCUMENT_TYPE. NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly.

getEncoding

public static String getEncoding(Entity entity)
Deprecated. no replacement - use DOM3 Entity.getXmlEncoding() instead

Call Entity#getEncoding on entity if supported. By using reflection, this method avoids problems when Entity.getEncoding() is not supported by the given implementation of org.w3c.dom.Entity (e.g. the one provided by JDK 1.4).
Parameters:
entity - the entity
Returns:
the encoding
Throws:
UnsupportedOperationException - if entity does not support the method

setEncoding

public static void setEncoding(Entity entity,
                               String enc)
Deprecated. no replacement - Read-only - part of early DOM3 draft but removed in final DOM3 specification

Call Entity#setEncoding(enc) on entity if supported. By using reflection, this method avoids problems when Entity.setEncoding() is not supported by the given implementation of org.w3c.dom.Entity (e.g. the one provided by JDK 1.4).
Parameters:
entity - the entity
enc - the encoding
Returns:
the encoding
Throws:
UnsupportedOperationException - if entity does not support the method

isNodeOfType

public static boolean isNodeOfType(Node node,
                                   short ofType)
Provides null-safe, inline evaluation of the node type. Use this method instead of null-safe, though heavyweight, instanceof comparisons.
Parameters:
node - the node for which to check the type
ofType - any one of the static short constants provided by org.w3c.dom.Node, eg.. Node.DOCUMENT_NODE, Node.TEXT_NODE, etc...
Returns:
true if node is non-null and node.getNodeType() matches the provided type, otherwise false


Copyright © 1999-2007 enhydra.org (Mark Diekhans, David Li, Richard Kunze, Jacob Kjome). All Rights reserved.