org.apache.xml.dtm.ref

Class DTMNodeProxy

Implemented Interfaces:
Attr, Comment, Document, DocumentFragment, Element, Node, ProcessingInstruction, Text

public class DTMNodeProxy
extends Object
implements Node, Document, Text, Element, Attr, ProcessingInstruction, Comment, DocumentFragment

DTMNodeProxy presents a DOM Node API front-end to the DTM model.

It does _not_ attempt to address the "node identity" question; no effort is made to prevent the creation of multiple proxies referring to a single DTM node. Users can create a mechanism for managing this, or relinquish the use of "==" and use the .sameNodeAs() mechanism, which is under consideration for future versions of the DOM.

DTMNodeProxy may be subclassed further to present specific DOM node types.

See Also:
org.w3c.dom

Field Summary

DTM
dtm
The DTM for this node.

Constructor Summary

DTMNodeProxy(DTM dtm, int node)
Create a DTMNodeProxy Node representing a specific Node in a DTM

Method Summary

Node
adoptNode(Node source)
NEEDSDOC Method adoptNode NEEDSDOC @param source
Node
appendChild(Node newChild)
void
appendData(String arg)
Node
cloneNode(boolean deep)
short
compareDocumentPosition(Node other)
Attr
createAttribute(String name)
Attr
createAttributeNS(String namespaceURI, String qualifiedName)
CDATASection
createCDATASection(String data)
Comment
createComment(String data)
DocumentFragment
createDocumentFragment()
Element
createElement(String tagName)
Element
createElementNS(String namespaceURI, String qualifiedName)
EntityReference
createEntityReference(String name)
ProcessingInstruction
createProcessingInstruction(String target, String data)
Text
createTextNode(String data)
void
deleteData(int offset, int count)
boolean
equals(Node node)
Test for equality based on node number.
boolean
equals(Object node)
Test for equality based on node number.
String
getAttribute(String name)
String
getAttributeNS(String namespaceURI, String localName)
Attr
getAttributeNode(String name)
Attr
getAttributeNodeNS(String namespaceURI, String localName)
NamedNodeMap
getAttributes()
String
getBaseURI()
NodeList
getChildNodes()
DTM
getDTM()
NON-DOM: Return the DTM model
int
getDTMNodeNumber()
NON-DOM: Return the DTM node number
String
getData()
DocumentType
getDoctype()
Element
getDocumentElement()
This is a bit of a problem in DTM, since a DTM may be a Document Fragment and hence not have a clear-cut Document Element.
String
getDocumentURI()
DOMConfiguration
getDomConfig()
Element
getElementById(String elementId)
NodeList
getElementsByTagName(String tagname)
NodeList
getElementsByTagNameNS(String namespaceURI, String localName)
String
getEncoding()
EXPERIMENTAL!
Object
getFeature(String feature, String version)
Node
getFirstChild()
DOMImplementation
getImplementation()
String
getInputEncoding()
Node
getLastChild()
int
getLength()
String
getLocalName()
String
getName()
String
getNamespaceURI()
Node
getNextSibling()
String
getNodeName()
short
getNodeType()
String
getNodeValue()
Document
getOwnerDocument()
Element
getOwnerElement()
Get the owner element of an attribute.
Node
getOwnerNode()
Node
getParentNode()
String
getPrefix()
Node
getPreviousSibling()
TypeInfo
getSchemaTypeInfo()
boolean
getSpecified()
boolean
getStandalone()
EXPERIMENTAL!
boolean
getStrictErrorChecking()
EXPERIMENTAL!
String
getStringValue()
String
getTagName()
String
getTarget()
A PI's "target" states what processor channel the PI's data should be directed to.
String
getTextContent()
Object
getUserData(String key)
String
getValue()
String
getVersion()
EXPERIMENTAL!
String
getWholeText()
String
getXmlEncoding()
boolean
getXmlStandalone()
String
getXmlVersion()
boolean
hasAttribute(String name)
Method hasAttribute
boolean
hasAttributeNS(String name, String x)
Method hasAttributeNS
boolean
hasAttributes()
Introduced in DOM Level 2.
boolean
hasChildNodes()
Node
importNode(Node importedNode, boolean deep)
Node
insertBefore(Node newChild, Node refChild)
void
insertData(int offset, String arg)
boolean
isDefaultNamespace(String namespaceURI)
boolean
isElementContentWhitespace()
boolean
isEqualNode(Node arg)
boolean
isId()
boolean
isSameNode(Node other)
boolean
isSupported(String feature, String version)
Ask whether we support a given DOM feature.
String
lookupNamespaceURI(String prefix)
String
lookupPrefix(String namespaceURI)
void
normalize()
void
normalizeDocument()
void
removeAttribute(String name)
void
removeAttributeNS(String namespaceURI, String localName)
Attr
removeAttributeNode(Attr oldAttr)
Node
removeChild(Node oldChild)
Node
renameNode(Node node, String namespaceURI, String qualifiedName)
Node
replaceChild(Node newChild, Node oldChild)
void
replaceData(int offset, int count, String arg)
Text
replaceWholeText(String content)
boolean
sameNodeAs(Node other)
FUTURE DOM: Test node identity, in lieu of Node==Node
void
setAttribute(String name, String value)
void
setAttributeNS(String namespaceURI, String qualifiedName, String value)
Attr
setAttributeNode(Attr newAttr)
Attr
setAttributeNodeNS(Attr newAttr)
void
setData(String data)
void
setDocumentURI(String documentURI)
void
setEncoding(String encoding)
EXPERIMENTAL!
void
setIdAttribute(String name, boolean isId)
void
setIdAttributeNS(String namespaceURI, String localName, boolean isId)
void
setIdAttributeNode(Attr idAttr, boolean isId)
void
setNodeValue(String nodeValue)
void
setPrefix(String prefix)
void
setStandalone(boolean standalone)
EXPERIMENTAL!
void
setStrictErrorChecking(boolean strictErrorChecking)
EXPERIMENTAL!
void
setTextContent(String textContent)
Object
setUserData(String key, Object data, UserDataHandler handler)
void
setValue(String value)
void
setVersion(String version)
EXPERIMENTAL!
void
setXmlStandalone(boolean xmlStandalone)
void
setXmlVersion(String xmlVersion)
Text
splitText(int offset)
String
substringData(int offset, int count)
boolean
supports(String feature, String version)
Ask whether we support a given DOM feature.

