Package com.jsevy.jxml
Class XMLNode
- java.lang.Object
-
- com.jsevy.jxml.XMLNode
-
- All Implemented Interfaces:
java.lang.Cloneable
,org.w3c.dom.Node
- Direct Known Subclasses:
XMLAttribute
,XMLCharacterData
,XMLDocument
,XMLDocumentType
,XMLElement
,XMLEntity
,XMLNotation
public abstract class XMLNode extends java.lang.Object implements org.w3c.dom.Node, java.lang.Cloneable
Class representing a general XML node. Can have children, attributes, and plain text associated with it.- Author:
- jsevy
-
-
Field Summary
-
Fields inherited from interface org.w3c.dom.Node
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 Summary
Constructors Constructor Description XMLNode()
Create a new empty anonymous (unnamed) XML node.XMLNode(java.lang.String name)
Create an empty XML node with the specified name.XMLNode(java.lang.String name, java.lang.String text)
Create an XML node with the specified name and containing the specified text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Node
appendChild(org.w3c.dom.Node newChild)
java.lang.Object
clone()
Define this to catch pesky CloneNotSupported exception, which will never happen...org.w3c.dom.Node
cloneNode(boolean deep)
short
compareDocumentPosition(org.w3c.dom.Node other)
boolean
equals(java.lang.Object other)
org.w3c.dom.NamedNodeMap
getAttributes()
java.lang.String
getBaseURI()
org.w3c.dom.NodeList
getChildNodes()
XMLNodeList
getDescendants()
java.lang.Object
getFeature(java.lang.String feature, java.lang.String version)
org.w3c.dom.Node
getFirstChild()
org.w3c.dom.Node
getLastChild()
java.lang.String
getLocalName()
java.lang.String
getNamespaceURI()
org.w3c.dom.Node
getNextSibling()
java.lang.String
getNodeName()
java.lang.String
getNodeValue()
org.w3c.dom.Document
getOwnerDocument()
org.w3c.dom.Node
getParentNode()
java.lang.String
getPrefix()
org.w3c.dom.Node
getPreviousSibling()
java.lang.Object
getUserData(java.lang.String key)
boolean
hasAttributes()
boolean
hasChildNodes()
org.w3c.dom.Node
insertAfter(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
org.w3c.dom.Node
insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
boolean
isDefaultNamespace(java.lang.String namespaceURI)
boolean
isEqualNode(org.w3c.dom.Node other)
Two nodes are equal if and only if the following conditions are satisfied: - The two nodes are of the same type.boolean
isSameNode(org.w3c.dom.Node other)
boolean
isSupported(java.lang.String feature, java.lang.String version)
java.lang.String
lookupNamespaceURI(java.lang.String prefix)
java.lang.String
lookupPrefix(java.lang.String namespaceURI)
void
normalize()
org.w3c.dom.Node
prependChild(org.w3c.dom.Node newChild)
org.w3c.dom.Node
removeChild(org.w3c.dom.Node oldChild)
org.w3c.dom.Node
replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
void
setNamespaceURI(java.lang.String namespaceURI)
void
setNodeName(java.lang.String nodeName)
Note that this sets the non-prefixed part of the name - the local namevoid
setNodeValue(java.lang.String nodeValue)
void
setOwnerDocument(org.w3c.dom.Document owner, boolean deep)
void
setParentNode(org.w3c.dom.Node parent)
void
setPrefix(java.lang.String prefix)
void
setTextContent(java.lang.String textContent)
java.lang.Object
setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
-
-
-
Constructor Detail
-
XMLNode
public XMLNode()
Create a new empty anonymous (unnamed) XML node.
-
XMLNode
public XMLNode(java.lang.String name)
Create an empty XML node with the specified name.- Parameters:
name
- Name for the node.
-
XMLNode
public XMLNode(java.lang.String name, java.lang.String text)
Create an XML node with the specified name and containing the specified text.- Parameters:
name
- Name for the node.text
- Text contained by the node.
-
-
Method Detail
-
getNodeName
public java.lang.String getNodeName()
- Specified by:
getNodeName
in interfaceorg.w3c.dom.Node
-
setNodeName
public void setNodeName(java.lang.String nodeName)
Note that this sets the non-prefixed part of the name - the local name- Parameters:
nodeName
-
-
getNodeValue
public java.lang.String getNodeValue() throws org.w3c.dom.DOMException
- Specified by:
getNodeValue
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
setNodeValue
public void setNodeValue(java.lang.String nodeValue) throws org.w3c.dom.DOMException
- Specified by:
setNodeValue
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
getParentNode
public org.w3c.dom.Node getParentNode()
- Specified by:
getParentNode
in interfaceorg.w3c.dom.Node
-
setParentNode
public void setParentNode(org.w3c.dom.Node parent)
-
getChildNodes
public org.w3c.dom.NodeList getChildNodes()
- Specified by:
getChildNodes
in interfaceorg.w3c.dom.Node
-
getDescendants
public XMLNodeList getDescendants()
-
getFirstChild
public org.w3c.dom.Node getFirstChild()
- Specified by:
getFirstChild
in interfaceorg.w3c.dom.Node
-
getLastChild
public org.w3c.dom.Node getLastChild()
- Specified by:
getLastChild
in interfaceorg.w3c.dom.Node
-
getPreviousSibling
public org.w3c.dom.Node getPreviousSibling()
- Specified by:
getPreviousSibling
in interfaceorg.w3c.dom.Node
-
getNextSibling
public org.w3c.dom.Node getNextSibling()
- Specified by:
getNextSibling
in interfaceorg.w3c.dom.Node
-
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
- Specified by:
getAttributes
in interfaceorg.w3c.dom.Node
-
getOwnerDocument
public org.w3c.dom.Document getOwnerDocument()
- Specified by:
getOwnerDocument
in interfaceorg.w3c.dom.Node
-
setOwnerDocument
public void setOwnerDocument(org.w3c.dom.Document owner, boolean deep)
-
insertBefore
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws org.w3c.dom.DOMException
- Specified by:
insertBefore
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
insertAfter
public org.w3c.dom.Node insertAfter(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws org.w3c.dom.DOMException
- Throws:
org.w3c.dom.DOMException
-
replaceChild
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws org.w3c.dom.DOMException
- Specified by:
replaceChild
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
removeChild
public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws org.w3c.dom.DOMException
- Specified by:
removeChild
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
appendChild
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws org.w3c.dom.DOMException
- Specified by:
appendChild
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
prependChild
public org.w3c.dom.Node prependChild(org.w3c.dom.Node newChild) throws org.w3c.dom.DOMException
- Throws:
org.w3c.dom.DOMException
-
hasChildNodes
public boolean hasChildNodes()
- Specified by:
hasChildNodes
in interfaceorg.w3c.dom.Node
-
clone
public java.lang.Object clone()
Define this to catch pesky CloneNotSupported exception, which will never happen...
-
cloneNode
public org.w3c.dom.Node cloneNode(boolean deep)
- Specified by:
cloneNode
in interfaceorg.w3c.dom.Node
-
normalize
public void normalize()
- Specified by:
normalize
in interfaceorg.w3c.dom.Node
-
isSupported
public boolean isSupported(java.lang.String feature, java.lang.String version)
- Specified by:
isSupported
in interfaceorg.w3c.dom.Node
-
getNamespaceURI
public java.lang.String getNamespaceURI()
- Specified by:
getNamespaceURI
in interfaceorg.w3c.dom.Node
-
setNamespaceURI
public void setNamespaceURI(java.lang.String namespaceURI)
-
getPrefix
public java.lang.String getPrefix()
- Specified by:
getPrefix
in interfaceorg.w3c.dom.Node
-
setPrefix
public void setPrefix(java.lang.String prefix) throws org.w3c.dom.DOMException
- Specified by:
setPrefix
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
getLocalName
public java.lang.String getLocalName()
- Specified by:
getLocalName
in interfaceorg.w3c.dom.Node
-
hasAttributes
public boolean hasAttributes()
- Specified by:
hasAttributes
in interfaceorg.w3c.dom.Node
-
getBaseURI
public java.lang.String getBaseURI()
- Specified by:
getBaseURI
in interfaceorg.w3c.dom.Node
-
compareDocumentPosition
public short compareDocumentPosition(org.w3c.dom.Node other) throws org.w3c.dom.DOMException
- Specified by:
compareDocumentPosition
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
setTextContent
public void setTextContent(java.lang.String textContent) throws org.w3c.dom.DOMException
- Specified by:
setTextContent
in interfaceorg.w3c.dom.Node
- Throws:
org.w3c.dom.DOMException
-
isSameNode
public boolean isSameNode(org.w3c.dom.Node other)
- Specified by:
isSameNode
in interfaceorg.w3c.dom.Node
-
lookupPrefix
public java.lang.String lookupPrefix(java.lang.String namespaceURI)
- Specified by:
lookupPrefix
in interfaceorg.w3c.dom.Node
-
isDefaultNamespace
public boolean isDefaultNamespace(java.lang.String namespaceURI)
- Specified by:
isDefaultNamespace
in interfaceorg.w3c.dom.Node
-
lookupNamespaceURI
public java.lang.String lookupNamespaceURI(java.lang.String prefix)
- Specified by:
lookupNamespaceURI
in interfaceorg.w3c.dom.Node
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
isEqualNode
public boolean isEqualNode(org.w3c.dom.Node other)
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 both null, or they have the same length and are character for character identical. - The attributes NamedNodeMaps are equal. This is: they are both null, 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 childNodes NodeLists are equal. This is: they are both null, 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 two DocumentType nodes to be equal, the following conditions must also be satisfied: - The following string attributes are equal: publicId, systemId, internalSubset. - The entities NamedNodeMaps are equal. - The notations NamedNodeMaps are equal. On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.- Specified by:
isEqualNode
in interfaceorg.w3c.dom.Node
-
getFeature
public java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
- Specified by:
getFeature
in interfaceorg.w3c.dom.Node
-
setUserData
public java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
- Specified by:
setUserData
in interfaceorg.w3c.dom.Node
-
getUserData
public java.lang.Object getUserData(java.lang.String key)
- Specified by:
getUserData
in interfaceorg.w3c.dom.Node
-
-