## com.gargoylesoftware.htmlunit
Class DefaultPageCreator

    java.lang.Object
      com.gargoylesoftware.htmlunit.DefaultPageCreator

All Implemented Interfaces:
  PageCreator, java.io.Serializable

    public class DefaultPageCreator

extends java.lang.Object
implements PageCreator, java.io.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 which HtmlUnit already knows about for your custom content types.

The following table shows the type of `Page` created depending on the content type:

Content type | Type of page
--- | ---
text/html | `HtmlPage`
text/xml application/xml text/vnd.wap.wml *+xml | `XmlPage`, or an `XHtmlPage` if an XHTML namespace is used
text/javascript application/x-javascript | `JavaScriptPage`
text/* | `TextPage`
Anything else | `UnexpectedPage`

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

Constructor Summary
`DefaultPageCreator()` Creates an instance.

Method Summary
`protected HtmlPage` `createHtmlPage(WebResponse webResponse, WebWindow webWindow)` Creates an HtmlPage for this WebResponse.
`protected JavaScriptPage` `createJavaScriptPage(WebResponse webResponse, WebWindow webWindow)` Creates 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)` Creates a TextPage for this WebResponse.
`protected UnexpectedPage` `createUnexpectedPage(WebResponse webResponse, WebWindow webWindow)` Creates an UnexpectedPage for this WebResponse.
`protected XHtmlPage` `createXHtmlPage(WebResponse webResponse, WebWindow webWindow)` Creates an XHtmlPage for this WebResponse.
`protected XmlPage` `createXmlPage(WebResponse webResponse, WebWindow webWindow)` Creates an XmlPage for this WebResponse.
`protected java.lang.String` `determinePageType(java.lang.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()

  Creates an instance.

Method Detail

### createPage

    public Page createPage(WebResponse webResponse,
                           WebWindow webWindow)
                    throws java.io.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:
    `java.io.IOException` - if an IO problem occurs

### createHtmlPage

    protected HtmlPage createHtmlPage(WebResponse webResponse,
                                      WebWindow webWindow)
                               throws java.io.IOException

  Creates an HtmlPage for this WebResponse.

  Parameters:
    `webResponse` - the page's source
    `webWindow` - the WebWindow to place the HtmlPage in
  Returns:
    the newly created HtmlPage
  Throws:
    `java.io.IOException` - if the page could not be created

### createXHtmlPage

    protected XHtmlPage createXHtmlPage(WebResponse webResponse,
                                        WebWindow webWindow)
                                 throws java.io.IOException

  Creates an XHtmlPage for this WebResponse.

  Parameters:
    `webResponse` - the page's source
    `webWindow` - the WebWindow to place the HtmlPage in
  Returns:
    the newly created XHtmlPage
  Throws:
    `java.io.IOException` - if the page could not be created

### createJavaScriptPage

    protected JavaScriptPage createJavaScriptPage(WebResponse webResponse,
                                                  WebWindow webWindow)

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

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

  Creates 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 java.io.IOException

  Creates 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:
    `java.io.IOException` - if the page could not be created

### determinePageType

    protected java.lang.String determinePageType(java.lang.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-2011 Gargoyle Software Inc.. All Rights Reserved.