public class NamespaceNode extends Object implements Node
This class implements the DOM2 and DOM3 Node interface
to allow namespace nodes to be included in the result
set of an XPath selectNodes operation, even though DOM does
not model namespaces in scope as separate nodes.
While all of the DOM2 methods are implemented with reasonable defaults, there will be some unexpected surprises, so users are advised to test for NamespaceNodes and filter them out from the result sets as early as possible.
getNodeType() method returns NAMESPACE_NODE,
which is not one of the usual DOM2 node types. Generic code may
fall unexpectedly out of switch statements, for example.getOwnerDocument() method returns the owner document
of the parent node, but that owner document will know nothing about
the namespace node.
isSupported(java.lang.String, java.lang.String) method always returns false.All attempts to modify a NamespaceNode will fail with a DOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR).
DocumentNavigator| Modifier and Type | Field and Description |
|---|---|
static short |
NAMESPACE_NODE
Constant: this is a NamespaceNode.
|
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 and Description |
|---|
NamespaceNode(Node parent,
String name,
String value)
Create a new NamespaceNode.
|
| Modifier and Type | Method and Description |
|---|---|
Node |
appendChild(Node newChild)
Append a new child node (always fails).
|
Node |
cloneNode(boolean deep)
Create a copy of this node.
|
short |
compareDocumentPosition(Node other)
Compare relative position of this node to another nbode.
|
boolean |
equals(Object o)
Test for equivalence with another object.
|
NamedNodeMap |
getAttributes()
Get the attribute nodes.
|
String |
getBaseURI()
Return the base URI of the document containing this node.
|
NodeList |
getChildNodes()
Get the list of child nodes.
|
Object |
getFeature(String feature,
String version)
Returns the value of the requested feature.
|
Node |
getFirstChild()
Get the first child node.
|
Node |
getLastChild()
Get the last child node.
|
String |
getLocalName()
Get the XPath name of the namespace node;; i.e.
|
String |
getNamespaceURI()
Get the namespace URI of this node.
|
Node |
getNextSibling()
Get the next sibling node.
|
String |
getNodeName()
Get the namespace prefix.
|
short |
getNodeType()
Get the node type.
|
String |
getNodeValue()
Get the namespace URI.
|
Document |
getOwnerDocument()
Get the owner document.
|
Node |
getParentNode()
Get the parent node.
|
String |
getPrefix()
Get the namespace prefix of this node.
|
Node |
getPreviousSibling()
Get the previous sibling node.
|
String |
getTextContent()
Return the namespace URI.
|
Object |
getUserData(String key)
Returns the user data associated with the given key.
|
boolean |
hasAttributes()
Test if this node has attributes.
|
boolean |
hasChildNodes()
Test for child nodes.
|
int |
hashCode()
Generate a hash code for a namespace node.
|
Node |
insertBefore(Node newChild,
Node refChild)
Insert a new child node (always fails).
|
boolean |
isDefaultNamespace(String namespaceURI)
Return true if the specified URI is the default namespace in
scope (always fails).
|
boolean |
isEqualNode(Node arg)
Returns true if this object binds the same prefix to the same URI.
|
boolean |
isSameNode(Node other)
Returns true if and only if this object represents the same XPath namespace node
as the argument; that is, they have the same parent, the same prefix, and the
same URI.
|
boolean |
isSupported(String feature,
String version)
Test if a DOM2 feature is supported.
|
String |
lookupNamespaceURI(String prefix)
Return the namespace URI mapped to the specified
prefix within the scope of this namespace node.
|
String |
lookupPrefix(String namespaceURI)
Return the prefix bound to this namespace URI within the scope
of this node.
|
void |
normalize()
Normalize the text descendants of this node.
|
Node |
removeChild(Node oldChild)
Remove a child node (always fails).
|
Node |
replaceChild(Node newChild,
Node oldChild)
Replace a child node (always fails).
|
void |
setNodeValue(String value)
Change the namespace URI (always fails).
|
void |
setPrefix(String prefix)
Change the namespace prefix of this node (always fails).
|
void |
setTextContent(String textContent)
Change the value of this node (always fails).
|
Object |
setUserData(String key,
Object data,
UserDataHandler handler)
Associates an object with a key.
|
public static final short NAMESPACE_NODE
getNodeType(),
Constant Field Valuespublic String getNodeName()
getNodeName in interface Nodepublic String getNodeValue()
getNodeValue in interface Nodepublic void setNodeValue(String value) throws DOMException
setNodeValue in interface Nodevalue - the new URIDOMException - alwayspublic short getNodeType()
getNodeType in interface NodeNAMESPACE_NODE.public Node getParentNode()
This method returns the element that was queried for Namespaces in effect, not necessarily the actual element containing the Namespace declaration.
getParentNode in interface Nodepublic NodeList getChildNodes()
getChildNodes in interface Nodepublic Node getFirstChild()
getFirstChild in interface Nodepublic Node getLastChild()
getLastChild in interface Nodepublic Node getPreviousSibling()
getPreviousSibling in interface Nodepublic Node getNextSibling()
getNextSibling in interface Nodepublic NamedNodeMap getAttributes()
getAttributes in interface Nodepublic Document getOwnerDocument()
getOwnerDocument in interface Nodepublic Node insertBefore(Node newChild, Node refChild) throws DOMException
insertBefore in interface NodenewChild - the node to addrefChild - ignoredDOMException - alwaysNode.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)public Node replaceChild(Node newChild, Node oldChild) throws DOMException
replaceChild in interface NodenewChild - the node to addoldChild - the child node to replaceDOMException - alwaysNode.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)public Node removeChild(Node oldChild) throws DOMException
removeChild in interface NodeoldChild - the child node to removeDOMException - alwaysNode.removeChild(org.w3c.dom.Node)public Node appendChild(Node newChild) throws DOMException
appendChild in interface NodenewChild - the node to addDOMException - alwaysNode.appendChild(org.w3c.dom.Node)public boolean hasChildNodes()
hasChildNodes in interface Nodepublic Node cloneNode(boolean deep)
public void normalize()
This method has no effect, since namespace nodes have no descendants.
public boolean isSupported(String feature, String version)
isSupported in interface Nodefeature - the feature nameversion - the feature versionpublic String getNamespaceURI()
Namespace declarations are not themselves Namespace-qualified.
getNamespaceURI in interface Nodepublic String getPrefix()
Namespace declarations are not themselves namespace-qualified.
getPrefix in interface NodegetLocalName()public void setPrefix(String prefix) throws DOMException
setPrefix in interface Nodeprefix - the new prefixDOMException - always thrownpublic String getLocalName()
getLocalName in interface Nodepublic boolean hasAttributes()
hasAttributes in interface Nodepublic int hashCode()
public boolean equals(Object o)
Two Namespace nodes are considered equivalent if their parents, names, and values are equal.
public String getBaseURI()
getBaseURI in interface Nodepublic short compareDocumentPosition(Node other) throws DOMException
compareDocumentPosition in interface Nodeother - the node to compare toDOMException - NOT_SUPPORTED_ERRpublic String getTextContent()
getTextContent in interface NodegetNodeValue()public void setTextContent(String textContent) throws DOMException
setTextContent in interface NodetextContent - the new contentDOMException - alwayspublic boolean isSameNode(Node other)
isSameNode in interface Nodeother - the node to compare topublic String lookupPrefix(String namespaceURI)
lookupPrefix in interface NodenamespaceURI - the URI to find a prefix binding forUnsupportedOperationException - in DOM 2public boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace in interface NodenamespaceURI - the URI to checkUnsupportedOperationException - alwayspublic String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodeprefix - the prefix to search forUnsupportedOperationException - in DOM 2public boolean isEqualNode(Node arg)
isEqualNode in interface Nodearg - the node to compare topublic Object getFeature(String feature, String version)
getFeature in interface Nodepublic Object setUserData(String key, Object data, UserDataHandler handler)
setUserData in interface Nodekey - the key by which the data will be retrieveddata - the object to store with the keyhandler - ignored since namespace nodes cannot be imported, cloned, or renamedpublic Object getUserData(String key)
getUserData in interface Nodekey - the lookup keyCopyright © 2001-2012 Codehaus. All Rights Reserved.