Groovy Documentation

org.jdesktop.dom
[Java] Class SimpleDocument

java.lang.Object
  org.jdesktop.dom.SimpleDocument
All Implemented Interfaces:
org.w3c.dom.Document

public class SimpleDocument
extends Object

A DOM org.w3c.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.

Authors:
rbair


Field Summary
private Map cachedExpressions

private org.w3c.dom.Document dom

private XPath xpath

 
Constructor Summary
SimpleDocument()

Create a new, empty, SimpleDocument

SimpleDocument(org.w3c.dom.Document dom)

Creates a new instance of SimpleDocument.

SimpleDocument(String xml)

Creates a new instance of SimpleDocument with the given XML.

 
Method Summary
org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)

org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)

org.w3c.dom.Node cloneNode(boolean deep)

short compareDocumentPosition(org.w3c.dom.Node other)

private XPathExpression compile(String expression)

Compiles the specified expression, and caches the expression in a SoftReference, so that under stress it can be reclaimed by the system.

org.w3c.dom.Attr createAttribute(String name)

org.w3c.dom.Attr createAttributeNS(String namespaceURI, String qualifiedName)

org.w3c.dom.CDATASection createCDATASection(String data)

org.w3c.dom.Comment createComment(String data)

org.w3c.dom.DocumentFragment createDocumentFragment()

org.w3c.dom.Element createElement(String tagName)

org.w3c.dom.Element createElementNS(String namespaceURI, String qualifiedName)

org.w3c.dom.EntityReference createEntityReference(String name)

org.w3c.dom.ProcessingInstruction createProcessingInstruction(String target, String data)

org.w3c.dom.Text createTextNode(String data)

org.w3c.dom.NamedNodeMap getAttributes()

String getBaseURI()

int getChildElementCount(org.w3c.dom.Node node)

Returns the number of child elements for the given node.

SimpleNodeList getChildElements(org.w3c.dom.Node node)

SimpleNodeList getChildNodes()

org.w3c.dom.DocumentType getDoctype()

@inheritDoc

org.w3c.dom.Element getDocumentElement()

String getDocumentURI()

org.w3c.dom.DOMConfiguration getDomConfig()

org.w3c.dom.Node getElement(String expression)

Returns a Node matching the given expression.

org.w3c.dom.Node getElement(String expression, org.w3c.dom.Node node)

Returns a Node matching the given expression.

org.w3c.dom.Element getElementById(String elementId)

SimpleNodeList getElements(String expression)

Returns a SimpleNodeList containing all the nodes that match the given expression.

SimpleNodeList getElements(String expression, org.w3c.dom.Node node)

Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).

SimpleNodeList getElementsByTagName(String tagname)

SimpleNodeList getElementsByTagNameNS(String namespaceURI, String localName)

Object getFeature(String feature, String version)

org.w3c.dom.Node getFirstChild()

org.w3c.dom.DOMImplementation getImplementation()

String getInputEncoding()

org.w3c.dom.Node getLastChild()

String getLocalName()

String getNamespaceURI()

org.w3c.dom.Node getNextSibling()

String getNodeName()

short getNodeType()

String getNodeValue()

org.w3c.dom.Document getOwnerDocument()

org.w3c.dom.Node getParentNode()

String getPrefix()

org.w3c.dom.Node getPreviousSibling()

boolean getStrictErrorChecking()

String getString(String expression)

Returns the text content of the Node matching the given expression.

String getString(String expression, org.w3c.dom.Node node)

Returns the text content of the Node matching the given expression.

String getTextContent()

Object getUserData(String key)

String getXmlEncoding()

boolean getXmlStandalone()

String getXmlVersion()

boolean hasAttributes()

boolean hasChildNodes()

org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)

org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)

boolean isDefaultNamespace(String namespaceURI)

boolean isEqualNode(org.w3c.dom.Node arg)

boolean isSameNode(org.w3c.dom.Node other)

boolean isSupported(String feature, String version)

String lookupNamespaceURI(String prefix)

String lookupPrefix(String namespaceURI)

void normalize()

void normalizeDocument()

org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)

org.w3c.dom.Node renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName)

org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)

void setDocumentURI(String documentURI)

void setNodeValue(String nodeValue)

void setPrefix(String prefix)

void setStrictErrorChecking(boolean strictErrorChecking)

void setTextContent(String textContent)

Object setUserData(String key, Object data, org.w3c.dom.UserDataHandler handler)

void setXmlStandalone(boolean xmlStandalone)

void setXmlVersion(String xmlVersion)

String toString()

String toXML()

Exports this DOM as a String

String toXML(org.w3c.dom.Node n)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

cachedExpressions

private Map cachedExpressions


dom

private org.w3c.dom.Document dom


xpath

private XPath xpath


 
Constructor Detail

SimpleDocument

public SimpleDocument()
Create a new, empty, SimpleDocument


SimpleDocument

public SimpleDocument(org.w3c.dom.Document dom)
Creates a new instance of SimpleDocument.
Parameters:
Document - the DOM document to wrap within this SimpleDocument.


SimpleDocument

public SimpleDocument(String xml)
Creates a new instance of SimpleDocument with the given XML. The given XML must be valid.
Parameters:
xml


 
Method Detail

adoptNode

public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)


appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)


cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)


