Groovy Documentation

org.jdesktop.dom
[Java] Class SimpleHtmlDocument

java.lang.Object
  org.jdesktop.dom.SimpleHtmlDocument
All Implemented Interfaces:
org.w3c.dom.html.HTMLDocument

public class SimpleHtmlDocument
extends Object

A DOM org.w3c.dom.Document that makes it easier to work with DOM documents. This class simply wraps a delegate HTMLDocument and delegates all calls to the Document. This allows this class to work with any HTMLDocument.

Authors:
rbair


Field Summary
private Map cachedExpressions

private org.w3c.dom.html.HTMLDocument dom

private XPath xpath

 
Constructor Summary
SimpleHtmlDocument()

Create a new, empty, SimpleHtmlDocument

SimpleHtmlDocument(org.w3c.dom.html.HTMLDocument dom)

Creates a new instance of SimpleHtmlDocument.

 
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)

void close()

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)

SimpleHtmlCollection getAnchors()

SimpleHtmlCollection getApplets()

org.w3c.dom.NamedNodeMap getAttributes()

String getBaseURI()

org.w3c.dom.html.HTMLElement getBody()

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

Returns the number of child elements for the given node.

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

SimpleNodeList getChildNodes()

String getCookie()

org.w3c.dom.DocumentType getDoctype()

@inheritDoc

org.w3c.dom.Element getDocumentElement()

String getDocumentURI()

org.w3c.dom.DOMConfiguration getDomConfig()

String getDomain()

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 getElementsByName(String elementName)

SimpleNodeList getElementsByTagName(String tagname)

SimpleNodeList getElementsByTagNameNS(String namespaceURI, String localName)

Object getFeature(String feature, String version)

org.w3c.dom.Node getFirstChild()

SimpleHtmlCollection getForms()

SimpleHtmlCollection getImages()

org.w3c.dom.DOMImplementation getImplementation()

String getInputEncoding()

org.w3c.dom.Node getLastChild()

SimpleHtmlCollection getLinks()

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()

String getReferrer()

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()

String getTitle()

String getURL()

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()

void open()

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 setBody(org.w3c.dom.html.HTMLElement body)

void setCookie(String cookie)

void setDocumentURI(String documentURI)

void setNodeValue(String nodeValue)

void setPrefix(String prefix)

void setStrictErrorChecking(boolean strictErrorChecking)

void setTextContent(String textContent)

void setTitle(String title)

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

void setXmlStandalone(boolean xmlStandalone)

void setXmlVersion(String xmlVersion)

String toXML()

Exports this DOM as a String

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

void write(String text)

void writeln(String text)

 
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.html.HTMLDocument dom


xpath

private XPath xpath


 
Constructor Detail

SimpleHtmlDocument

public SimpleHtmlDocument()
Create a new, empty, SimpleHtmlDocument


SimpleHtmlDocument

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


 
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)


close

public void close()


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)


getAnchors

public SimpleHtmlCollection getAnchors()


getApplets

public SimpleHtmlCollection getApplets()


getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()


getBaseURI

public String getBaseURI()


getBody

public org.w3c.dom.html.HTMLElement getBody()


getChildElementCount

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

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()


getCookie

public String getCookie()


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()


getDomain

public String getDomain()


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.


getElementsByName

public SimpleNodeList getElementsByName(String elementName)


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()


getForms

public SimpleHtmlCollection getForms()


getImages

public SimpleHtmlCollection getImages()


getImplementation

public org.w3c.dom.DOMImplementation getImplementation()


getInputEncoding

public String getInputEncoding()


getLastChild

public org.w3c.dom.Node getLastChild()


getLinks

public SimpleHtmlCollection getLinks()


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()


getReferrer

public String getReferrer()


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()


getTitle

public String getTitle()


getURL

public String getURL()


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()


open

public void open()


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)


setBody

public void setBody(org.w3c.dom.html.HTMLElement body)


setCookie

public void setCookie(String cookie)


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)


setTitle

public void setTitle(String title)


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)


toXML

public String toXML()
Exports this DOM as a String
Returns:
an XML String representation of this DOM


toXML

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


write

public void write(String text)


writeln

public void writeln(String text)


 

Groovy Documentation