Field Details

dtm

public DTM dtm
The DTM for this node.

Constructor Details

DTMNodeProxy

public DTMNodeProxy(DTM dtm,
                    int node)
Create a DTMNodeProxy Node representing a specific Node in a DTM
Parameters:
dtm - The DTM Reference, must be non-null.
node - The DTM node handle.

Method Details

adoptNode

public Node adoptNode(Node source)
            throws DOMException
NEEDSDOC Method adoptNode NEEDSDOC @param source

appendChild

public final Node appendChild(Node newChild)
            throws DOMException
Parameters:
newChild -
See Also:
-- DTMNodeProxy is read-only

appendData

public final void appendData(String arg)
            throws DOMException
Parameters:
arg -
See Also:
org.w3c.dom.CharacterData

cloneNode

public final Node cloneNode(boolean deep)
Parameters:
deep -
See Also:
-- DTMNodeProxy is read-only

compareDocumentPosition

public short compareDocumentPosition(Node other)
            throws DOMException

createAttribute

public final Attr createAttribute(String name)
            throws DOMException
Parameters:
name -
See Also:
org.w3c.dom.Document

createAttributeNS

public final Attr createAttributeNS(String namespaceURI,
                                    String qualifiedName)
            throws DOMException
Parameters:
namespaceURI -
qualifiedName -
See Also:
as of DOM Level 2

createCDATASection

public final CDATASection createCDATASection(String data)
            throws DOMException
Parameters:
data -
See Also:
org.w3c.dom.Document

createComment

public final Comment createComment(String data)
Parameters:
data -
See Also:
org.w3c.dom.Document

createDocumentFragment

public final DocumentFragment createDocumentFragment()
See Also:
org.w3c.dom.Document

createElement

public final Element createElement(String tagName)
            throws DOMException
Parameters:
tagName -
See Also:
org.w3c.dom.Document

createElementNS

