Package org.jdesktop.dom
Class SimpleDocument
java.lang.Object
org.jdesktop.dom.SimpleDocument
A DOM Document that makes it easier to work with DOM
documents. This class simply wraps a delegate DOM Document and
delegates all calls to the Document. This allows this class to work with
any DOM Document.
-
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
ConstructorsConstructorDescriptionCreate a new, empty, SimpleDocumentSimpleDocument(String xml)Creates a new instance of SimpleDocument with the given XML.SimpleDocument(Document dom)Creates a new instance of SimpleDocument. -
Method Summary
Modifier and TypeMethodDescriptionappendChild(Node newChild)cloneNode(boolean deep)shortcompareDocumentPosition(Node other)createAttribute(String name)createAttributeNS(String namespaceURI, String qualifiedName)createCDATASection(String data)createComment(String data)createElement(String tagName)createElementNS(String namespaceURI, String qualifiedName)createEntityReference(String name)createProcessingInstruction(String target, String data)createTextNode(String data)intgetChildElementCount(Node node)Returns the number of child elements for the given node.getChildElements(Node node)Returns the child elements of the specified node.getElement(String expression)Returns a Node matching the given expression.getElement(String expression, Node node)Returns a Node matching the given expression.getElementById(String elementId)getElements(String expression)Returns aSimpleNodeListcontaining all the nodes that match the given expression.getElements(String expression, Node node)Returns aSimpleNodeListcontaining all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).getElementsByTagName(String tagname)getElementsByTagNameNS(String namespaceURI, String localName)getFeature(String feature, String version)shortbooleanReturns the text content of the Node matching the given expression.Returns the text content of the Node matching the given expression.getUserData(String key)booleanbooleanbooleanimportNode(Node importedNode, boolean deep)insertBefore(Node newChild, Node refChild)booleanisDefaultNamespace(String namespaceURI)booleanisEqualNode(Node arg)booleanisSameNode(Node other)booleanisSupported(String feature, String version)lookupNamespaceURI(String prefix)lookupPrefix(String namespaceURI)voidvoidremoveChild(Node oldChild)renameNode(Node n, String namespaceURI, String qualifiedName)replaceChild(Node newChild, Node oldChild)voidsetDocumentURI(String documentURI)voidsetNodeValue(String nodeValue)voidvoidsetStrictErrorChecking(boolean strictErrorChecking)voidsetTextContent(String textContent)setUserData(String key, Object data, UserDataHandler handler)voidsetXmlStandalone(boolean xmlStandalone)voidsetXmlVersion(String xmlVersion)toString()toXML()Exports this DOM as a String
-
Constructor Details
-
SimpleDocument
public SimpleDocument()Create a new, empty, SimpleDocument -
SimpleDocument
Creates a new instance of SimpleDocument.- Parameters:
Document- the DOM document to wrap within this SimpleDocument.
-
SimpleDocument
Creates a new instance of SimpleDocument with the given XML. The given XML must be valid.- Parameters:
xml-
-
-
Method Details
-
toString
-
toXML
Exports this DOM as a String -
toXML
-
getChildElements
Returns the child elements of the specified node. This returns only the immediate child Nodes of type ELEMENT_NODE.
- Parameters:
parent- the parent node- Returns:
- a SimpleNodeList containing all of the immediate child elements
-
getChildElementCount
Returns the number of child elements for the given node. Only immediate child nodes of type ELEMENT_NODE are counted.- Parameters:
parent- the parent node- Returns:
- the number of immediate child Elements of the given parent node
-
getElements
Returns aSimpleNodeListcontaining all the nodes that match the given expression.- Parameters:
expression- an XPath expression- Returns:
- SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getElements
Returns aSimpleNodeListcontaining all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).- Parameters:
expression- an XPath expressionnode- the contextual node- Returns:
- SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getElement
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.- Parameters:
expression- an XPath expression- Returns:
- Node. May be null.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getElement
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.- Parameters:
expression- an XPath expressionnode- the contextual node- Returns:
- Node. May be null.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getString
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.- Parameters:
expression- an XPath expression- Returns:
- text content of the selected Node. May be null.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getString
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.- Parameters:
expression- an XPath expressionnode- the contextual node- Returns:
- text content of the selected Node. May be null.
- Throws:
IllegalArgumentException- if the expression does not parse
-
getDoctype
- Specified by:
getDoctypein interfaceDocument
-
getImplementation
- Specified by:
getImplementationin interfaceDocument
-
getDocumentElement
- Specified by:
getDocumentElementin interfaceDocument
-
createElement
- Specified by:
createElementin interfaceDocument- Throws:
DOMException
-
createDocumentFragment
- Specified by:
createDocumentFragmentin interfaceDocument
-
createTextNode
- Specified by:
createTextNodein interfaceDocument
-
createComment
- Specified by:
createCommentin interfaceDocument
-
createCDATASection
- Specified by:
createCDATASectionin interfaceDocument- Throws:
DOMException
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException- Specified by:
createProcessingInstructionin interfaceDocument- Throws:
DOMException
-
createAttribute
- Specified by:
createAttributein interfaceDocument- Throws:
DOMException
-
createEntityReference
- Specified by:
createEntityReferencein interfaceDocument- Throws:
DOMException
-
getElementsByTagName
- Specified by:
getElementsByTagNamein interfaceDocument
-
importNode
- Specified by:
importNodein interfaceDocument- Throws:
DOMException
-
createElementNS
- Specified by:
createElementNSin interfaceDocument- Throws:
DOMException
-
createAttributeNS
- Specified by:
createAttributeNSin interfaceDocument- Throws:
DOMException
-
getElementsByTagNameNS
- Specified by:
getElementsByTagNameNSin interfaceDocument
-
getElementById
- Specified by:
getElementByIdin interfaceDocument
-
getInputEncoding
- Specified by:
getInputEncodingin interfaceDocument
-
getXmlEncoding
- Specified by:
getXmlEncodingin interfaceDocument
-
getXmlStandalone
public boolean getXmlStandalone()- Specified by:
getXmlStandalonein interfaceDocument
-
setXmlStandalone
- Specified by:
setXmlStandalonein interfaceDocument- Throws:
DOMException
-
getXmlVersion
- Specified by:
getXmlVersionin interfaceDocument
-
setXmlVersion
- Specified by:
setXmlVersionin interfaceDocument- Throws:
DOMException
-
getStrictErrorChecking
public boolean getStrictErrorChecking()- Specified by:
getStrictErrorCheckingin interfaceDocument
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking)- Specified by:
setStrictErrorCheckingin interfaceDocument
-
getDocumentURI
- Specified by:
getDocumentURIin interfaceDocument
-
setDocumentURI
- Specified by:
setDocumentURIin interfaceDocument
-
adoptNode
- Specified by:
adoptNodein interfaceDocument- Throws:
DOMException
-
getDomConfig
- Specified by:
getDomConfigin interfaceDocument
-
normalizeDocument
public void normalizeDocument()- Specified by:
normalizeDocumentin interfaceDocument
-
renameNode
- Specified by:
renameNodein interfaceDocument- Throws:
DOMException
-
getNodeName
- Specified by:
getNodeNamein interfaceNode
-
getNodeValue
- Specified by:
getNodeValuein interfaceNode- Throws:
DOMException
-
setNodeValue
- Specified by:
setNodeValuein interfaceNode- Throws:
DOMException
-
getNodeType
public short getNodeType()- Specified by:
getNodeTypein interfaceNode
-
getParentNode
- Specified by:
getParentNodein interfaceNode
-
getChildNodes
- Specified by:
getChildNodesin interfaceNode
-
getFirstChild
- Specified by:
getFirstChildin interfaceNode
-
getLastChild
- Specified by:
getLastChildin interfaceNode
-
getPreviousSibling
- Specified by:
getPreviousSiblingin interfaceNode
-
getNextSibling
- Specified by:
getNextSiblingin interfaceNode
-
getAttributes
- Specified by:
getAttributesin interfaceNode
-
getOwnerDocument
- Specified by:
getOwnerDocumentin interfaceNode
-
insertBefore
- Specified by:
insertBeforein interfaceNode- Throws:
DOMException
-
replaceChild
- Specified by:
replaceChildin interfaceNode- Throws:
DOMException
-
removeChild
- Specified by:
removeChildin interfaceNode- Throws:
DOMException
-
appendChild
- Specified by:
appendChildin interfaceNode- Throws:
DOMException
-
hasChildNodes
public boolean hasChildNodes()- Specified by:
hasChildNodesin interfaceNode
-
cloneNode
-
normalize
public void normalize() -
isSupported
- Specified by:
isSupportedin interfaceNode
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode
-
getPrefix
-
setPrefix
- Specified by:
setPrefixin interfaceNode- Throws:
DOMException
-
getLocalName
- Specified by:
getLocalNamein interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfaceNode
-
getBaseURI
- Specified by:
getBaseURIin interfaceNode
-
compareDocumentPosition
- Specified by:
compareDocumentPositionin interfaceNode- Throws:
DOMException
-
getTextContent
- Specified by:
getTextContentin interfaceNode- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContentin interfaceNode- Throws:
DOMException
-
isSameNode
- Specified by:
isSameNodein interfaceNode
-
lookupPrefix
- Specified by:
lookupPrefixin interfaceNode
-
isDefaultNamespace
- Specified by:
isDefaultNamespacein interfaceNode
-
lookupNamespaceURI
- Specified by:
lookupNamespaceURIin interfaceNode
-
isEqualNode
- Specified by:
isEqualNodein interfaceNode
-
getFeature
- Specified by:
getFeaturein interfaceNode
-
setUserData
- Specified by:
setUserDatain interfaceNode
-
getUserData
- Specified by:
getUserDatain interfaceNode
-