org.xins.common.http
Class HTTPCallResult

java.lang.Object
  extended byorg.xins.common.service.CallResult
      extended byorg.xins.common.http.HTTPCallResult
All Implemented Interfaces:
HTTPCallResultData, Serializable

public final class HTTPCallResult
extends CallResult
implements HTTPCallResultData

Result returned from an HTTP request.

Since:
XINS 1.0.0
Version:
$Revision: 1.21 $ $Date: 2006/08/28 09:12:31 $
Author:
Ernst de Haan
See Also:
Serialized Form

Constructor Summary
HTTPCallResult(HTTPCallRequest request, TargetDescriptor succeededTarget, long duration, CallExceptionList exceptions, HTTPCallResultData data)
          Constructs a new HTTPCallResult object.
 
Method Summary
 byte[] getData()
          Returns the result data as a byte array.
 int getStatusCode()
          Returns the HTTP status code.
 InputStream getStream()
          Returns the returned data as an InputStream.
 String getString()
          Returns the returned data as a String.
 String getString(String encoding)
          Returns the returned data as a String in the specified encoding.
 
Methods inherited from class org.xins.common.service.CallResult
getDuration, getExceptions, getRequest, getSucceededTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPCallResult

public HTTPCallResult(HTTPCallRequest request,
                      TargetDescriptor succeededTarget,
                      long duration,
                      CallExceptionList exceptions,
                      HTTPCallResultData data)
               throws IllegalArgumentException
Constructs a new HTTPCallResult object.

Parameters:
request - the call request that resulted in this result, cannot be null.
succeededTarget - the target for which the call succeeded, cannot be null.
duration - the call duration in milliseconds, must be a non-negative number.
exceptions - the list of CallExceptionLists, or null if the first call attempt succeeded.
data - the HTTPCallResultData object returned from the call, cannot be null.
Throws:
IllegalArgumentException - if request == null || succeededTarget == null || data == null || duration < 0L.
Since:
XINS 1.5.0
Method Detail

getStatusCode

public int getStatusCode()
Returns the HTTP status code.

Specified by:
getStatusCode in interface HTTPCallResultData
Returns:
the HTTP status code.

getData

public byte[] getData()
Returns the result data as a byte array. Note that this is not a copy or clone of the internal data structure, but it is a link to the actual data structure itself.

Specified by:
getData in interface HTTPCallResultData
Returns:
a byte array of the result data, never null.

getString

public String getString()
Returns the returned data as a String. The encoding US-ASCII is assumed.

Returns:
the result data as a text string, not null.

getString

public String getString(String encoding)
                 throws UnsupportedEncodingException
Returns the returned data as a String in the specified encoding.

Parameters:
encoding - the encoding to use in the conversion from bytes to a text string, not null.
Returns:
the result data as a text string, not null.
Throws:
UnsupportedEncodingException - if the specified encoding is not supported.

getStream

public InputStream getStream()
Returns the returned data as an InputStream. The input stream is based directly on the underlying byte array.

Returns:
an InputStream that returns the returned data, never null.


See http://www.xins.org/.