public abstract class WebResponse extends Object implements HTMLSegment, CookieSource, DomWindowProxy
| Modifier and Type | Class and Description |
|---|---|
class |
WebResponse.Scriptable |
| Modifier | Constructor and Description |
|---|---|
protected |
WebResponse(WebClient client,
FrameSelector frame,
URL url)
Constructs a response object.
|
protected |
WebResponse(WebClient client,
FrameSelector frame,
URL url,
String text)
Constructs a response object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
alert(String message) |
void |
close() |
boolean |
confirm(String message) |
ScriptingHandler |
createDomScriptingHandler()
create a DOMScriptingHandler
|
ScriptingHandler |
createJavascriptScriptingHandler() |
protected void |
defineRawInputStream(InputStream inputStream) |
WebApplet[] |
getApplets()
Returns the applets found in the page in the order in which they appear.
|
String |
getCharacterSet()
Returns the character set used in this response.
|
WebClient |
getClient()
getter for the WebClient
|
int |
getContentLength()
Returns the content length of this response.
|
String |
getContentType()
Returns the content type of this response.
|
Document |
getDOM()
Returns a copy of the domain object model tree associated with this response.
|
String[] |
getElementNames()
Returns a list of HTML element names contained in this HTML section.
|
HTMLElement[] |
getElementsByTagName(String tagName)
return the HTMLElements with the specified tag name
|
HTMLElement[] |
getElementsWithAttribute(String name,
String value)
Returns the HTMLElements found with the specified attribute value.
|
HTMLElement[] |
getElementsWithName(String name)
Returns the HTMLElements found in this segment with the specified name.
|
HTMLElement |
getElementWithID(String id)
Returns the HTMLElement with the specified ID.
|
String |
getExternalStyleSheet()
Returns the stylesheet linked in the head of the page.
|
WebForm |
getFirstMatchingForm(HTMLElementPredicate predicate,
Object criteria)
Returns the first form found in the page matching the specified criteria.
|
WebLink |
getFirstMatchingLink(HTMLElementPredicate predicate,
Object criteria)
Returns the first link found in the page matching the specified criteria.
|
WebTable |
getFirstMatchingTable(HTMLElementPredicate predicate,
Object criteria)
Returns the first table in the response which matches the specified predicate and value.
|
TextBlock |
getFirstMatchingTextBlock(HTMLElementPredicate predicate,
Object criteria)
Returns the first link found in the page matching the specified criteria.
|
WebForm[] |
getForms()
Returns the forms found in the page in the order in which they appear.
|
WebForm |
getFormWithID(String ID)
Returns the form found in the page with the specified ID.
|
WebForm |
getFormWithName(String name)
Returns the form found in the page with the specified name.
|
String |
getFrameName()
Returns the name of the frame containing this page.
|
String[] |
getFrameNames()
Returns the names of the frames found in the page in the order in which they appear.
|
abstract String |
getHeaderField(String fieldName)
Returns the value for the specified header field.
|
abstract String[] |
getHeaderFieldNames()
Returns the names of the header fields found in the response.
|
WebImage[] |
getImages()
Returns the images found in the page in the order in which they appear.
|
WebImage |
getImageWithAltText(String altText)
Returns the first image found in the page with the specified alt attribute.
|
WebImage |
getImageWithName(String source)
Returns the image found in the page with the specified name attribute.
|
WebImage |
getImageWithSource(String source)
Returns the first image found in the page with the specified src attribute.
|
InputStream |
getInputStream()
Returns a buffered input stream for reading the contents of this reply.
|
WebLink[] |
getLinks()
Returns the links found in the page in the order in which they appear.
|
WebLink |
getLinkWith(String text)
Returns the first link which contains the specified text.
|
WebLink |
getLinkWithID(String ID)
Returns the link found in the page with the specified ID.
|
WebLink |
getLinkWithImageText(String text)
Returns the first link which contains an image with the specified text as its 'alt' attribute.
|
WebLink |
getLinkWithName(String name)
Returns the link found in the page with the specified name.
|
WebForm[] |
getMatchingForms(HTMLElementPredicate predicate,
Object criteria)
Returns all forms found in the page matching the specified criteria.
|
WebLink[] |
getMatchingLinks(HTMLElementPredicate predicate,
Object criteria)
Returns all links found in the page matching the specified criteria.
|
WebTable[] |
getMatchingTables(HTMLElementPredicate predicate,
Object criteria)
Returns all tables found in the page matching the specified criteria.
|
String[] |
getMetaTagContent(String attribute,
String attributeValue)
Retrieves the "content" of the meta tags for a key pair attribute-attributeValue.
|
String[] |
getNewCookieNames()
Returns a list of new cookie names defined as part of this response.
|
String |
getNewCookieValue(String name)
Returns the new cookie value defined as part of this response.
|
TextBlock |
getNextTextBlock(TextBlock block)
Returns the text block after the specified block, if any.
|
int |
getRefreshDelay()
Returns the delay before normally following the request to refresh this page, if any.
|
WebRequest |
getRefreshRequest()
Returns a request to refresh this page, if any.
|
abstract int |
getResponseCode()
Returns the response code associated with this response.
|
abstract String |
getResponseMessage()
Returns the response message associated with this response.
|
WebResponse.Scriptable |
getScriptableObject()
get the scriptable object for this WebResponse
|
ScriptingHandler |
getScriptingHandler() |
WebResponse |
getSubframeContents(String subFrameName)
Returns the contents of the specified subframe of this frameset response.
|
WebTable[] |
getTables()
Returns the top-level tables found in this page in the order in which
they appear.
|
WebTable |
getTableStartingWith(String text)
Returns the first table in the response which has the specified text as the full text of
its first non-blank row and non-blank column.
|
WebTable |
getTableStartingWithPrefix(String text)
Returns the first table in the response which has the specified text as a prefix of the text of
its first non-blank row and non-blank column.
|
WebTable |
getTableWithID(String text)
Returns the first table in the response which has the specified text as its ID attribute.
|
WebTable |
getTableWithSummary(String text)
Returns the first table in the response which has the specified text as its summary attribute.
|
String |
getText()
Returns the text of the response (excluding headers) as a string.
|
TextBlock[] |
getTextBlocks()
Returns an array of text blocks found in the page.
|
String |
getTitle()
Returns the title of the page.
|
URL |
getURL()
Returns the URL which invoked this response.
|
static String[] |
getValidContentTypes()
allow access to the valid content Types
|
boolean |
isHTML()
Returns true if the response is HTML.
|
protected void |
loadResponseText() |
static ScriptableDelegate |
newDelegate(String delegateClassName) |
static WebResponse |
newResponse(URLConnection connection)
Returns a web response built from a URL connection.
|
DomWindowProxy |
openNewWindow(String name,
String relativeUrl)
open a a new Window with the given name and relative URL
|
String |
prompt(String prompt,
String defaultResponse) |
boolean |
replaceText(String text,
String contentType)
Replaces the text in the window with the specified text and content type.
|
protected void |
setContentTypeHeader(String value)
Overwrites the current value (if any) of the content type header.
|
void |
setScriptingHandler(ScriptingHandler scriptingHandler) |
protected static void |
setValidContentTypes(String[] validContentTypes)
allow modification of the valid content Types
use with care
|
DomWindowProxy |
submitRequest(HTMLElementImpl sourceElement,
String method,
String location,
String target,
MessageBody requestBody) |
abstract String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetHeaderFieldsprotected WebResponse(WebClient client, FrameSelector frame, URL url)
frame - the frame to hold the responseurl - the url from which the response was receivedprotected WebResponse(WebClient client, FrameSelector frame, URL url, String text)
frame - the frame to hold the responseurl - the url from which the response was receivedpublic static WebResponse newResponse(URLConnection connection) throws IOException
IOExceptionpublic boolean isHTML()
public URL getURL()
getURL in interface CookieSourcegetURL in interface DomWindowProxypublic String getTitle() throws SAXException
SAXException - thrown if there is an error parsing this responsepublic String getExternalStyleSheet() throws SAXException
will return "/mystyle.css".SAXException - thrown if there is an error parsing this responsepublic String[] getMetaTagContent(String attribute, String attributeValue) throws SAXException
this can be used like this
getMetaTagContent("name","robots") will return { "index","follow" }
getMetaTagContent("http-equiv","Expires") will return { "now" }
SAXException - thrown if there is an error parsing this responsepublic String getFrameName()
public WebRequest getRefreshRequest()
public int getRefreshDelay()
public abstract int getResponseCode()
public abstract String getResponseMessage()
public int getContentLength()
public String getContentType()
public String getCharacterSet()
public String[] getNewCookieNames()
public String getNewCookieValue(String name)
public abstract String[] getHeaderFieldNames()
public abstract String getHeaderField(String fieldName)
public String getText() throws IOException
IOExceptionpublic InputStream getInputStream() throws IOException
IOExceptionpublic String[] getFrameNames() throws SAXException
SAXException - thrown if there is an error parsing this responsepublic WebResponse getSubframeContents(String subFrameName)
subFrameName - the name of the desired frame as defined in the frameset.public HTMLElement getElementWithID(String id) throws SAXException
getElementWithID in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public HTMLElement[] getElementsByTagName(String tagName) throws SAXException
tagName - e.g. "div" or "table"SAXExceptionpublic String[] getElementNames() throws SAXException
getElementNames in interface HTMLSegmentSAXExceptionpublic HTMLElement[] getElementsWithName(String name) throws SAXException
getElementsWithName in interface HTMLSegmentSAXExceptionpublic HTMLElement[] getElementsWithAttribute(String name, String value) throws SAXException
getElementsWithAttribute in interface HTMLSegmentSAXExceptionpublic WebForm[] getForms() throws SAXException
getForms in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebForm getFormWithName(String name) throws SAXException
getFormWithName in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebForm getFormWithID(String ID) throws SAXException
getFormWithID in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebForm getFirstMatchingForm(HTMLElementPredicate predicate, Object criteria) throws SAXException
getFirstMatchingForm in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebForm[] getMatchingForms(HTMLElementPredicate predicate, Object criteria) throws SAXException
getMatchingForms in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebLink[] getLinks() throws SAXException
getLinks in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebLink getLinkWith(String text) throws SAXException
getLinkWith in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebLink getLinkWithImageText(String text) throws SAXException
getLinkWithImageText in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebLink getLinkWithName(String name) throws SAXException
SAXException - thrown if there is an error parsing the response.public WebLink getLinkWithID(String ID) throws SAXException
SAXException - thrown if there is an error parsing the response.public WebLink getFirstMatchingLink(HTMLElementPredicate predicate, Object criteria) throws SAXException
getFirstMatchingLink in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebLink[] getMatchingLinks(HTMLElementPredicate predicate, Object criteria) throws SAXException
getMatchingLinks in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebImage[] getImages() throws SAXException
getImages in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebImage getImageWithName(String source) throws SAXException
getImageWithName in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebImage getImageWithSource(String source) throws SAXException
getImageWithSource in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebImage getImageWithAltText(String altText) throws SAXException
getImageWithAltText in interface HTMLSegmentSAXException - thrown if there is an error parsing the segment.public WebApplet[] getApplets() throws SAXException
HTMLSegmentgetApplets in interface HTMLSegmentSAXException - thrown if there is an error parsing the segment.public TextBlock[] getTextBlocks() throws SAXException
getTextBlocks in interface HTMLSegmentSAXException - thrown if there is an error parsing the segment.public TextBlock getNextTextBlock(TextBlock block) throws SAXException
SAXExceptionpublic TextBlock getFirstMatchingTextBlock(HTMLElementPredicate predicate, Object criteria) throws SAXException
SAXException - thrown if there is an error parsing the response.public Document getDOM() throws SAXException
SAXException - thrown if there is an error parsing the response.public WebTable[] getTables() throws SAXException
getTables in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebTable getFirstMatchingTable(HTMLElementPredicate predicate, Object criteria) throws SAXException
getFirstMatchingTable in interface HTMLSegmentSAXExceptionpublic WebTable[] getMatchingTables(HTMLElementPredicate predicate, Object criteria) throws SAXException
getMatchingTables in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebTable getTableStartingWith(String text) throws SAXException
getTableStartingWith in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebTable getTableStartingWithPrefix(String text) throws SAXException
getTableStartingWithPrefix in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebTable getTableWithSummary(String text) throws SAXException
getTableWithSummary in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebTable getTableWithID(String text) throws SAXException
getTableWithID in interface HTMLSegmentSAXException - thrown if there is an error parsing the response.public WebResponse.Scriptable getScriptableObject()
public void setScriptingHandler(ScriptingHandler scriptingHandler)
public ScriptingHandler getScriptingHandler()
getScriptingHandler in interface DomWindowProxypublic ScriptingHandler createJavascriptScriptingHandler()
public ScriptingHandler createDomScriptingHandler()
public static ScriptableDelegate newDelegate(String delegateClassName)
public DomWindowProxy openNewWindow(String name, String relativeUrl) throws IOException, SAXException
openNewWindow in interface DomWindowProxyname - - the name of the windowrelativeUrl - - the relative URL to be usedIOExceptionSAXExceptionpublic DomWindowProxy submitRequest(HTMLElementImpl sourceElement, String method, String location, String target, MessageBody requestBody) throws IOException, SAXException
submitRequest in interface DomWindowProxyIOExceptionSAXExceptionpublic void close()
close in interface DomWindowProxypublic void alert(String message)
alert in interface DomWindowProxypublic boolean confirm(String message)
confirm in interface DomWindowProxypublic String prompt(String prompt, String defaultResponse)
prompt in interface DomWindowProxyprotected final void defineRawInputStream(InputStream inputStream) throws IOException
IOExceptionprotected void setContentTypeHeader(String value)
public boolean replaceText(String text, String contentType)
DomWindowProxyreplaceText in interface DomWindowProxypublic WebClient getClient()
protected void loadResponseText()
throws IOException
IOExceptionpublic static String[] getValidContentTypes()
protected static void setValidContentTypes(String[] validContentTypes)
validContentTypes - the validContentTypes to setCopyright © 2012. All Rights Reserved.