|
|||||||||
| Home >> All >> gnu >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.xml.dom
Class DomNode

java.lang.Objectgnu.xml.dom.DomNode
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Comparable, org.w3c.dom.events.DocumentEvent, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.NodeList
- Direct Known Subclasses:
- DomCharacterData, DomDocument, DomDocumentFragment, DomEntityReference, DomExtern, DomFragment, DomNsNode, DomPI, DomProcessingInstruction
- public abstract class DomNode
- extends java.lang.Object
- implements org.w3c.dom.Node, org.w3c.dom.NodeList, org.w3c.dom.events.EventTarget, org.w3c.dom.events.DocumentEvent, java.lang.Cloneable, java.lang.Comparable
- extends java.lang.Object
"Node", "EventTarget", and "DocumentEvent" implementation. This provides most of the core DOM functionality; only more specialized features are provided by subclasses. Those subclasses may have some particular constraints they must implement, by overriding methods defined here. Such constraints are noted here in the method documentation.
Note that you can create events with type names prefixed with "USER-", and pass them through this DOM. This lets you use the DOM event scheme for application specific purposes, although you must use a predefined event structure (such as MutationEvent) to pass data along with those events. Test for existence of this feature with the "USER-Events" DOM feature name.
Other kinds of events you can send include the "html" events, like "load", "unload", "abort", "error", and "blur"; and the mutation events. If this DOM has been compiled with mutation event support enabled, it will send mutation events when you change parts of the tree; otherwise you may create and send such events yourself, but they won't be generated by the DOM itself.
Note that there is a namespace-aware name comparison method, nameAndTypeEquals, which compares the names (and types) of two nodes in conformance with the "Namespaces in XML" specification. While mostly intended for use with elements and attributes, this should also be helpful for ProcessingInstruction nodes and some others which do not have namespace URIs.
| Nested Class Summary | |
(package private) static class |
DomNode.DomEventException
|
(package private) static class |
DomNode.ListenerRecord
|
(package private) class |
DomNode.LiveNodeList
|
(package private) class |
DomNode.ShadowList
|
| Field Summary | |
private static DomNode[] |
ancestors
|
private static int |
ANCESTORS_INIT
|
(package private) int |
depth
|
private static boolean |
dispatchDataLock
|
private static boolean |
eventDataLock
|
(package private) DomNode |
first
|
(package private) int |
index
|
(package private) DomNode |
last
|
(package private) int |
length
|
private java.util.HashSet |
listeners
|
private static java.lang.Object |
lockNode
|
private static DomEvent.DomMutationEvent |
mutationEvent
|
(package private) DomNode |
next
|
private static int |
NKIDS_DELTA
|
private int |
nListeners
|
(package private) short |
nodeType
|
private static int |
NOTIFICATIONS_INIT
|
private static DomNode.ListenerRecord[] |
notificationSet
|
(package private) DomDocument |
owner
|
(package private) DomNode |
parent
|
(package private) DomNode |
previous
|
(package private) boolean |
readonly
|
(package private) static boolean |
reportMutations
|
private java.util.HashMap |
userData
|
private java.util.HashMap |
userDataHandlers
|
| Constructor Summary | |
protected |
DomNode(short nodeType,
DomDocument owner)
Constructs a node and associates it with its owner. |
| Method Summary | |
void |
addEventListener(java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
DOM L2 (Events) Registers an event listener's interest in a class of events. |
org.w3c.dom.Node |
appendChild(org.w3c.dom.Node newChild)
DOM L1 Appends the specified node to this node's list of children. |
private void |
checkMisc(DomNode child)
|
java.lang.Object |
clone()
Clones this node; roughly equivalent to cloneNode(false). |
org.w3c.dom.Node |
cloneNode(boolean deep)
DOM L1 Returns a clone of this node which optionally includes cloned versions of child nodes. |
void |
compact()
Reduces space utilization for this node. |
short |
compareDocumentPosition(org.w3c.dom.Node other)
Compares the reference node, i.e. |
int |
compareTo(java.lang.Object other)
DOM nodes have a natural ordering: document order. |
(package private) int |
compareTo2(DomNode n1,
DomNode n2)
Compare two nodes at the same depth. |
org.w3c.dom.events.Event |
createEvent(java.lang.String eventType)
DOM L2 (Events) Returns an instance of the specified type of event object. |
boolean |
dispatchEvent(org.w3c.dom.events.Event event)
DOM L2 (Events) Delivers an event to all relevant listeners, returning true if the caller should perform their default action. |
(package private) java.lang.String |
encode(java.lang.String value)
|
(package private) boolean |
equal(java.lang.String arg1,
java.lang.String arg2)
|
private static void |
freeMutationEvent()
|
org.w3c.dom.NamedNodeMap |
getAttributes()
DOM L1 Returns null; Element subclasses must override this method. |
java.lang.String |
getBaseURI()
The absolute base URI of this node or null if the
implementation wasn't able to obtain an absolute URI. |
org.w3c.dom.NodeList |
getChildNodes()
DOM L1 Returns a list, possibly empty, of the children of this node. |
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tag)
DOM L1 Creates a NodeList giving array-style access to elements with the specified name. |
org.w3c.dom.NodeList |
getElementsByTagNameNS(java.lang.String namespace,
java.lang.String local)
DOM L2 Creates a NodeList giving array-style access to elements with the specified namespace and local name. |
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . |
org.w3c.dom.Node |
getFirstChild()
DOM L1 Returns the first child of this node, or null if there are none. |
org.w3c.dom.Node |
getLastChild()
DOM L1 Returns the last child of this node, or null if there are none. |
int |
getLength()
DOM L1 (NodeList) Returns the number of elements in this NodeList. |
java.lang.String |
getLocalName()
DOM L2 Returns the node name; this must be overridden for element and attribute nodes. |
private static DomEvent.DomMutationEvent |
getMutationEvent()
|
java.lang.String |
getNamespaceURI()
DOM L2 Returns null; this must be overridden for element and attribute nodes. |
org.w3c.dom.Node |
getNextSibling()
DOM L1 Returns the previous sibling, if one is known. |
abstract java.lang.String |
getNodeName()
This forces GCJ compatibility. |
short |
getNodeType()
This forces GCJ compatibility. |
java.lang.String |
getNodeValue()
DOM L1 Returns null; this must be overridden for nodes types with a defined value, along with the setNodeValue method. |
org.w3c.dom.Document |
getOwnerDocument()
DOM L1 (modified in L2) Returns the owner document. |
org.w3c.dom.Node |
getParentNode()
DOM L1 Returns the parent node, if one is known. |
java.lang.String |
getPrefix()
DOM L2 Returns null; this must be overridden for element and attribute nodes. |
org.w3c.dom.Node |
getPreviousSibling()
DOM L1 Returns the previous sibling, if one is known. |
java.lang.String |
getTextContent()
This attribute returns the text content of this node and its descendants. |
(package private) java.lang.String |
getTextContent(boolean topLevel)
|
java.lang.Object |
getUserData(java.lang.String key)
Retrieves the object associated to a key on a this node. |
boolean |
hasAttributes()
DOM L2> Returns true iff this is an element node with attributes. |
boolean |
hasChildNodes()
DOM L1 Returns true if this node has children. |
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
DOM L1 Inserts the specified node in this node's list of children. |
private void |
insertionEvent(DomEvent.DomMutationEvent event,
DomNode target)
|
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
This method checks if the specified namespaceURI is the
default namespace or not. |
boolean |
isEqualNode(org.w3c.dom.Node arg)
Tests whether two nodes are equal. |
boolean |
isReadonly()
Exposes the internal "readonly" flag. |
boolean |
isSameNode(org.w3c.dom.Node other)
Returns whether this node is the same node as the given one. |
boolean |
isSupported(java.lang.String feature,
java.lang.String version)
DOM L2 Consults the DOM implementation to determine if the requested feature is supported. |
org.w3c.dom.Node |
item(int index)
DOM L1 (NodeList) Returns the item with the specified index in this NodeList, else null. |
void |
list(java.io.PrintStream out,
int indent)
|
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
Look up the namespace URI associated to the given prefix, starting from this node. |
java.lang.String |
lookupPrefix(java.lang.String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node. |
void |
makeReadonly()
Sets the internal "readonly" flag so this subtree can't be changed. |
boolean |
nameAndTypeEquals(org.w3c.dom.Node other)
Returns true iff node types match, and either (a) both nodes have no namespace and their getNodeName() values are the same, or (b) both nodes have the same getNamespaceURI() and same getLocalName() values. |
(package private) java.lang.String |
nodeTypeToString(short nodeType)
|
void |
normalize()
DOM L1 (relocated in DOM L2) In this node and all contained nodes (including attributes if relevant) merge adjacent text nodes. |
private void |
notifyNode(DomEvent e,
DomNode current,
boolean capture,
DomNode.ListenerRecord[] notificationSet)
|
(package private) void |
notifyUserDataHandlers(short op,
org.w3c.dom.Node src,
org.w3c.dom.Node dst)
|
private void |
removalEvent(DomEvent.DomMutationEvent event,
DomNode target)
|
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node refChild)
DOM L1 Removes the specified child from this node's list of children, or else reports an exception. |
void |
removeEventListener(java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture)
DOM L2 (Events) Unregisters an event listener. |
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
DOM L1 Replaces the specified node in this node's list of children. |
(package private) void |
setDepth(int depth)
|
void |
setNodeValue(java.lang.String value)
DOM L1 Does nothing; this must be overridden (along with the getNodeValue method) for nodes with a non-null defined value. |
(package private) void |
setOwner(DomDocument doc)
Used to adopt a node to a new document. |
void |
setPrefix(java.lang.String prefix)
DOM L2 Does nothing; this must be overridden (along with the getPrefix method) for element and attribute nodes. |
void |
setTextContent(java.lang.String textContent)
This attribute returns the text content of this node and its descendants. |
java.lang.Object |
setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
Associate an object to a key on this node. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
void |
trimToSize()
Minimize extra space consumed by this node to hold children and event listeners. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
NKIDS_DELTA
private static final int NKIDS_DELTA
- See Also:
- Constant Field Values
ANCESTORS_INIT
private static final int ANCESTORS_INIT
- See Also:
- Constant Field Values
NOTIFICATIONS_INIT
private static final int NOTIFICATIONS_INIT
- See Also:
- Constant Field Values
reportMutations
static final boolean reportMutations
- See Also:
- Constant Field Values
lockNode
private static final java.lang.Object lockNode
dispatchDataLock
private static boolean dispatchDataLock
ancestors
private static DomNode[] ancestors
notificationSet
private static DomNode.ListenerRecord[] notificationSet
eventDataLock
private static boolean eventDataLock
mutationEvent
private static DomEvent.DomMutationEvent mutationEvent
owner
DomDocument owner
parent
DomNode parent
previous
DomNode previous
next
DomNode next
first
DomNode first
last
DomNode last
index
int index
depth
int depth
length
int length
nodeType
final short nodeType
readonly
boolean readonly
listeners
private java.util.HashSet listeners
nListeners
private int nListeners
userData
private java.util.HashMap userData
userDataHandlers
private java.util.HashMap userDataHandlers
| Constructor Detail |
DomNode
protected DomNode(short nodeType,
DomDocument owner)
- Constructs a node and associates it with its owner. Only
Document and DocumentType nodes may be created with no owner,
and DocumentType nodes get an owner as soon as they are
associated with a document.
| Method Detail |
compact
public void compact()
- Reduces space utilization for this node.
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
- DOM L1
Returns null; Element subclasses must override this method.
- Specified by:
getAttributesin interfaceorg.w3c.dom.Node
hasAttributes
public boolean hasAttributes()
- DOM L2>
Returns true iff this is an element node with attributes.
- Specified by:
hasAttributesin interfaceorg.w3c.dom.Node
getChildNodes
public org.w3c.dom.NodeList getChildNodes()
- DOM L1
Returns a list, possibly empty, of the children of this node.
In this implementation, to conserve memory, nodes are the same
as their list of children. This can have ramifications for
subclasses, which may need to provide their own getLength method
for reasons unrelated to the NodeList method of the same name.
- Specified by:
getChildNodesin interfaceorg.w3c.dom.Node
getFirstChild
public org.w3c.dom.Node getFirstChild()
- DOM L1
Returns the first child of this node, or null if there are none.
- Specified by:
getFirstChildin interfaceorg.w3c.dom.Node
getLastChild
public org.w3c.dom.Node getLastChild()
- DOM L1
Returns the last child of this node, or null if there are none.
- Specified by:
getLastChildin interfaceorg.w3c.dom.Node
hasChildNodes
public boolean hasChildNodes()
- DOM L1
Returns true if this node has children.
- Specified by:
hasChildNodesin interfaceorg.w3c.dom.Node
isReadonly
public final boolean isReadonly()
- Exposes the internal "readonly" flag. In DOM, children of
entities and entity references are readonly, as are the
objects associated with DocumentType objets.
makeReadonly
public void makeReadonly()
- Sets the internal "readonly" flag so this subtree can't be changed.
Subclasses need to override this method for any associated content
that's not a child node, such as an element's attributes or the
(few) declarations associated with a DocumentType.
setOwner
void setOwner(DomDocument doc)
- Used to adopt a node to a new document.
checkMisc
private void checkMisc(DomNode child)
insertionEvent
private void insertionEvent(DomEvent.DomMutationEvent event, DomNode target)
removalEvent
private void removalEvent(DomEvent.DomMutationEvent event, DomNode target)
getMutationEvent
private static DomEvent.DomMutationEvent getMutationEvent()
freeMutationEvent
private static void freeMutationEvent()
setDepth
void setDepth(int depth)
appendChild
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
- DOM L1
Appends the specified node to this node's list of children.
Document subclasses must override this to enforce the restrictions
that there be only one element and document type child.
Causes a DOMNodeInserted mutation event to be reported. Will first cause a DOMNodeRemoved event to be reported if the parameter already has a parent. If the new child is a document fragment node, both events will be reported for each child of the fragment; the order in which children are removed and inserted is implementation-specific.
If this DOM has been compiled without mutation event support, these events will not be reported.
- Specified by:
appendChildin interfaceorg.w3c.dom.Node
insertBefore
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
- DOM L1
Inserts the specified node in this node's list of children.
Document subclasses must override this to enforce the restrictions
that there be only one element and document type child.
Causes a DOMNodeInserted mutation event to be reported. Will first cause a DOMNodeRemoved event to be reported if the newChild parameter already has a parent. If the new child is a document fragment node, both events will be reported for each child of the fragment; the order in which children are removed and inserted is implementation-specific.
If this DOM has been compiled without mutation event support, these events will not be reported.
- Specified by:
insertBeforein interfaceorg.w3c.dom.Node
replaceChild
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
- DOM L1
Replaces the specified node in this node's list of children.
Document subclasses must override this to test the restrictions
that there be only one element and document type child.
Causes DOMNodeRemoved and DOMNodeInserted mutation event to be reported. Will cause another DOMNodeRemoved event to be reported if the newChild parameter already has a parent. These events may be delivered in any order, except that the event reporting removal from such an existing parent will always be delivered before the event reporting its re-insertion as a child of some other node. The order in which children are removed and inserted is implementation specific.
If your application needs to depend on the in which those removal and insertion events are delivered, don't use this API. Instead, invoke the removeChild and insertBefore methods directly, to guarantee a specific delivery order. Similarly, don't use document fragments, Otherwise your application code may not work on a DOM which implements this method differently.
If this DOM has been compiled without mutation event support, these events will not be reported.
- Specified by:
replaceChildin interfaceorg.w3c.dom.Node
removeChild
public org.w3c.dom.Node removeChild(org.w3c.dom.Node refChild)
- DOM L1
Removes the specified child from this node's list of children,
or else reports an exception.
Causes a DOMNodeRemoved mutation event to be reported.
If this DOM has been compiled without mutation event support, these events will not be reported.
- Specified by:
removeChildin interfaceorg.w3c.dom.Node
item
public org.w3c.dom.Node item(int index)
- DOM L1 (NodeList)
Returns the item with the specified index in this NodeList,
else null.
- Specified by:
itemin interfaceorg.w3c.dom.NodeList
getLength
public int getLength()
- DOM L1 (NodeList)
Returns the number of elements in this NodeList.
(Note that many interfaces have a "Length" property, not just
NodeList, and if a node subtype must implement one of those,
it will also need to override getChildNodes.)
- Specified by:
getLengthin interfaceorg.w3c.dom.NodeList
trimToSize
public void trimToSize()
- Minimize extra space consumed by this node to hold children and event
listeners.
getNextSibling
public org.w3c.dom.Node getNextSibling()
- DOM L1
Returns the previous sibling, if one is known.
- Specified by:
getNextSiblingin interfaceorg.w3c.dom.Node
getPreviousSibling
public org.w3c.dom.Node getPreviousSibling()
- DOM L1
Returns the previous sibling, if one is known.
- Specified by:
getPreviousSiblingin interfaceorg.w3c.dom.Node
getParentNode
public org.w3c.dom.Node getParentNode()
- DOM L1
Returns the parent node, if one is known.
- Specified by:
getParentNodein interfaceorg.w3c.dom.Node
isSupported
public boolean isSupported(java.lang.String feature, java.lang.String version)
- DOM L2
Consults the DOM implementation to determine if the requested
feature is supported. DocumentType subclasses must override
this method, and associate themselves directly with the
DOMImplementation node used. (This method relies on being able
to access the DOMImplementation from the owner document, but
DocumentType nodes can be created without an owner.)
- Specified by:
isSupportedin interfaceorg.w3c.dom.Node
getOwnerDocument
public final org.w3c.dom.Document getOwnerDocument()
- DOM L1 (modified in L2)
Returns the owner document. This is only null for Document nodes,
and (new in L2) for DocumentType nodes which have not yet been
associated with the rest of their document.
- Specified by:
getOwnerDocumentin interfaceorg.w3c.dom.Node
setNodeValue
public void setNodeValue(java.lang.String value)
- DOM L1
Does nothing; this must be overridden (along with the
getNodeValue method) for nodes with a non-null defined value.
- Specified by:
setNodeValuein interfaceorg.w3c.dom.Node
getNodeValue
public java.lang.String getNodeValue()
- DOM L1
Returns null; this must be overridden for nodes types with
a defined value, along with the setNodeValue method.
- Specified by:
getNodeValuein interfaceorg.w3c.dom.Node
getNodeType
public final short getNodeType()
- This forces GCJ compatibility.
Without this method GCJ is unable to compile to byte code.
- Specified by:
getNodeTypein interfaceorg.w3c.dom.Node
getNodeName
public abstract java.lang.String getNodeName()
- This forces GCJ compatibility.
Without this method GCJ seems unable to natively compile GNUJAXP.
- Specified by:
getNodeNamein interfaceorg.w3c.dom.Node
setPrefix
public void setPrefix(java.lang.String prefix)
- DOM L2
Does nothing; this must be overridden (along with the
getPrefix method) for element and attribute nodes.
- Specified by:
setPrefixin interfaceorg.w3c.dom.Node
getPrefix
public java.lang.String getPrefix()
- DOM L2
Returns null; this must be overridden for element and
attribute nodes.
- Specified by:
getPrefixin interfaceorg.w3c.dom.Node
getNamespaceURI
public java.lang.String getNamespaceURI()
- DOM L2
Returns null; this must be overridden for element and
attribute nodes.
- Specified by:
getNamespaceURIin interfaceorg.w3c.dom.Node
getLocalName
public java.lang.String getLocalName()
- DOM L2
Returns the node name; this must be overridden for element and
attribute nodes.
- Specified by:
getLocalNamein interfaceorg.w3c.dom.Node
cloneNode
public org.w3c.dom.Node cloneNode(boolean deep)
- DOM L1
Returns a clone of this node which optionally includes cloned
versions of child nodes. Clones are always mutable, except for
entity reference nodes.
- Specified by:
cloneNodein interfaceorg.w3c.dom.Node
notifyUserDataHandlers
void notifyUserDataHandlers(short op,
org.w3c.dom.Node src,
org.w3c.dom.Node dst)
clone
public java.lang.Object clone()
- Clones this node; roughly equivalent to cloneNode(false).
Element subclasses must provide a new implementation which
invokes this method to handle the basics, and then arranges
to clone any element attributes directly. Attribute subclasses
must make similar arrangements, ensuring that existing ties to
elements are broken by cloning.
getElementsByTagName
public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tag)
- DOM L1
Creates a NodeList giving array-style access to elements with
the specified name. Access is fastest if indices change by
small values, and the DOM is not modified.
getElementsByTagNameNS
public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespace, java.lang.String local)
- DOM L2
Creates a NodeList giving array-style access to elements with
the specified namespace and local name. Access is fastest if
indices change by small values, and the DOM is not modified.
createEvent
public org.w3c.dom.events.Event createEvent(java.lang.String eventType)
- DOM L2 (Events)
Returns an instance of the specified type of event object.
Understands about DOM Mutation, HTML, and UI events.
If the name of the event type begins with "USER-", then an object implementing the "Event" class will be returned; this provides a limited facility for application-defined events to use the DOM event infrastructure. Alternatively, use one of the standard DOM event classes and initialize it using use such a "USER-" event type name; or defin, instantiate, and initialize an application-specific subclass of DomEvent and pass that to dispatchEvent().
- Specified by:
createEventin interfaceorg.w3c.dom.events.DocumentEvent
addEventListener
public final void addEventListener(java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
- DOM L2 (Events)
Registers an event listener's interest in a class of events.
- Specified by:
addEventListenerin interfaceorg.w3c.dom.events.EventTarget
dispatchEvent
public final boolean dispatchEvent(org.w3c.dom.events.Event event) throws org.w3c.dom.events.EventException
- DOM L2 (Events)
Delivers an event to all relevant listeners, returning true if the
caller should perform their default action. Note that the event
must have been provided by the createEvent() method on this
class, else it can't be dispatched.
- Specified by:
dispatchEventin interfaceorg.w3c.dom.events.EventTarget
notifyNode
private void notifyNode(DomEvent e, DomNode current, boolean capture, DomNode.ListenerRecord[] notificationSet)
removeEventListener
public final void removeEventListener(java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
- DOM L2 (Events)
Unregisters an event listener.
- Specified by:
removeEventListenerin interfaceorg.w3c.dom.events.EventTarget
normalize
public final void normalize()
- DOM L1 (relocated in DOM L2)
In this node and all contained nodes (including attributes if
relevant) merge adjacent text nodes. This is done while ignoring
text which happens to use CDATA delimiters).
- Specified by:
normalizein interfaceorg.w3c.dom.Node
nameAndTypeEquals
public boolean nameAndTypeEquals(org.w3c.dom.Node other)
- Returns true iff node types match, and either (a) both nodes have no
namespace and their getNodeName() values are the same, or (b) both
nodes have the same getNamespaceURI() and same getLocalName() values.
Note that notion of a "Per-Element-Type" attribute name scope, as found in a non-normative appendix of the XML Namespaces specification, is not supported here. Your application must implement that notion, typically by not bothering to check nameAndTypeEquals for attributes without namespace URIs unless you already know their elements are nameAndTypeEquals.
getBaseURI
public java.lang.String getBaseURI()
- Description copied from interface:
org.w3c.dom.Node - The absolute base URI of this node or
nullif the implementation wasn't able to obtain an absolute URI. This value is computed as described in . However, when theDocumentsupports the feature "HTML" [DOM Level 2 HTML] , the base URI is computed using first the value of the href attribute of the HTML BASE element if any, and the value of thedocumentURIattribute from theDocumentinterface otherwise.- Specified by:
getBaseURIin interfaceorg.w3c.dom.Node
compareDocumentPosition
public short compareDocumentPosition(org.w3c.dom.Node other) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.Node - Compares the reference node, i.e. the node on which this method is
being called, with a node, i.e. the one passed as a parameter, with
regard to their position in the document and according to the
document order.
- Specified by:
compareDocumentPositionin interfaceorg.w3c.dom.Node
compareTo
public final int compareTo(java.lang.Object other)
- DOM nodes have a natural ordering: document order.
- Specified by:
compareToin interfacejava.lang.Comparable
compareTo2
final int compareTo2(DomNode n1, DomNode n2)
- Compare two nodes at the same depth.
getTextContent
public final java.lang.String getTextContent() throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.Node - This attribute returns the text content of this node and its
descendants. When it is defined to be
null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty ornull, replaced by a singleTextnode containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attributeText.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
getTextContentin interfaceorg.w3c.dom.Node
getTextContent
final java.lang.String getTextContent(boolean topLevel) throws org.w3c.dom.DOMException
setTextContent
public void setTextContent(java.lang.String textContent) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.Node - This attribute returns the text content of this node and its
descendants. When it is defined to be
null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty ornull, replaced by a singleTextnode containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attributeText.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
setTextContentin interfaceorg.w3c.dom.Node
isSameNode
public boolean isSameNode(org.w3c.dom.Node other)
- Description copied from interface:
org.w3c.dom.Node - Returns whether this node is the same node as the given one.
This method provides a way to determine whether twoNodereferences returned by the implementation reference the same object. When twoNodereferences are references to the same object, even if through a proxy, the references may be used completely interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.- Specified by:
isSameNodein interfaceorg.w3c.dom.Node
lookupPrefix
public java.lang.String lookupPrefix(java.lang.String namespaceURI)
- Description copied from interface:
org.w3c.dom.Node - Look up the prefix associated to the given namespace URI, starting from
this node. The default namespace declarations are ignored by this
method.
See for details on the algorithm used by this method.- Specified by:
lookupPrefixin interfaceorg.w3c.dom.Node
isDefaultNamespace
public boolean isDefaultNamespace(java.lang.String namespaceURI)
- Description copied from interface:
org.w3c.dom.Node - This method checks if the specified
namespaceURIis the default namespace or not.- Specified by:
isDefaultNamespacein interfaceorg.w3c.dom.Node
lookupNamespaceURI
public java.lang.String lookupNamespaceURI(java.lang.String prefix)
- Description copied from interface:
org.w3c.dom.Node - Look up the namespace URI associated to the given prefix, starting from
this node.
See for details on the algorithm used by this method.- Specified by:
lookupNamespaceURIin interfaceorg.w3c.dom.Node
isEqualNode
public boolean isEqualNode(org.w3c.dom.Node arg)
- Description copied from interface:
org.w3c.dom.Node - Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested withNode.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:- The two nodes are of the same type.
- The following string
attributes are equal:
nodeName,localName,namespaceURI,prefix,nodeValue. This is: they are bothnull, or they have the same length and are character for character identical. - The
attributesNamedNodeMapsare equal. This is: they are bothnull, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index. - The
childNodesNodeListsare equal. This is: they are bothnull, or they have the same length and contain equal nodes at the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.
For twoDocumentTypenodes to be equal, the following conditions must also be satisfied:- The following string attributes
are equal:
publicId,systemId,internalSubset. - The
entitiesNamedNodeMapsare equal. - The
notationsNamedNodeMapsare equal.
On the other hand, the following do not affect equality: theownerDocument,baseURI, andparentNodeattributes, thespecifiedattribute forAttrnodes, theschemaTypeInfoattribute forAttrandElementnodes, theText.isElementContentWhitespaceattribute forTextnodes, as well as any user data or event listeners registered on the nodes.Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.
- Specified by:
isEqualNodein interfaceorg.w3c.dom.Node
equal
boolean equal(java.lang.String arg1, java.lang.String arg2)
getFeature
public java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
- Description copied from interface:
org.w3c.dom.Node - This method returns a specialized object which implements the
specialized APIs of the specified feature and version, as specified
in . The specialized object may also be obtained by using
binding-specific casting methods but is not necessarily expected to,
as discussed in . This method also allow the implementation to
provide specialized objects which do not support the
Nodeinterface.- Specified by:
getFeaturein interfaceorg.w3c.dom.Node
setUserData
public java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
- Description copied from interface:
org.w3c.dom.Node - Associate an object to a key on this node. The object can later be
retrieved from this node by calling
getUserDatawith the same key.- Specified by:
setUserDatain interfaceorg.w3c.dom.Node
getUserData
public java.lang.Object getUserData(java.lang.String key)
- Description copied from interface:
org.w3c.dom.Node - Retrieves the object associated to a key on a this node. The object
must first have been set to this node by calling
setUserDatawith the same key.- Specified by:
getUserDatain interfaceorg.w3c.dom.Node
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
encode
java.lang.String encode(java.lang.String value)
nodeTypeToString
java.lang.String nodeTypeToString(short nodeType)
list
public void list(java.io.PrintStream out, int indent)
|
|||||||||
| Home >> All >> gnu >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
gnu.xml.dom.DomNode