com.gargoylesoftware.htmlunit.util
Class WebResponseWrapper

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.util.WebResponseWrapper
All Implemented Interfaces:
WebResponse

public class WebResponseWrapper
extends java.lang.Object
implements WebResponse

Provides a convenient implementation of the WebResponse interface that can be subclassed by developers wishing to adapt a particular WebResponse. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped web connection object.

Version:
$Revision: 1.3 $
Author:
Marc Guillemot

Constructor Summary
WebResponseWrapper(WebResponse webResponse)
 Constructs a WebResponse object wrapping provided WebResponse.
 
Method Summary
 java.io.InputStream getContentAsStream()
 Return the content from the server as an input stream The default behavior of this method is to return getContentAsStream() on the wrapped connection object.
 java.lang.String getContentAsString()
 Return the content from the server as a string The default behavior of this method is to return getContentAsString() on the wrapped connection object.
 java.lang.String getContentCharSet()
 Return the content charset value. The default behavior of this method is to return getContentCharSet() on the wrapped connection object.
 java.lang.String getContentType()
 Return the content type returned from the server. The default behavior of this method is to return getContentType() on the wrapped connection object.
 long getLoadTimeInMilliSeconds()
 Return the time it took to load this web response in milliseconds. The default behavior of this method is to return getLoadTimeInMilliSeconds() on the wrapped connection object.
 SubmitMethod getRequestMethod()
 Return the method used for the request resulting into this response. The default behavior of this method is to return getRequestMethod() on the wrapped connection object.
 byte[] getResponseBody()
 Return the response body as byte array. The default behavior of this method is to return getResponseBody() on the wrapped connection object.
 java.util.List getResponseHeaders()
 Return the response headers as a List of NameValuePairs. The default behavior of this method is to return getResponseHeaders() on the wrapped connection object.
 java.lang.String getResponseHeaderValue(java.lang.String headerName)
 Return the value of the specified header from this response. The default behavior of this method is to return getResponseHeaderValue() on the wrapped connection object.
 int getStatusCode()
 Return the status code that was returned by the server The default behavior of this method is to return getStatusCode() on the wrapped connection object.
 java.lang.String getStatusMessage()
 Return the status message that was returned from the server The default behavior of this method is to return getStatusMessage() on the wrapped connection object.
 java.net.URL getUrl()
 Return the URL that was used to load this page. The default behavior of this method is to return getUrl() on the wrapped connection object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebResponseWrapper

public WebResponseWrapper(WebResponse webResponse)
                   throws java.lang.IllegalArgumentException
Constructs a WebResponse object wrapping provided WebResponse.

Parameters:
webResponse - the webResponse that does the real work
Throws:
java.lang.IllegalArgumentException - if the connection is null
Method Detail

getContentAsStream

public java.io.InputStream getContentAsStream()
                                       throws java.io.IOException
Return the content from the server as an input stream The default behavior of this method is to return getContentAsStream() on the wrapped connection object.

Specified by:
getContentAsStream in interface WebResponse
Returns:
See above
Throws:
java.io.IOException - If an IO problem occurs

getContentAsString

public java.lang.String getContentAsString()
Return the content from the server as a string The default behavior of this method is to return getContentAsString() on the wrapped connection object.

Specified by:
getContentAsString in interface WebResponse
Returns:
See above

getContentCharSet

public java.lang.String getContentCharSet()
Return the content charset value. The default behavior of this method is to return getContentCharSet() on the wrapped connection object.

Specified by:
getContentCharSet in interface WebResponse
Returns:
The charset value.

getContentType

public java.lang.String getContentType()
Return the content type returned from the server. Ie "text/html" The default behavior of this method is to return getContentType() on the wrapped connection object.

Specified by:
getContentType in interface WebResponse
Returns:
See above

getLoadTimeInMilliSeconds

public long getLoadTimeInMilliSeconds()
Return the time it took to load this web response in milliseconds. The default behavior of this method is to return getLoadTimeInMilliSeconds() on the wrapped connection object.

Specified by:
getLoadTimeInMilliSeconds in interface WebResponse
Returns:
The load time.

getRequestMethod

public SubmitMethod getRequestMethod()
Return the method used for the request resulting into this response. The default behavior of this method is to return getRequestMethod() on the wrapped connection object.

Specified by:
getRequestMethod in interface WebResponse
Returns:
the method

getResponseBody

public byte[] getResponseBody()
Return the response body as byte array. The default behavior of this method is to return getResponseBody() on the wrapped connection object.

Specified by:
getResponseBody in interface WebResponse
Returns:
response body.

getResponseHeaders

public java.util.List getResponseHeaders()
Return the response headers as a List of NameValuePairs. The default behavior of this method is to return getResponseHeaders() on the wrapped connection object.

Specified by:
getResponseHeaders in interface WebResponse
Returns:
a List of NameValuePairs.

getResponseHeaderValue

public java.lang.String getResponseHeaderValue(java.lang.String headerName)
Return the value of the specified header from this response. The default behavior of this method is to return getResponseHeaderValue() on the wrapped connection object.

Specified by:
getResponseHeaderValue in interface WebResponse
Parameters:
headerName - The name of the header
Returns:
The value of the specified header

getStatusCode

public int getStatusCode()
Return the status code that was returned by the server The default behavior of this method is to return getStatusCode() on the wrapped connection object.

Specified by:
getStatusCode in interface WebResponse
Returns:
See above.

getStatusMessage

public java.lang.String getStatusMessage()
Return the status message that was returned from the server The default behavior of this method is to return getStatusMessage() on the wrapped connection object.

Specified by:
getStatusMessage in interface WebResponse
Returns:
See above

getUrl

public java.net.URL getUrl()
Return the URL that was used to load this page. The default behavior of this method is to return getUrl() on the wrapped connection object.

Specified by:
getUrl in interface WebResponse
Returns:
The originating URL


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.