com.gargoylesoftware.htmlunit
Class SgmlPage

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.SgmlPage
All Implemented Interfaces:
Page, Serializable, Cloneable, Document, Node
Direct Known Subclasses:
HtmlPage, XmlPage

public abstract class SgmlPage
extends DomNode
implements Page, Document

A basic class to be implemented by HtmlPage and XmlPage.

Version:
$Revision: 5764 $
Author:
Ahmed Ashour
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator<T extends DomNode>
 
Field Summary
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
AS_TEXT_BLANK, AS_TEXT_BLOCK_SEPARATOR, AS_TEXT_NEW_LINE, AS_TEXT_TAB, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
 
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
SgmlPage(WebResponse webResponse, WebWindow webWindow)
          Creates an instance of SgmlPage.
 
Method Summary
 String asXml()
          Returns a string representation of the XML document from this element and all it's children (recursively).
 void cleanUp()
          Clean up this page.
protected  SgmlPage clone()
          Creates a clone of this instance.
 DomAttr createAttribute(String name)
          
 DomDocumentFragment createDomDocumentFragment()
          Creates an empty DomDocumentFragment object.
abstract  Element createElement(String tagName)
          Creates an element, the type of which depends on the specified tag name.
abstract  Element createElementNS(String namespaceURI, String qualifiedName)
          Create a new Element with the given namespace and qualified name.
 String getCanonicalXPath()
          Returns the canonical XPath expression which identifies this node, for instance "/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".
 DocumentType getDoctype()
          Returns the document type.
 DomElement getDocumentElement()
          Returns the document element.
 WebWindow getEnclosingWindow()
          Returns the window that this page is sitting inside.
 String getNodeName()
          Gets the name for the current node.
 short getNodeType()
          Gets the type of the current node.
 SgmlPage getPage()
          Returns the page that contains this node.
abstract  String getPageEncoding()
          Returns the page encoding.
 URL getUrl()
          Returns the URL of this page.
 WebClient getWebClient()
          Returns the WebClient that originally loaded this page.
 WebResponse getWebResponse()
          Returns the web response that was originally used to create this page.
abstract  boolean hasCaseSensitiveTagNames()
          Returns true if this page has case-sensitive tag names, false otherwise.
 void initialize()
          Initialize this page.
 void normalizeDocument()
           The current implementation just DomNode.normalize()s the document element.
protected  void setDocumentType(DomDocumentType type)
          Sets the document type.
 void setEnclosingWindow(WebWindow window)
          Sets the window that contains this page.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, appendChild, asText, checkChildHierarchy, cloneNode, compareDocumentPosition, fireNodeAdded, fireNodeDeleted, getAllHtmlChildElements, getAncestors, getAttributes, getBaseURI, getByXPath, getChildNodes, getChildren, getDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getIndex, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isBlock, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, isTrimmedText, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, printXml, remove, removeAllChildren, removeChild, removeDomChangeListener, replace, replaceChild, setNextSibling, setNodeValue, setParentNode, setPrefix, setPreviousSibling, setReadyState, setScriptObject, setTextContent, setUserData
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Document
adoptNode, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersion
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Constructor Detail

SgmlPage

public SgmlPage(WebResponse webResponse,
                WebWindow webWindow)
Creates an instance of SgmlPage.

Parameters:
webResponse - the web response that was used to create this page
webWindow - the window that this page is being loaded into
Method Detail

cleanUp

public void cleanUp()
             throws IOException
Clean up this page. This method gets called by the web client when an other page is loaded in the window and you should probably never need to call it directly

Specified by:
cleanUp in interface Page
Throws:
IOException - if an IO problem occurs

getWebResponse

public WebResponse getWebResponse()
Returns the web response that was originally used to create this page.

Specified by:
getWebResponse in interface Page
Returns:
the web response

initialize

public void initialize()
                throws IOException