compareDocumentPosition

public short compareDocumentPosition(org.w3c.dom.Node other)


compile

private XPathExpression compile(String expression)
Compiles the specified expression, and caches the expression in a SoftReference, so that under stress it can be reclaimed by the system.
returns:
the compiled expression as an XPathExpression
Parameters:
expression - the expression to compile


createAttribute

public org.w3c.dom.Attr createAttribute(String name)


createAttributeNS

public org.w3c.dom.Attr createAttributeNS(String namespaceURI, String qualifiedName)


createCDATASection

public org.w3c.dom.CDATASection createCDATASection(String data)


createComment

public org.w3c.dom.Comment createComment(String data)


createDocumentFragment

public org.w3c.dom.DocumentFragment createDocumentFragment()


createElement

public org.w3c.dom.Element createElement(String tagName)


createElementNS

public org.w3c.dom.Element createElementNS(String namespaceURI, String qualifiedName)


createEntityReference

public org.w3c.dom.EntityReference createEntityReference(String name)


createProcessingInstruction

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(String target, String data)


createTextNode

public org.w3c.dom.Text createTextNode(String data)


getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()


getBaseURI

public String getBaseURI()


getChildElementCount

public int getChildElementCount(org.w3c.dom.Node node)
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


getChildElements

public SimpleNodeList getChildElements(org.w3c.dom.Node node)

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


getChildNodes

public SimpleNodeList getChildNodes()


getDoctype

public org.w3c.dom.DocumentType getDoctype()
inheritDoc:


getDocumentElement

public org.w3c.dom.Element getDocumentElement()


getDocumentURI

public String getDocumentURI()


getDomConfig

public org.w3c.dom.DOMConfiguration getDomConfig()


getElement

public org.w3c.dom.Node getElement(String expression)
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
Returns:
Node. May be null.


getElement

public org.w3c.dom.Node getElement(String expression, org.w3c.dom.Node node)
Returns a Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
Node. May be null.


getElementById

public org.w3c.dom.Element getElementById(String elementId)


getElements

public SimpleNodeList getElements(String expression)
Returns a SimpleNodeList containing all the nodes that match the given expression.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
Returns:
SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.


getElements

public SimpleNodeList getElements(String expression, org.w3c.dom.Node node)
Returns a SimpleNodeList containing all the nodes that match the given expression when executed on the given node (as opposed to the dom as a whole).
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
SimpleNodeList containing the results from the expression. This will never be null, but may contain no results.


getElementsByTagName

public SimpleNodeList getElementsByTagName(String tagname)


getElementsByTagNameNS

public SimpleNodeList getElementsByTagNameNS(String namespaceURI, String localName)


getFeature

public Object getFeature(String feature, String version)


getFirstChild

public org.w3c.dom.Node getFirstChild()


getImplementation

public org.w3c.dom.DOMImplementation getImplementation()


getInputEncoding

public String getInputEncoding()


getLastChild

public org.w3c.dom.Node getLastChild()


getLocalName

public String getLocalName()


getNamespaceURI

public String getNamespaceURI()


getNextSibling

public org.w3c.dom.Node getNextSibling()


getNodeName

public String getNodeName()


getNodeType

public short getNodeType()


getNodeValue

public String getNodeValue()


getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()


getParentNode

public org.w3c.dom.Node getParentNode()


getPrefix

public String getPrefix()


getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()


getStrictErrorChecking

public boolean getStrictErrorChecking()


getString

public String getString(String expression)
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
Returns:
text content of the selected Node. May be null.


getString

public String getString(String expression, org.w3c.dom.Node node)
Returns the text content of the Node matching the given expression. If more than one node matches, the return value is undefined.
throws:
IllegalArgumentException if the expression does not parse
Parameters:
expression - an XPath expression
node - the contextual node
Returns:
text content of the selected Node. May be null.


getTextContent

public String getTextContent()


getUserData

public Object getUserData(String key)


getXmlEncoding

public String getXmlEncoding()


getXmlStandalone

public boolean getXmlStandalone()


getXmlVersion

public String getXmlVersion()


hasAttributes

public boolean hasAttributes()


hasChildNodes

public boolean hasChildNodes()


importNode

public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)


insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)


isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)


isEqualNode

public boolean isEqualNode(org.w3c.dom.Node arg)


isSameNode

public boolean isSameNode(org.w3c.dom.Node other)


isSupported

public boolean isSupported(String feature, String version)


lookupNamespaceURI

public String lookupNamespaceURI(String prefix)


lookupPrefix

public String lookupPrefix(String namespaceURI)


normalize

public void normalize()


normalizeDocument

public void normalizeDocument()


removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)


renameNode

public org.w3c.dom.Node renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName)


replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)


setDocumentURI

public void setDocumentURI(String documentURI)


setNodeValue

public void setNodeValue(String nodeValue)


setPrefix

public void setPrefix(String prefix)


setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)


setTextContent

public void setTextContent(String textContent)


setUserData

public Object setUserData(String key, Object data, org.w3c.dom.UserDataHandler handler)


setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)


setXmlVersion

public void setXmlVersion(String xmlVersion)


toString

public String toString()


toXML

public String toXML()
Exports this DOM as a String


toXML

public String toXML(org.w3c.dom.Node n)


 

Groovy Documentation