public final Element createElementNS(String namespaceURI,
                                     String qualifiedName)
            throws DOMException
Parameters:
namespaceURI -
qualifiedName -
See Also:
as of DOM Level 2

createEntityReference

public final EntityReference createEntityReference(String name)
            throws DOMException
Parameters:
name -
See Also:
org.w3c.dom.Document

createProcessingInstruction

public final ProcessingInstruction createProcessingInstruction(String target,
                                                               String data)
            throws DOMException
Parameters:
target -
data -
See Also:
org.w3c.dom.Document

createTextNode

public final Text createTextNode(String data)
Parameters:
data -
See Also:
org.w3c.dom.Document

deleteData

public final void deleteData(int offset,
                             int count)
            throws DOMException
Parameters:
offset -
count -
See Also:
org.w3c.dom.CharacterData

equals

public final boolean equals(Node node)
Test for equality based on node number.
Parameters:
node - A DTM node proxy reference.
Returns:
true if the given node has the same handle as this node.

equals

public final boolean equals(Object node)
Test for equality based on node number.
Parameters:
node - A DTM node proxy reference.
Returns:
true if the given node has the same handle as this node.

getAttribute

public final String getAttribute(String name)
Parameters:
name -
See Also:
org.w3c.dom.Element

getAttributeNS

public final String getAttributeNS(String namespaceURI,
                                   String localName)
Parameters:
namespaceURI -
localName -
See Also:
org.w3c.dom.Element

getAttributeNode

public final Attr getAttributeNode(String name)
Parameters:
name -
See Also:
org.w3c.dom.Element

getAttributeNodeNS

public final Attr getAttributeNodeNS(String namespaceURI,
                                     String localName)
Parameters:
namespaceURI -
localName -
See Also:
org.w3c.dom.Element

getAttributes

public final NamedNodeMap getAttributes()
See Also:
org.w3c.dom.Node

getBaseURI

public String getBaseURI()

getChildNodes

public final NodeList getChildNodes()
See Also:
org.w3c.dom.Node

getDTM

public final DTM getDTM()
NON-DOM: Return the DTM model
Returns:
The DTM that this proxy is a representative for.

getDTMNodeNumber

public final int getDTMNodeNumber()
NON-DOM: Return the DTM node number
Returns:
The DTM node handle.

getData

public final String getData()
            throws DOMException
See Also:
org.w3c.dom.CharacterData

getDoctype

public final DocumentType getDoctype()
See Also:
org.w3c.dom.Document

getDocumentElement

public final Element getDocumentElement()
This is a bit of a problem in DTM, since a DTM may be a Document Fragment and hence not have a clear-cut Document Element. We can make it work in the well-formed cases but would that be confusing for others?
See Also:
org.w3c.dom.Document

getDocumentURI

public String getDocumentURI()

getDomConfig

public DOMConfiguration getDomConfig()

getElementById

public final Element getElementById(String elementId)
Parameters:
elementId -
See Also:
as of DOM Level 2

getElementsByTagName

public final NodeList getElementsByTagName(String tagname)
Parameters:
tagname -
See Also:
org.w3c.dom.Document

getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
Parameters:
namespaceURI -
localName -
See Also:
as of DOM Level 2

getEncoding

public String getEncoding()
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Since:
DOM Level 3

getFeature

public Object getFeature(String feature,
                         String version)

getFirstChild

public final Node getFirstChild()
See Also:
org.w3c.dom.Node

getImplementation

public final DOMImplementation getImplementation()
See Also:
org.w3c.dom.Document

getInputEncoding

public String getInputEncoding()

getLastChild

public final Node getLastChild()
See Also:
org.w3c.dom.Node

getLength

public final int getLength()
See Also:
org.w3c.dom.CharacterData

getLocalName

public final String getLocalName()
See Also:
as of DOM Level 2

getName

public final String getName()
See Also:
org.w3c.dom.Attr

getNamespaceURI

public final String getNamespaceURI()
See Also:
as of DOM Level 2

getNextSibling

public final Node getNextSibling()
See Also:
org.w3c.dom.Node

getNodeName

public final String getNodeName()
See Also:
org.w3c.dom.Node

getNodeType

