public class DefaultPageCreator extends Object implements PageCreator, Serializable
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 text/javascript |
HtmlPage |
text/xml application/xml text/vnd.wap.wml *+xml |
XmlPage , or an XHtmlPage if an XHTML namespace is used |
text/* | TextPage |
Anything else | UnexpectedPage |
Modifier and Type | Class and Description |
---|---|
static class |
DefaultPageCreator.PageType
The different supported page types.
|
Constructor and Description |
---|
DefaultPageCreator() |
Modifier and Type | Method and Description |
---|---|
protected HtmlPage |
createHtmlPage(WebResponse webResponse,
WebWindow webWindow)
Creates an HtmlPage 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 SgmlPage |
createXmlPage(WebResponse webResponse,
WebWindow webWindow)
Creates an SgmlPage for this WebResponse.
|
static DefaultPageCreator.PageType |
determinePageType(String contentType)
Determines the kind of page to create from the content type.
|
static DefaultPageCreator.PageType |
determinePageType(WebResponse webResponse)
Determines the kind of page to create from the content type.
|
HTMLParser |
getHtmlParser()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
public static DefaultPageCreator.PageType determinePageType(String contentType)
contentType
- the content type to evaluatepublic static DefaultPageCreator.PageType determinePageType(WebResponse webResponse) throws IOException
webResponse
- the response to investigateIOException
- if an IO problem occurspublic Page createPage(WebResponse webResponse, WebWindow webWindow) throws IOException
createPage
in interface PageCreator
webResponse
- the response from the serverwebWindow
- the window that this page will be loaded intoIOException
- if an IO problem occurspublic HTMLParser getHtmlParser()
getHtmlParser
in interface PageCreator
protected HtmlPage createHtmlPage(WebResponse webResponse, WebWindow webWindow) throws IOException
webResponse
- the page's sourcewebWindow
- the WebWindow to place the HtmlPage inIOException
- if the page could not be createdprotected XHtmlPage createXHtmlPage(WebResponse webResponse, WebWindow webWindow) throws IOException
webResponse
- the page's sourcewebWindow
- the WebWindow to place the HtmlPage inIOException
- if the page could not be createdprotected TextPage createTextPage(WebResponse webResponse, WebWindow webWindow)
webResponse
- the page's sourcewebWindow
- the WebWindow to place the TextPage inprotected UnexpectedPage createUnexpectedPage(WebResponse webResponse, WebWindow webWindow)
webResponse
- the page's sourcewebWindow
- the WebWindow to place the UnexpectedPage inprotected SgmlPage createXmlPage(WebResponse webResponse, WebWindow webWindow) throws IOException
webResponse
- the page's sourcewebWindow
- the WebWindow to place the TextPage inIOException
- if the page could not be createdCopyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.