com.gargoylesoftware.htmlunit
Class DefaultPageCreator

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.DefaultPageCreator
All Implemented Interfaces:
PageCreator, Serializable

public class DefaultPageCreator
extends Object
implements PageCreator, Serializable

The default implementation of PageCreator. Designed to be extended for easier handling of new content types. Just check the content type in createPage() and call super(createPage()) if your custom type isn't found. There are also protected createXXXXPage() methods for creating the Page types HtmlUnit already knows about for your custom content types.

Version:
$Revision: 2132 $
Author:
Mike Bowler, Christian Sell, Brad Clarke, Marc Guillemot, Ahmed Ashour
See Also:
Serialized Form

Constructor Summary
DefaultPageCreator()
          Create an instance.
 
Method Summary
protected  HtmlPage createHtmlPage(WebResponse webResponse, WebWindow webWindow)
          Create a HtmlPage for this WebResponse
protected  JavaScriptPage createJavaScriptPage(WebResponse webResponse, WebWindow webWindow)
          Create a JavaScriptPage for this WebResponse
 Page createPage(WebResponse webResponse, WebWindow webWindow)
          Create a Page object for the specified web response.
protected  TextPage createTextPage(WebResponse webResponse, WebWindow webWindow)
          Create a TextPage for this WebResponse
protected  UnexpectedPage createUnexpectedPage(WebResponse webResponse, WebWindow webWindow)
          Create an UnexpectedPage for this WebResponse
protected  XmlPage createXmlPage(WebResponse webResponse, WebWindow webWindow)
          Create an XmlPage for this WebResponse
protected  String determinePageType(String contentType)
          Determines the kind of page to create from the content type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPageCreator

public DefaultPageCreator()
Create an instance.

Method Detail

createPage

public Page createPage(WebResponse webResponse,
                       WebWindow webWindow)
                throws IOException
Create a Page object for the specified web response.

Specified by:
createPage in interface PageCreator
Parameters:
webResponse - The response from the server
webWindow - The window that this page will be loaded into.
Returns:
The new page object
Throws:
IOException - If an io problem occurs

createHtmlPage

protected HtmlPage createHtmlPage(WebResponse webResponse,
                                  WebWindow webWindow)
                           throws IOException
Create a HtmlPage for this WebResponse

Parameters:
webResponse - The page's source
webWindow - The WebWindow to place the HtmlPage in
Returns:
The newly created HtmlPage
Throws:
IOException - If the page could not be created

createJavaScriptPage

protected JavaScriptPage createJavaScriptPage(WebResponse webResponse,
                                              WebWindow webWindow)
Create a JavaScriptPage for this WebResponse

Parameters:
webResponse - The page's source
webWindow - The WebWindow to place the JavaScriptPage in
Returns:
The newly created JavaScriptPage

createTextPage

protected TextPage createTextPage(WebResponse webResponse,
                                  WebWindow webWindow)
Create a TextPage for this WebResponse

Parameters:
webResponse - The page's source
webWindow - The WebWindow to place the TextPage in
Returns:
The newly created TextPage

createUnexpectedPage

protected UnexpectedPage createUnexpectedPage(WebResponse webResponse,
                                              WebWindow webWindow)
Create an UnexpectedPage for this WebResponse

Parameters:
webResponse - The page's source
webWindow - The WebWindow to place the UnexpectedPage in
Returns:
The newly created UnexpectedPage

createXmlPage

protected XmlPage createXmlPage(WebResponse webResponse,
                                WebWindow webWindow)
                         throws IOException
Create an XmlPage for this WebResponse

Parameters:
webResponse - The page's source
webWindow - The WebWindow to place the TextPage in
Returns:
The newly created TextPage
Throws:
IOException - If the page could not be created

determinePageType

protected String determinePageType(String contentType)
Determines the kind of page to create from the content type

Parameters:
contentType - The content type to evaluate
Returns:
"xml", "html", "javascript", "text" or "unknown"


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