public final short getNodeType()
See Also:
org.w3c.dom.Node

getNodeValue

public final String getNodeValue()
            throws DOMException
See Also:
org.w3c.dom.Node

getOwnerDocument

public final Document getOwnerDocument()
See Also:
org.w3c.dom.Node

getOwnerElement

public final Element getOwnerElement()
Get the owner element of an attribute.
See Also:
as of DOM Level 2

getOwnerNode

public final Node getOwnerNode()
See Also:
org.w3c.dom.Node

getParentNode

public final Node getParentNode()
See Also:
org.w3c.dom.Node

getPrefix

public final String getPrefix()
Returns:
The prefix for this node.
See Also:
as of DOM Level 2

getPreviousSibling

public final Node getPreviousSibling()
See Also:
org.w3c.dom.Node

getSchemaTypeInfo

public TypeInfo getSchemaTypeInfo()

getSpecified

public final boolean getSpecified()
See Also:
org.w3c.dom.Attr

getStandalone

public boolean getStandalone()
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Since:
DOM Level 3

getStrictErrorChecking

public boolean getStrictErrorChecking()
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Since:
DOM Level 3

getStringValue

public final String getStringValue()
            throws DOMException
Returns:
The string value of the node

getTagName

public final String getTagName()
See Also:
org.w3c.dom.Element

getTarget

public final String getTarget()
A PI's "target" states what processor channel the PI's data should be directed to. It is defined differently in HTML and XML.

In XML, a PI's "target" is the first (whitespace-delimited) token following the "<?" token that begins the PI.

In HTML, target is always null.

Note that getNodeName is aliased to getTarget.


getTextContent

public String getTextContent()
            throws DOMException

getUserData

public Object getUserData(String key)

getValue

public final String getValue()
See Also:
org.w3c.dom.Attr

getVersion

public String getVersion()
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Since:
DOM Level 3

getWholeText

public String getWholeText()

getXmlEncoding

public String getXmlEncoding()

getXmlStandalone

public boolean getXmlStandalone()

getXmlVersion

public String getXmlVersion()

hasAttribute

public boolean hasAttribute(String name)
Method hasAttribute
Parameters:
name -

hasAttributeNS

public boolean hasAttributeNS(String name,
                              String x)
Method hasAttributeNS
Parameters:
name -
x -

hasAttributes

public boolean hasAttributes()
Introduced in DOM Level 2.

hasChildNodes

public final boolean hasChildNodes()
See Also:
org.w3c.dom.Node

importNode

public final Node importNode(Node importedNode,
                             boolean deep)
            throws DOMException
Parameters:
importedNode -
deep -
See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only

insertBefore

public final Node insertBefore(Node newChild,
                               Node refChild)
            throws DOMException
Parameters:
newChild -
refChild -
See Also:
-- DTMNodeProxy is read-only

insertData

public final void insertData(int offset,
                             String arg)
            throws DOMException
Parameters:
offset -
arg -
See Also:
org.w3c.dom.CharacterData

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)

isElementContentWhitespace

public boolean isElementContentWhitespace()

isEqualNode

public boolean isEqualNode(Node arg)

isId

public boolean isId()

isSameNode

public boolean isSameNode(Node other)

isSupported

public final boolean isSupported(String feature,
                                 String version)
Ask whether we support a given DOM feature. In fact, we do not _fully_ support any DOM feature -- we're a read-only subset -- so arguably we should always return false.
Parameters:
feature -
version -
Returns:
false
See Also:
as of DOM Level 2

lookupNamespaceURI

public String lookupNamespaceURI(String prefix)

lookupPrefix

public String lookupPrefix(String namespaceURI)

normalize

public final void normalize()
See Also:
org.w3c.dom.Element

normalizeDocument

public void normalizeDocument()

removeAttribute

public final void removeAttribute(String name)
            throws DOMException
Parameters:
name -
See Also:
org.w3c.dom.Element

removeAttributeNS

public final void removeAttributeNS(String namespaceURI,
                                    String localName)
            throws DOMException
Parameters:
namespaceURI -
localName -
See Also:
org.w3c.dom.Element

removeAttributeNode

public final Attr removeAttributeNode(Attr oldAttr)
            throws DOMException
