|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jaxen.dom.NamespaceNode
Extension DOM2 node type for a Namespace Declaration.
This class implements the DOM2 Node
interface to
allow Namespace declarations to be included in the result
set of an XPath selectNodes operation, even though DOM2 does
not model Namespace declarations as separate nodes.
While all of the 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
).
This class has only protected constructors, so that it can be
instantiated only by DocumentNavigator
.
DocumentNavigator
Field Summary | |
static short |
NAMESPACE_NODE
Constant: this is a NamespaceNode. |
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 | |
NamespaceNode(Node parent,
String name,
String value)
Constructor. |
Method Summary | |
Node |
appendChild(Node newChild)
Append a new child node (always fails). |
Node |
cloneNode(boolean deep)
Create a copy of this node. |
boolean |
equals(Object o)
Test for equivalence with another object. |
NamedNodeMap |
getAttributes()
Get the attribute nodes. |
NodeList |
getChildNodes()
Get the list of child nodes. |
Node |
getFirstChild()
Get the first child node. |
Node |
getLastChild()
Get the last child node. |
String |
getLocalName()
Get the local name for this node. |
String |
getNamespaceURI()
Get the Namespace URI for 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 for this node. |
Node |
getPreviousSibling()
Get the previous sibling node. |
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 |
isSupported(String feature,
String version)
Test if a DOM2 feature is supported. |
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 for this node (always fails). |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final short NAMESPACE_NODE
getNodeType()
Constructor Detail |
public NamespaceNode(Node parent, String name, String value)
parent
- The DOM node to which the Namespace is attached.uri
- The Namespace URI as a string.Method Detail |
public String getNodeName()
getNodeName
in interface Node
public String getNodeValue()
getNodeValue
in interface Node
public void setNodeValue(String value) throws DOMException
setNodeValue
in interface Node
value
- The new URI.DOMException
- always thrown.public short getNodeType()
getNodeType
in interface Node
NAMESPACE_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 Node
public NodeList getChildNodes()
getChildNodes
in interface Node
public Node getFirstChild()
getFirstChild
in interface Node
public Node getLastChild()
getLastChild
in interface Node
public Node getPreviousSibling()
getPreviousSibling
in interface Node
public Node getNextSibling()
getNextSibling
in interface Node
public NamedNodeMap getAttributes()
getAttributes
in interface Node
public Document getOwnerDocument()
getOwnerDocument
in interface Node
public Node insertBefore(Node newChild, Node refChild) throws DOMException
insertBefore
in interface Node
DOMException
- always thrown.Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
replaceChild
in interface Node
DOMException
- always thrown.Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
public Node removeChild(Node oldChild) throws DOMException
removeChild
in interface Node
DOMException
- always thrown.Node.removeChild(org.w3c.dom.Node)
public Node appendChild(Node newChild) throws DOMException
appendChild
in interface Node
DOMException
- always thrown.Node.appendChild(org.w3c.dom.Node)
public boolean hasChildNodes()
hasChildNodes
in interface Node
public Node cloneNode(boolean deep)
cloneNode
in interface Node
deep
- Make a deep copy (no effect, since Namespace nodes
don't have children).public void normalize()
This method has no effect, since Namespace nodes have no descendants.
normalize
in interface Node
public boolean isSupported(String feature, String version)
isSupported
in interface Node
feature
- The feature name.version
- The feature version.public String getNamespaceURI()
Namespace declarations are not themselves Namespace-qualified.
getNamespaceURI
in interface Node
public String getPrefix()
Namespace declarations are not themselves Namespace-qualified.
getPrefix
in interface Node
public void setPrefix(String prefix) throws DOMException
setPrefix
in interface Node
prefix
- The new prefix.DOMException
- always thrown.public String getLocalName()
getLocalName
in interface Node
public boolean hasAttributes()
hasAttributes
in interface Node
public int hashCode()
The hash code is the sum of the hash codes of the parent node, name, and value.
hashCode
in class Object
public boolean equals(Object o)
Two Namespace nodes are considered equivalent if their parents, names, and values are equal.
equals
in class Object
o
- The object to test for equality.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |