org.jaxen.dom
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.
All attempts to modify a NamespaceNode
will fail with a DOMException ( DOMException#NO_MODIFICATION_ALLOWED_ERR).
See Also: DocumentNavigator
Nested Class Summary | |
---|---|
static class | NamespaceNode.EmptyNodeList
A node list with no members.
|
Field Summary | |
---|---|
String | name |
static short | NAMESPACE_NODE
Constant: this is a NamespaceNode.
|
Node | parent |
HashMap | userData |
String | value |
Constructor Summary | |
---|---|
NamespaceNode(Node parent, String name, String value)
Create a new NamespaceNode.
| |
NamespaceNode(Node parent, Node attribute)
Constructor.
|
Method Summary | |
---|---|
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. |
void | disallowModification()
Throw a NO_MODIFICATION_ALLOWED_ERR DOMException.
|
boolean | equals(Object o)
Test for equivalence with another object.
|
boolean | equals(Object a, Object b)
Helper method for comparing two objects.
|
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. the
namespace prefix.
|
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.
|
int | hashCode(Object o)
Helper method for generating a hash code.
|
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.
|
See Also: NamespaceNode
Parameters: parent the DOM node to which the namespace is attached name the namespace prefix value the namespace URI
Parameters: parent the DOM node to which the namespace is attached attribute the DOM attribute object containing the namespace declaration
Parameters: newChild the node to add
Returns: never
Throws: DOMException always
See Also: Node#appendChild
Parameters: deep make a deep copy (no effect, since namespace nodes don't have children).
Returns: a new copy of this namespace node
Parameters: other the node to compare to
Returns: never
Throws: DOMException NOT_SUPPORTED_ERR
Throws: DOMException always thrown
Two Namespace nodes are considered equivalent if their parents, names, and values are equal.
Parameters: o the object to test for equality
Returns: true if the object is equivalent to this node, false otherwise
Parameters: a the first object to compare (possibly null) b the second object to compare (possibly null)
Returns: true if the objects are equivalent or are both null
See Also: java.lang.Object#equals
Returns: null
Returns: null
Returns: an empty node list
Returns: null
Returns: null
Returns: null
Returns: the namespace prefix
Namespace declarations are not themselves Namespace-qualified.
Returns: null
Returns: null
Returns: the namespace prefix, or "" for the default namespace
Returns: always NAMESPACE_NODE.
Returns: the namespace URI
Returns: the owner document of the parent node
This method returns the element that was queried for Namespaces in effect, not necessarily the actual element containing the Namespace declaration.
Returns: the parent node (not null)
Namespace declarations are not themselves namespace-qualified.
Returns: null
See Also: NamespaceNode
Returns: null
Returns: the namespace URI
See Also: NamespaceNode
Parameters: key the lookup key
Returns: the object associated with the key; or null if no such object is available
Returns: false
Returns: false
Returns: a hash code for this node
Parameters: o the object for generating a hash code (possibly null)
Returns: the object's hash code, or 0 if the object is null
See Also: java.lang.Object#hashCode
Parameters: newChild the node to add refChild ignored
Returns: never
Throws: DOMException always
See Also: Node#insertBefore
Parameters: namespaceURI the URI to check
Returns: never
Throws: UnsupportedOperationException always
Parameters: arg the node to compare to
Returns: true if this object has the same prefix and URI as the argument; false otherwise
Parameters: other the node to compare to
Returns: true if this object represents the same XPath namespace node as other; false otherwise
Parameters: feature the feature name version the feature version
Returns: false
Parameters: prefix the prefix to search for
Returns: the namespace URI mapped to this prefix
Throws: UnsupportedOperationException in DOM 2
Parameters: namespaceURI the URI to find a prefix binding for
Returns: a prefix matching this namespace URI
Throws: UnsupportedOperationException in DOM 2
This method has no effect, since namespace nodes have no descendants.
Parameters: oldChild the child node to remove
Returns: never
Throws: DOMException always
See Also: Node#removeChild
Parameters: newChild the node to add oldChild the child node to replace
Returns: never
Throws: DOMException always
See Also: Node#replaceChild
Parameters: value the new URI
Throws: DOMException always
Parameters: prefix the new prefix
Throws: DOMException always thrown
Parameters: textContent the new content
Throws: DOMException always
Parameters: key the key by which the data will be retrieved data the object to store with the key handler ignored since namespace nodes cannot be imported, cloned, or renamed
Returns: the value previously associated with this key; or null if there isn't any such previous value