Parameters:
oldAttr -
See Also:
org.w3c.dom.Element

removeChild

public final Node removeChild(Node oldChild)
            throws DOMException
Parameters:
oldChild -
See Also:
-- DTMNodeProxy is read-only

renameNode

public Node renameNode(Node node,
                       String namespaceURI,
                       String qualifiedName)
            throws DOMException

replaceChild

public final Node replaceChild(Node newChild,
                               Node oldChild)
            throws DOMException
Parameters:
newChild -
oldChild -
See Also:
-- DTMNodeProxy is read-only

replaceData

public final void replaceData(int offset,
                              int count,
                              String arg)
            throws DOMException
Parameters:
offset -
count -
arg -
See Also:
org.w3c.dom.CharacterData

replaceWholeText

public Text replaceWholeText(String content)
            throws DOMException

sameNodeAs

public final boolean sameNodeAs(Node other)
FUTURE DOM: Test node identity, in lieu of Node==Node
Parameters:
other -
Returns:
true if the given node has the same handle as this node.

setAttribute

public final void setAttribute(String name,
                               String value)
            throws DOMException
Parameters:
name -
value -
See Also:
org.w3c.dom.Element

setAttributeNS

public final void setAttributeNS(String namespaceURI,
                                 String qualifiedName,
                                 String value)
            throws DOMException
Parameters:
namespaceURI -
qualifiedName -
value -
See Also:
org.w3c.dom.Element

setAttributeNode

public final Attr setAttributeNode(Attr newAttr)
            throws DOMException
Parameters:
newAttr -
See Also:
org.w3c.dom.Element

setAttributeNodeNS

public final Attr setAttributeNodeNS(Attr newAttr)
            throws DOMException
Parameters:
newAttr -
See Also:
org.w3c.dom.Element

setData

public final void setData(String data)
            throws DOMException
Parameters:
data -
See Also:
org.w3c.dom.CharacterData

setDocumentURI

public void setDocumentURI(String documentURI)

setEncoding

public void setEncoding(String encoding)
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Since:
DOM Level 3 NEEDSDOC @param encoding

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
            throws DOMException

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
            throws DOMException

setIdAttributeNode

public void setIdAttributeNode(Attr idAttr,
                               boolean isId)
            throws DOMException

setNodeValue

public final void setNodeValue(String nodeValue)
            throws DOMException
Parameters:
nodeValue -
See Also:
-- DTMNodeProxy is read-only

setPrefix

public final void setPrefix(String prefix)
            throws DOMException
Parameters:
prefix -
See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only

setStandalone

public void setStandalone(boolean standalone)
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Since:
DOM Level 3 NEEDSDOC @param standalone

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Since:
DOM Level 3 NEEDSDOC @param strictErrorChecking

setTextContent

public void setTextContent(String textContent)
            throws DOMException

setUserData

public Object setUserData(String key,
                          Object data,
                          UserDataHandler handler)

setValue

public final void setValue(String value)
Parameters:
value -
See Also:
org.w3c.dom.Attr

setVersion

public void setVersion(String version)
EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Since:
DOM Level 3 NEEDSDOC @param version

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)
            throws DOMException

setXmlVersion

public void setXmlVersion(String xmlVersion)
            throws DOMException

splitText

public final Text splitText(int offset)
            throws DOMException
Parameters:
offset -
See Also:
org.w3c.dom.Text

substringData

public final String substringData(int offset,
                                  int count)
            throws DOMException
Parameters:
offset -
count -
See Also:
org.w3c.dom.CharacterData

supports

public final boolean supports(String feature,
                              String version)
Ask whether we support a given DOM feature. In fact, we do not _fully_ support any DOM feature -- we're a read-only subset -- so arguably we should always return false. Or we could say that we support DOM Core Level 2 but all nodes are read-only. Unclear which answer is least misleading. NON-DOM method. This was present in early drafts of DOM Level 2, but was renamed isSupported. It's present here only because it's cheap, harmless, and might help some poor fool who is still trying to use an early Working Draft of the DOM.
Parameters:
feature -
version -
Returns:
false

Copyright B) 2004 Apache XML Project. All Rights Reserved.