org.apache.xml.dtm.ref

Class DTMNodeProxy

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

public class DTMNodeProxy
extends java.lang.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

Nested Class Summary

Field Summary

DTM
dtm
The DTM for this node.

Fields inherited from interface org.w3c.dom.Node

ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_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)
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(Object node)
Test for equality based on node number.
boolean
equals(Node 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()
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.
Element
getElementById(String elementId)
NodeList
getElementsByTagName(String tagname)
NodeList
getElementsByTagNameNS(String namespaceURI, String localName)
String
getEncoding()
EXPERIMENTAL!
Node
getFirstChild()
DOMImplementation
getImplementation()
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()
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
getValue()
String
getVersion()
EXPERIMENTAL!
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
isSupported(String feature, String version)
Ask whether we support a given DOM feature.
void
normalize()
void
removeAttribute(String name)
void
removeAttributeNS(String namespaceURI, String localName)
Attr
removeAttributeNode(Attr oldAttr)
Node
removeChild(Node oldChild)
Node
replaceChild(Node newChild, Node oldChild)
void
replaceData(int offset, int count, String arg)
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
setEncoding(String encoding)
EXPERIMENTAL!
void
setNodeValue(String nodeValue)
void
setPrefix(String prefix)
void
setStandalone(boolean standalone)
EXPERIMENTAL!
void
setStrictErrorChecking(boolean strictErrorChecking)
EXPERIMENTAL!
void
setValue(String value)
void
setVersion(String version)
EXPERIMENTAL!
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

Throws:
DOMException -


appendChild

public final Node appendChild(Node newChild)
            throws DOMException
Specified by:
appendChild in interface Node

Parameters:
newChild -

Throws:
DOMException -

See Also:
-- DTMNodeProxy is read-only


appendData

public final void appendData(String arg)
            throws DOMException
Specified by:
appendData in interface CharacterData

Parameters:
arg -

Throws:
DOMException -

See Also:
CharacterData


cloneNode

public final Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node

Parameters:
deep -

See Also:
-- DTMNodeProxy is read-only


createAttribute

public final Attr createAttribute(String name)
            throws DOMException
Specified by:
createAttribute in interface Document

Parameters:
name -

Throws:
DOMException -

See Also:
Document


createAttributeNS

public final Attr createAttributeNS(String namespaceURI,
                                    String qualifiedName)
            throws DOMException
Specified by:
createAttributeNS in interface Document

Parameters:
namespaceURI -
qualifiedName -

Throws:
DOMException -

See Also:
as of DOM Level 2


createCDATASection

public final CDATASection createCDATASection(String data)
            throws DOMException
Specified by:
createCDATASection in interface Document

Parameters:
data -

Throws:
DOMException -

See Also:
Document


createComment

public final Comment createComment(String data)
Specified by:
createComment in interface Document

Parameters:
data -

See Also:
Document


createDocumentFragment

public final DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document

See Also:
Document


createElement

public final Element createElement(String tagName)
            throws DOMException
Specified by:
createElement in interface Document

Parameters:
tagName -

Throws:
DOMException -

See Also:
Document


createElementNS

public final Element createElementNS(String namespaceURI,
                                     String qualifiedName)
            throws DOMException
Specified by:
createElementNS in interface Document

Parameters:
namespaceURI -
qualifiedName -

Throws:
DOMException -

See Also:
as of DOM Level 2


createEntityReference

public final EntityReference createEntityReference(String name)
            throws DOMException
Specified by:
createEntityReference in interface Document

Parameters:
name -

Throws:
DOMException -

See Also:
Document


createProcessingInstruction

public final ProcessingInstruction createProcessingInstruction(String target,
                                                               String data)
            throws DOMException
Specified by:
createProcessingInstruction in interface Document

Parameters:
target -
data -

Throws:
DOMException -

See Also:
Document


createTextNode

public final Text createTextNode(String data)
Specified by:
createTextNode in interface Document

Parameters:
data -

See Also:
Document


deleteData

public final void deleteData(int offset,
                             int count)
            throws DOMException
Specified by:
deleteData in interface CharacterData

Parameters:
offset -
count -

Throws:
DOMException -

See Also:
CharacterData


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.


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.


getAttribute

public final String getAttribute(String name)
Specified by:
getAttribute in interface Element

Parameters:
name -

See Also:
Element


getAttributeNS

public final String getAttributeNS(String namespaceURI,
                                   String localName)
Specified by:
getAttributeNS in interface Element

Parameters:
namespaceURI -
localName -

See Also:
Element


getAttributeNode

public final Attr getAttributeNode(String name)
Specified by:
getAttributeNode in interface Element

Parameters:
name -

See Also:
Element


getAttributeNodeNS

public final Attr getAttributeNodeNS(String namespaceURI,
                                     String localName)
Specified by:
getAttributeNodeNS in interface Element

Parameters:
namespaceURI -
localName -

See Also:
Element


getAttributes

public final NamedNodeMap getAttributes()
Specified by:
getAttributes in interface Node

See Also:
Node


getChildNodes

public final NodeList getChildNodes()
Specified by:
getChildNodes in interface Node

See Also:
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
Specified by:
getData in interface CharacterData
getData in interface ProcessingInstruction

Throws:
DOMException -

See Also:
CharacterData


getDoctype

public final DocumentType getDoctype()
Specified by:
getDoctype in interface Document

See Also:
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?
Specified by:
getDocumentElement in interface Document

See Also:
Document


getElementById

public final Element getElementById(String elementId)
Specified by:
getElementById in interface Document

Parameters:
elementId -

See Also:
as of DOM Level 2


getElementsByTagName

public final NodeList getElementsByTagName(String tagname)
Specified by:
getElementsByTagName in interface Document
getElementsByTagName in interface Element

Parameters:
tagname -

See Also:
Document


getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
Specified by:
getElementsByTagNameNS in interface Document
getElementsByTagNameNS in interface Element

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


getFirstChild

public final Node getFirstChild()
Specified by:
getFirstChild in interface Node

See Also:
Node


getImplementation

public final DOMImplementation getImplementation()
Specified by:
getImplementation in interface Document

See Also:
Document


getLastChild

public final Node getLastChild()
Specified by:
getLastChild in interface Node

See Also:
Node


getLength

public final int getLength()
Specified by:
getLength in interface CharacterData

See Also:
CharacterData


getLocalName

public final String getLocalName()
Specified by:
getLocalName in interface Node

See Also:
as of DOM Level 2


getName

public final String getName()
Specified by:
getName in interface Attr

See Also:
Attr


getNamespaceURI

public final String getNamespaceURI()
Specified by:
getNamespaceURI in interface Node

See Also:
as of DOM Level 2


getNextSibling

public final Node getNextSibling()
Specified by:
getNextSibling in interface Node

See Also:
Node


getNodeName

public final String getNodeName()
Specified by:
getNodeName in interface Node

See Also:
Node


getNodeType

public final short getNodeType()
Specified by:
getNodeType in interface Node

See Also:
Node


getNodeValue

public final String getNodeValue()
            throws DOMException
Specified by:
getNodeValue in interface Node

Throws:
DOMException -

See Also:
Node


getOwnerDocument

public final Document getOwnerDocument()
Specified by:
getOwnerDocument in interface Node

See Also:
Node


getOwnerElement

public final Element getOwnerElement()
Get the owner element of an attribute.
Specified by:
getOwnerElement in interface Attr

See Also:
as of DOM Level 2


getOwnerNode

public final Node getOwnerNode()

See Also:
Node


getParentNode

public final Node getParentNode()
Specified by:
getParentNode in interface Node

See Also:
Node


getPrefix

public final String getPrefix()
Specified by:
getPrefix in interface Node

Returns:
The prefix for this node.

See Also:
as of DOM Level 2


getPreviousSibling

public final Node getPreviousSibling()
Specified by:
getPreviousSibling in interface Node

See Also:
Node


getSpecified

public final boolean getSpecified()
Specified by:
getSpecified in interface Attr

See Also:
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

Throws:
DOMException -


getTagName

public final String getTagName()
Specified by:
getTagName in interface Element

See Also:
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.

Specified by:
getTarget in interface ProcessingInstruction


getValue

public final String getValue()
Specified by:
getValue in interface Attr

See Also:
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


hasAttribute

public boolean hasAttribute(String name)
Method hasAttribute
Specified by:
hasAttribute in interface Element

Parameters:
name -


hasAttributeNS

public boolean hasAttributeNS(String name,
                              String x)
Method hasAttributeNS
Specified by:
hasAttributeNS in interface Element

Parameters:
name -
x -


hasAttributes

public boolean hasAttributes()
Introduced in DOM Level 2.
Specified by:
hasAttributes in interface Node


hasChildNodes

public final boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node

See Also:
Node


importNode

public final Node importNode(Node importedNode,
                             boolean deep)
            throws DOMException
Specified by:
importNode in interface Document

Parameters:
importedNode -
deep -

Throws:
DOMException -

See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only


insertBefore

public final Node insertBefore(Node newChild,
                               Node refChild)
            throws DOMException
Specified by:
insertBefore in interface Node

Parameters:
newChild -
refChild -

Throws:
DOMException -

See Also:
-- DTMNodeProxy is read-only


insertData

public final void insertData(int offset,
                             String arg)
            throws DOMException
Specified by:
insertData in interface CharacterData

Parameters:
offset -
arg -

Throws:
DOMException -

See Also:
CharacterData


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.
Specified by:
isSupported in interface Node

Parameters:
feature -
version -

Returns:
false

See Also:
as of DOM Level 2


normalize

public final void normalize()
Specified by:
normalize in interface Node

See Also:
Element


removeAttribute

public final void removeAttribute(String name)
            throws DOMException
Specified by:
removeAttribute in interface Element

Parameters:
name -

Throws:
DOMException -

See Also:
Element


removeAttributeNS

public final void removeAttributeNS(String namespaceURI,
                                    String localName)
            throws DOMException
Specified by:
removeAttributeNS in interface Element

Parameters:
namespaceURI -
localName -

Throws:
DOMException -

See Also:
Element


removeAttributeNode

public final Attr removeAttributeNode(Attr oldAttr)
            throws DOMException
Specified by:
removeAttributeNode in interface Element

Parameters:
oldAttr -

Throws:
DOMException -

See Also:
Element


removeChild

public final Node removeChild(Node oldChild)
            throws DOMException
Specified by:
removeChild in interface Node

Parameters:
oldChild -

Throws:
DOMException -

See Also:
-- DTMNodeProxy is read-only


replaceChild

public final Node replaceChild(Node newChild,
                               Node oldChild)
            throws DOMException
Specified by:
replaceChild in interface Node

Parameters:
newChild -
oldChild -

Throws:
DOMException -

See Also:
-- DTMNodeProxy is read-only


replaceData

public final void replaceData(int offset,
                              int count,
                              String arg)
            throws DOMException
Specified by:
replaceData in interface CharacterData

Parameters:
offset -
count -
arg -

Throws:
DOMException -

See Also:
CharacterData


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
Specified by:
setAttribute in interface Element

Parameters:
name -
value -

Throws:
DOMException -

See Also:
Element


setAttributeNS

public final void setAttributeNS(String namespaceURI,
                                 String qualifiedName,
                                 String value)
            throws DOMException
Specified by:
setAttributeNS in interface Element

Parameters:
namespaceURI -
qualifiedName -
value -

Throws:
DOMException -

See Also:
Element


setAttributeNode

public final Attr setAttributeNode(Attr newAttr)
            throws DOMException
Specified by:
setAttributeNode in interface Element

Parameters:
newAttr -

Throws:
DOMException -

See Also:
Element


setAttributeNodeNS

public final Attr setAttributeNodeNS(Attr newAttr)
            throws DOMException
Specified by:
setAttributeNodeNS in interface Element

Parameters:
newAttr -

Throws:
DOMException -

See Also:
Element


setData

public final void setData(String data)
            throws DOMException
Specified by:
setData in interface CharacterData
setData in interface ProcessingInstruction

Parameters:
data -

Throws:
DOMException -

See Also:
CharacterData


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


setNodeValue

public final void setNodeValue(String nodeValue)
            throws DOMException
Specified by:
setNodeValue in interface Node

Parameters:
nodeValue -

Throws:
DOMException -

See Also:
-- DTMNodeProxy is read-only


setPrefix

public final void setPrefix(String prefix)
            throws DOMException
Specified by:
setPrefix in interface Node

Parameters:
prefix -

Throws:
DOMException -

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


setValue

public final void setValue(String value)
Specified by:
setValue in interface Attr

Parameters:
value -

See Also:
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


splitText

public final Text splitText(int offset)
            throws DOMException
Specified by:
splitText in interface Text

Parameters:
offset -

Throws:
DOMException -

See Also:
Text


substringData

public final String substringData(int offset,
                                  int count)
            throws DOMException
Specified by:
substringData in interface CharacterData

Parameters:
offset -
count -

Throws:
DOMException -

See Also:
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.