|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.htmlunit.DefaultPageCreator
public class DefaultPageCreator
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.
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 |
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 String |
determineContentType(String contentType,
InputStream contentAsStream)
Tries to determine the content type. |
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 |
---|
public DefaultPageCreator()
Method Detail |
---|
public 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 into
IOException
- if an IO problem occursprotected String determineContentType(String contentType, InputStream contentAsStream) throws IOException
contentType
- the contentType header if anycontentAsStream
- stream allowing to read the downloaded content
IOException
- if an IO problem occursprotected HtmlPage createHtmlPage(WebResponse webResponse, WebWindow webWindow) throws IOException
webResponse
- the page's sourcewebWindow
- the WebWindow to place the HtmlPage in
IOException
- 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 in
IOException
- if the page could not be createdprotected JavaScriptPage createJavaScriptPage(WebResponse webResponse, WebWindow webWindow)
webResponse
- the page's sourcewebWindow
- the WebWindow to place the JavaScriptPage in
protected TextPage createTextPage(WebResponse webResponse, WebWindow webWindow)
webResponse
- the page's sourcewebWindow
- the WebWindow to place the TextPage in
protected UnexpectedPage createUnexpectedPage(WebResponse webResponse, WebWindow webWindow)
webResponse
- the page's sourcewebWindow
- the WebWindow to place the UnexpectedPage in
protected XmlPage createXmlPage(WebResponse webResponse, WebWindow webWindow) throws IOException
webResponse
- the page's sourcewebWindow
- the WebWindow to place the TextPage in
IOException
- if the page could not be createdprotected String determinePageType(String contentType)
contentType
- the content type to evaluate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |