org.jvoicexml.xml
Class XmlDocument

java.lang.Object
  extended by org.jvoicexml.xml.XmlDocument
All Implemented Interfaces:
Serializable, Document, Node
Direct Known Subclasses:
CcxmlDocument, PlsDocument, SrgsXmlDocument, SsmlDocument, VoiceXmlDocument

public abstract class XmlDocument
extends Object
implements Document, Serializable

An XML Document abstract base class.

VoiceXML is designed for creating audio dialogs that feature synthesized speech, digitized audio, recognition of spoken and DTMF key input, recording of spoken input, telephony and mixed initiative conversations. Its major goal is to bring the advantages of web-based development and content delivery to interactive voice response applications.

Objects of this class can create such VoiceXML documents or parse them.

The encoding can be controlled via the jvoicexml.xml.encoding environment property. The default value is UTF-8.

Entities are not resolved by default. The bahavior can be controlled via the system property org.jvoicexml.resolveEntities.

Version:
$Revision: 2592 $
Author:
Steve Doyle, Dirk Schnelle-Walka
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
XmlDocument()
          Creates an empty XML document.
XmlDocument(Document doc)
          Construct a new XML document with the given document.
XmlDocument(InputSource source)
          Constructs a new XML document from the given input source.
 
Method Summary
 Node adoptNode(Node source)
          Attempts to adopt a node from another document to this document.
 Node appendChild(Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 short compareDocumentPosition(Node other)
          Compares the reference node, i.e.
 Attr createAttribute(String name)
          Creates an Attr of the given name.
 Attr createAttributeNS(String namespaceURI, String qualifiedName)
          Creates an attribute of the given qualified name and namespace URI.
 CDATASection createCDATASection(String data)
          Creates a CDATASection node whose value is the specified string.
 Comment createComment(String data)
          Creates a Comment node given the specified string.
 DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 Element createElement(String tagName)
          Creates an element of the type specified.
 Element createElementNS(String namespaceURI, String qualifiedName)
          Creates an element of the given qualified name and namespace URI.
 EntityReference createEntityReference(String name)
          Creates an EntityReference object.
 ProcessingInstruction createProcessingInstruction(String target, String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
protected abstract  Node createRootNode()
          Create the root node of the document.
 Text createTextNode(String data)
          Creates a Text node given the specified string.
 NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 String getBaseURI()
          The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
protected abstract  String getDefaultNamespaceURI()
          Retrieves the default namespace.
 DocumentType getDoctype()
          Retrieves the Document Type Declaration associated with this document.
protected  Document getDocument()
          Retrieves the encapsulated document.
 Element getDocumentElement()
          This is a convenience attribute that allows direct access to the child node that is the root element of the document.
 String getDocumentURI()
          The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.
 DOMConfiguration getDomConfig()
          The configuration used when Document.normalizeDocument() is invoked.
 Element getElementById(String elementId)
          Returns the Element whose ID is given by elementId.
 NodeList getElementsByTagName(String tagname)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
          Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
 Object getFeature(String feature, String version)
          This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .
 Node getFirstChild()
          The first child of this node.
 DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 String getInputEncoding()
          An attribute specifying the encoding used for this document at the time of the parsing.
 Node getLastChild()
          The last child of this node.
 String getLocalName()
          Returns the local part of the qualified name of this node.
 String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 Node getNextSibling()
          The node immediately following this node.
 String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 String getNodeValue()
          The value of this node, depending on its type; see the table above.
 Document getOwnerDocument()
          The Document object associated with this node.
 Node getParentNode()
          The parent of this node.
 String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 Node getPreviousSibling()
          The node immediately preceding this node.
 boolean getStrictErrorChecking()
          An attribute specifying whether error checking is enforced or not.
 String getTextContent()
          This attribute returns the text content of this node and its descendants.
 Object getUserData(String key)
          Retrieves the object associated to a key on a this node.
 String getXmlEncoding()
          An attribute specifying, as part of the XML declaration, the encoding of this document.
protected  Node getXmlNode(Node node)
          Get the XmlNode object corresponding to the node.
protected abstract  XmlNodeFactory<?> getXmlNodefactory()
          Retrieves the node factory for child node lists.
protected abstract  NodeList getXmlNodeList(NodeList nodeList)
          Get the XmlNodeList object corresponding to the nodelist.
 boolean getXmlStandalone()
          An attribute specifying, as part of the XML declaration, whether this document is standalone.
 String getXmlVersion()
          An attribute specifying, as part of the XML declaration, the version number of this document.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node importNode(Node importedNode, boolean deep)
          Imports a node from another document to this document.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 boolean isDefaultNamespace(String namespaceURI)
          This method checks if the specified namespaceURI is the default namespace or not.
 boolean isEqualNode(Node arg)
          Tests whether two nodes are equal.
 boolean isSameNode(Node other)
          Returns whether this node is the same node as the given one.
 boolean isSupported(String feature, String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 String lookupNamespaceURI(String prefix)
          Look up the namespace URI associated to the given prefix, starting from this node.
 String lookupPrefix(String namespaceURI)
          Look up the prefix associated to the given namespace URI, starting from this node.
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 void normalizeDocument()
          This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.
 Node removeChild(Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 Node renameNode(Node n, String namespaceURI, String qualifiedName)
          Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.
 Node replaceChild(Node newChild, Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setDocumentURI(String documentURI)
          The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.
 void setNodeValue(String nodeValue)
          The value of this node, depending on its type; see the table above.
 void setPrefix(String prefix)
          The namespace prefix of this node, or null if it is unspecified.
 void setStrictErrorChecking(boolean strictErrorChecking)
          An attribute specifying whether error checking is enforced or not.
 void setTextContent(String textContent)
          This attribute returns the text content of this node and its descendants.
 Object setUserData(String key, Object data, UserDataHandler handler)
          Associate an object to a key on this node.
 void setXmlStandalone(boolean xmlStandalone)
          An attribute specifying, as part of the XML declaration, whether this document is standalone.
 void setXmlVersion(String xmlVersion)
          An attribute specifying, as part of the XML declaration, the version number of this document.
 String toString()
           Creates a representation as an XML string.
 String toXml()
          Returns the contents of this object as an XML formatted string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlDocument

public XmlDocument()
            throws ParserConfigurationException
Creates an empty XML document.

Throws:
ParserConfigurationException - Error creating the document builder.

XmlDocument

public XmlDocument(InputSource source)
            throws ParserConfigurationException,
                   SAXException,
                   IOException
Constructs a new XML document from the given input source.

Parameters:
source - Input source for a single XML document.
Throws:
ParserConfigurationException - Error creating the document builder.
SAXException - Error parsing the input source.
IOException - Error reading the input source.

XmlDocument

public XmlDocument(Document doc)
Construct a new XML document with the given document.

Parameters:
doc - Encapsulated document.
Method Detail

getDocument

protected final Document getDocument()
Retrieves the encapsulated document.

Returns:
The encapsulated document.

getXmlNodefactory

protected abstract XmlNodeFactory<?> getXmlNodefactory()
Retrieves the node factory for child node lists.

Returns:
Node factory for child node lists.
Since:
0.5

createRootNode

protected abstract Node createRootNode()
Create the root node of the document.

Returns:
Root node

appendChild

public final Node appendChild(Node newChild)
Adds the node newChild to the end of the list of children of this node.

Specified by:
appendChild in interface Node
Parameters:
newChild - The node to add.If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node
Returns:
The node added.

cloneNode

public final Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.

Specified by:
cloneNode in interface Node
Parameters:
deep - If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
Returns:
The duplicate node.

createAttribute

public final Attr createAttribute(String name)
Creates an Attr of the given name.

Specified by:
createAttribute in interface Document
Parameters:
name - The name of the attribute.
Returns:
A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.

createAttributeNS

public final Attr createAttributeNS(String namespaceURI,
                                    String qualifiedName)
Creates an attribute of the given qualified name and namespace URI.

Specified by:
createAttributeNS in interface Document
Parameters:
namespaceURI - The namespace URI of the attribute to create.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
A new Attr object with the following attributes:
Attribute Value
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName local name, extracted from qualifiedName
Attr.name qualifiedName
Node.nodeValue the empty string

createCDATASection

public final CDATASection createCDATASection(String data)
Creates a CDATASection node whose value is the specified string.

Specified by:
createCDATASection in interface Document
Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.

createComment

public final Comment createComment(String data)
Creates a Comment node given the specified string.

Specified by:
createComment in interface Document
Parameters:
data - The data for the node.
Returns:
The new Comment object.

createDocumentFragment

public final DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment object.

Specified by:
createDocumentFragment in interface Document
Returns:
A new DocumentFragment.

createElement

public final Element createElement(String tagName)
Creates an element of the type specified.

Specified by:
createElement in interface Document
Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.

createElementNS

public final Element createElementNS(String namespaceURI,
                                     String qualifiedName)
Creates an element of the given qualified name and namespace URI.

Specified by:
createElementNS in interface Document
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new Element object with the following attributes:
Attribute Value
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName local name, extracted from qualifiedName
Element.tagName qualifiedName

createEntityReference

public final EntityReference createEntityReference(String name)
Creates an EntityReference object.

Specified by:
createEntityReference in interface Document
Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.

createProcessingInstruction

public final ProcessingInstruction createProcessingInstruction(String target,
                                                               String data)
Creates a ProcessingInstruction node given the specified name and data strings.

Specified by:
createProcessingInstruction in interface Document
Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.

createTextNode

public final Text createTextNode(String data)
Creates a Text node given the specified string.

Specified by:
createTextNode in interface Document
Parameters:
data - The data for the node.
Returns:
The new Text object.

getAttributes

public final NamedNodeMap getAttributes()
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface Node
Returns:
NamedNodeMap

getChildNodes

public final NodeList getChildNodes()
A NodeList that contains all children of this node.

Specified by:
getChildNodes in interface Node
Returns:
NodeList

getDoctype

public DocumentType getDoctype()
Retrieves the Document Type Declaration associated with this document. null if there is none

Specified by:
getDoctype in interface Document
Returns:
the associated document type
See Also:
DocumentType

getDocumentElement

public final Element getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document.

Specified by:
getDocumentElement in interface Document
Returns:
Element

getElementById

public final Element getElementById(String elementId)
Returns the Element whose ID is given by elementId.

Specified by:
getElementById in interface Document
Parameters:
elementId - The unique id value for an element.
Returns:
The matching element.

getElementsByTagName

public final NodeList getElementsByTagName(String tagname)
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagName in interface Document
Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements.

getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagNameNS in interface Document
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.

getXmlNode

protected final Node getXmlNode(Node node)
Get the XmlNode object corresponding to the node.

Parameters:
node - - Node to convert to an XmlNode
Returns:
XmlNode representing the node.

getXmlNodeList

protected abstract NodeList getXmlNodeList(NodeList nodeList)
Get the XmlNodeList object corresponding to the nodelist.

Parameters:
nodeList - - Node to convert to an XmlNodeList
Returns:
XmlNodeList representing the node.

getFirstChild

public final Node getFirstChild()
The first child of this node.

Specified by:
getFirstChild in interface Node
Returns:
Node

getImplementation

public final DOMImplementation getImplementation()
The DOMImplementation object that handles this document.

Specified by:
getImplementation in interface Document
Returns:
DOMImplementation

getLastChild

public final Node getLastChild()
The last child of this node.

Specified by:
getLastChild in interface Node
Returns:
Node

getLocalName

public final String getLocalName()
Returns the local part of the qualified name of this node.

Specified by:
getLocalName in interface Node
Returns:
String

getNamespaceURI

public final String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.

Specified by:
getNamespaceURI in interface Node
Returns:
String

getDefaultNamespaceURI

protected abstract String getDefaultNamespaceURI()
Retrieves the default namespace.

Returns:
the default namespace, never null.
Since:
0.7.5

getNextSibling

public final Node getNextSibling()
The node immediately following this node.

Specified by:
getNextSibling in interface Node
Returns:
Node

getNodeName

public final String getNodeName()
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface Node
Returns:
String

getNodeType

public final short getNodeType()
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface Node
Returns:
short

getNodeValue

public final String getNodeValue()
The value of this node, depending on its type; see the table above.

Specified by:
getNodeValue in interface Node
Returns:
String

getOwnerDocument

public final Document getOwnerDocument()
The Document object associated with this node.

Specified by:
getOwnerDocument in interface Node
Returns:
Document

getParentNode

public final Node getParentNode()
The parent of this node.

Specified by:
getParentNode in interface Node
Returns:
Node

getPrefix

public final String getPrefix()
The namespace prefix of this node, or null if it is unspecified.

Specified by:
getPrefix in interface Node
Returns:
String

getPreviousSibling

public final Node getPreviousSibling()
The node immediately preceding this node.

Specified by:
getPreviousSibling in interface Node
Returns:
Node

hasAttributes

public final boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes.

Specified by:
hasAttributes in interface Node
Returns:
true if this node has any attributes, false otherwise.

hasChildNodes

public final boolean hasChildNodes()
Returns whether this node has any children.

Specified by:
hasChildNodes in interface Node
Returns:
true if this node has any children, false otherwise.

importNode

public final Node importNode(Node importedNode,
                             boolean deep)
Imports a node from another document to this document.

Specified by:
importNode in interface Document
Parameters:
importedNode - The node to import.
deep - If true, recursively import the subtree under the specified node; if false, import only the node itself, as explained above. This has no effect on Attr , EntityReference, and Notation nodes.
Returns:
The imported node that belongs to this Document.

getInputEncoding

public final String getInputEncoding()
An attribute specifying the encoding used for this document at the time of the parsing.

Specified by:
getInputEncoding in interface Document
Returns:
String

getXmlEncoding

public final String getXmlEncoding()
An attribute specifying, as part of the XML declaration, the encoding of this document.

Specified by:
getXmlEncoding in interface Document
Returns:
String

getXmlStandalone

public final boolean getXmlStandalone()
An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
getXmlStandalone in interface Document
Returns:
boolean

setXmlStandalone

public final void setXmlStandalone(boolean xmlStandalone)
An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
setXmlStandalone in interface Document
Parameters:
xmlStandalone - boolean

getXmlVersion

public final String getXmlVersion()
An attribute specifying, as part of the XML declaration, the version number of this document.

Specified by:
getXmlVersion in interface Document
Returns:
String

setXmlVersion

public final void setXmlVersion(String xmlVersion)
An attribute specifying, as part of the XML declaration, the version number of this document.

Specified by:
setXmlVersion in interface Document
Parameters:
xmlVersion - String

getStrictErrorChecking

public final boolean getStrictErrorChecking()
An attribute specifying whether error checking is enforced or not.

Specified by:
getStrictErrorChecking in interface Document
Returns:
boolean

setStrictErrorChecking

public final void setStrictErrorChecking(boolean strictErrorChecking)
An attribute specifying whether error checking is enforced or not.

Specified by:
setStrictErrorChecking in interface Document
Parameters:
strictErrorChecking - boolean

getDocumentURI

public final String getDocumentURI()
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.

Specified by:
getDocumentURI in interface Document
Returns:
String

setDocumentURI

public final void setDocumentURI(String documentURI)
The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.

Specified by:
setDocumentURI in interface Document
Parameters:
documentURI - String

adoptNode

public final Node adoptNode(Node source)
Attempts to adopt a node from another document to this document.

Specified by:
adoptNode in interface Document
Parameters:
source - The node to move into this document.
Returns:
The adopted node, or null if this operation fails, such as when the source node comes from a different implementation.

getDomConfig

public final DOMConfiguration getDomConfig()
The configuration used when Document.normalizeDocument() is invoked.

Specified by:
getDomConfig in interface Document
Returns:
DOMConfiguration

normalizeDocument

public final void normalizeDocument()
This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form.

Specified by:
normalizeDocument in interface Document

renameNode

public final Node renameNode(Node n,
                             String namespaceURI,
                             String qualifiedName)
Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.

Specified by:
renameNode in interface Document
Parameters:
n - The node to rename.
namespaceURI - The new namespace URI.
qualifiedName - The new qualified name.
Returns:
The renamed node. This is either the specified node or the new node that was created to replace the specified node.

insertBefore

public final Node insertBefore(Node newChild,
                               Node refChild)
Inserts the node newChild before the existing child node refChild.

Specified by:
insertBefore in interface Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.

isSupported

public final boolean isSupported(String feature,
                                 String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Specified by:
isSupported in interface Node
Parameters:
feature - The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation.
version - This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true.
Returns:
Returns true if the specified feature is supported on this node, false otherwise.

normalize

public final void normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.

Specified by:
normalize in interface Node

removeChild

public final Node removeChild(Node oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface Node
Parameters:
oldChild - The node being removed.
Returns:
The node removed.

replaceChild

public final Node replaceChild(Node newChild,
                               Node oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.

Specified by:
replaceChild in interface Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.

setNodeValue

public final void setNodeValue(String nodeValue)
The value of this node, depending on its type; see the table above.

Specified by:
setNodeValue in interface Node
Parameters:
nodeValue - String

setPrefix

public final void setPrefix(String prefix)
The namespace prefix of this node, or null if it is unspecified.

Specified by:
setPrefix in interface Node
Parameters:
prefix - String

getBaseURI

public final String getBaseURI()
The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.

Specified by:
getBaseURI in interface Node
Returns:
String

compareDocumentPosition

public final short compareDocumentPosition(Node other)
Compares the reference node, i.e.

Specified by:
compareDocumentPosition in interface Node
Parameters:
other - The node to compare against the reference node.
Returns:
Returns how the node is positioned relatively to the reference node.

getTextContent

public final String getTextContent()
This attribute returns the text content of this node and its descendants.

Specified by:
getTextContent in interface Node
Returns:
String

setTextContent

public final void setTextContent(String textContent)
This attribute returns the text content of this node and its descendants.

Specified by:
setTextContent in interface Node
Parameters:
textContent - String

isSameNode

public final boolean isSameNode(Node other)
Returns whether this node is the same node as the given one.

Specified by:
isSameNode in interface Node
Parameters:
other - The node to test against.
Returns:
Returns true if the nodes are the same, false otherwise.

lookupPrefix

public final String lookupPrefix(String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node.

Specified by:
lookupPrefix in interface Node
Parameters:
namespaceURI - The namespace URI to look for.
Returns:
Returns an associated namespace prefix if found or null if none is found. If more than one prefix are associated to the namespace prefix, the returned namespace prefix is implementation dependent.

isDefaultNamespace

public final boolean isDefaultNamespace(String namespaceURI)
This method checks if the specified namespaceURI is the default namespace or not.

Specified by:
isDefaultNamespace in interface Node
Parameters:
namespaceURI - The namespace URI to look for.
Returns:
Returns true if the specified namespaceURI is the default namespace, false otherwise.

lookupNamespaceURI

public final String lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.

Specified by:
lookupNamespaceURI in interface Node
Parameters:
prefix - The prefix to look for. If this parameter is null, the method will return the default namespace URI if any.
Returns:
Returns the associated namespace URI or null if none is found.

isEqualNode

public final boolean isEqualNode(Node arg)
Tests whether two nodes are equal.

Specified by:
isEqualNode in interface Node
Parameters:
arg - The node to compare equality with.
Returns:
Returns true if the nodes are equal, false otherwise.

getFeature

public final Object getFeature(String feature,
                               String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .

Specified by:
getFeature in interface Node
Parameters:
feature - The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.
version - This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the Node interface, it must delegate to the primary core Node and not return results inconsistent with the primary core Node such as attributes, childNodes, etc.

setUserData

public final Object setUserData(String key,
                                Object data,
                                UserDataHandler handler)
Associate an object to a key on this node.

Specified by:
setUserData in interface Node
Parameters:
key - The key to associate the object to.
data - The object to associate to the given key, or null to remove any existing association to that key.
handler - The handler to associate to that key, or null.
Returns:
Returns the DOMUserData previously associated to the given key on this node, or null if there was none.

getUserData

public final Object getUserData(String key)
Retrieves the object associated to a key on a this node.

Specified by:
getUserData in interface Node
Parameters:
key - The key the object is associated to.
Returns:
Returns the DOMUserData associated to the given key on this node, or null if there was none.

toXml

public final String toXml()
                   throws IOException
Returns the contents of this object as an XML formatted string.

Returns:
XML representation of this object.
Throws:
IOException - Error writing to the writer.

toString

public final String toString()
Creates a representation as an XML string. If this is not possible for some reason, the conventional toString creation is used.

Overrides:
toString in class Object
Since:
0.3


Copyright © 2005-2009JVoiceXML group.