Initialize this page. This method gets called when a new page is loaded and you should probably never need to call it directly.

Specified by:
initialize in interface Page
Throws:
IOException - if an IO problem occurs

getNodeName

public String getNodeName()
Gets the name for the current node.

Specified by:
getNodeName in interface Node
Specified by:
getNodeName in class DomNode
Returns:
the node name

getNodeType

public short getNodeType()
Gets the type of the current node.

Specified by:
getNodeType in interface Node
Specified by:
getNodeType in class DomNode
Returns:
the node type

getEnclosingWindow

public WebWindow getEnclosingWindow()
Returns the window that this page is sitting inside.

Specified by:
getEnclosingWindow in interface Page
Returns:
the enclosing frame or null if this page isn't inside a frame

setEnclosingWindow

public void setEnclosingWindow(WebWindow window)
Sets the window that contains this page.

Parameters:
window - the new frame or null if this page is being removed from a frame

getWebClient

public WebClient getWebClient()
Returns the WebClient that originally loaded this page.

Returns:
the WebClient that originally loaded this page

createDomDocumentFragment

public DomDocumentFragment createDomDocumentFragment()
Creates an empty DomDocumentFragment object.

Returns:
a newly created DomDocumentFragment

getDoctype

public final DocumentType getDoctype()
Returns the document type.

Specified by:
getDoctype in interface Document
Returns:
the document type

setDocumentType

protected void setDocumentType(DomDocumentType type)
Sets the document type.

Parameters:
type - the document type

getPage

public SgmlPage getPage()
Returns the page that contains this node.

Overrides:
getPage in class DomNode
Returns:
the page that contains this node

createElement

public abstract Element createElement(String tagName)
Creates an element, the type of which depends on the specified tag name.

Specified by:
createElement in interface Document
Parameters:
tagName - the tag name which determines the type of element to be created
Returns:
an element, the type of which depends on the specified tag name

createElementNS

public abstract Element createElementNS(String namespaceURI,
                                        String qualifiedName)
Create a new Element with the given namespace and qualified name.

Specified by:
createElementNS in interface Document
Parameters:
namespaceURI - the URI that identifies an XML namespace
qualifiedName - the qualified name of the element type to instantiate
Returns:
the new element

getPageEncoding

public abstract String getPageEncoding()
Returns the page encoding.

Returns:
the page encoding

getDocumentElement

public DomElement getDocumentElement()
Returns the document element.

Specified by:
getDocumentElement in interface Document
Returns:
the document element

clone

protected SgmlPage clone()
Creates a clone of this instance.

Overrides:
clone in class Object
Returns:
a clone of this instance

asXml

public String asXml()
Returns a string representation of the XML document from this element and all it's children (recursively). The charset used is the current page encoding.

Overrides:
asXml in class DomNode
Returns:
the XML string

hasCaseSensitiveTagNames

public abstract boolean hasCaseSensitiveTagNames()
Returns true if this page has case-sensitive tag names, false otherwise. In general, XML has case-sensitive tag names, and HTML doesn't. This is especially important during XPath matching.

Returns:
true if this page has case-sensitive tag names, false otherwise

normalizeDocument

public void normalizeDocument()
The current implementation just DomNode.normalize()s the document element.

Specified by:
normalizeDocument in interface Document

getCanonicalXPath

public String getCanonicalXPath()

Returns the canonical XPath expression which identifies this node, for instance "/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".

WARNING: This sort of automated XPath expression is often quite bad at identifying a node, as it is highly sensitive to changes in the DOM tree.

Overrides:
getCanonicalXPath in class DomNode
Returns:
the canonical XPath expression which identifies this node
See Also:
DomNode.getByXPath(String)

createAttribute

public DomAttr createAttribute(String name)

Specified by:
createAttribute in interface Document

getUrl

public URL getUrl()
Returns the URL of this page.

Specified by:
getUrl in interface Page
Returns:
the URL of this page


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.