org.apache.wink.client
Interface ClientResponse

All Superinterfaces:
org.apache.wink.client.internal.BaseRequestResponse

public interface ClientResponse
extends org.apache.wink.client.internal.BaseRequestResponse

Represents an http response that was received after invoking any one of the invocation methods on a Resource. An instance of a ClientResponse is created by the ConnectionHandler at the end of the handler chain, and is returned from every handler on the chain.


Method Summary
 void consumeContent()
          Consumes entity content.
<T> T
getEntity(java.lang.Class<T> cls)
          Get the response entity.
<T> T
getEntity(EntityType<T> entityType)
          Get the response entity.
 java.lang.String getMessage()
          Get the response message
 int getStatusCode()
          Get the response status code
 javax.ws.rs.core.Response.StatusType getStatusType()
          Gets the response status as a status type
 void setEntity(java.lang.Object entity)
          Set the response entity
 void setMessage(java.lang.String message)
          Set the response message
 void setStatusCode(int code)
          Set the response status code
 
Methods inherited from interface org.apache.wink.client.internal.BaseRequestResponse
getAttribute, getAttributes, getHeaders, setAttribute
 

Method Detail

getStatusType

javax.ws.rs.core.Response.StatusType getStatusType()
Gets the response status as a status type

Returns:
the response status

getStatusCode

int getStatusCode()
Get the response status code

Returns:
response status code

setStatusCode

void setStatusCode(int code)
Set the response status code

Parameters:
code - status code to set

getMessage

java.lang.String getMessage()
Get the response message

Returns:
response message

setMessage

void setMessage(java.lang.String message)
Set the response message

Parameters:
message - response message to set

getEntity

<T> T getEntity(java.lang.Class<T> cls)
Get the response entity.

If the requested type to return is InputStream, then the input stream of the response is returned, and the entity is not read using the providers. The returned input stream is the adapted input stream as created by the InputStream adapters. If the InputStream is read directly, then it will not be possible to receive the entity as any other type other than InputStream.

If the requested type to return is anything other than InputStream, then the entity is read using the appropriate provider before returning it. Subsequent calls to getEntity will return the same instance of the entity.

Type Parameters:
T - type of the response entity to get
Parameters:
cls - class of the response entity to get
Returns:
the response entity
Throws:
ClientRuntimeException - if there are exceptions that the Wink client encounters

getEntity

<T> T getEntity(EntityType<T> entityType)
Get the response entity.

If the requested type to return is InputStream, then the input stream of the response is returned, and the entity is not read using the providers. The returned input stream is the adapted input stream as created by the InputStream adapters. If the InputStream is read directly, then it will not be possible to receive the entity as any other type other than InputStream.

If the requested type to return is anything other than InputStream, then the entity is read using the appropriate provider before returning it. Subsequent calls to getEntity will return the same instance of the entity.

Type Parameters:
T - type of the response entity to get
Parameters:
entityType - an instance of EntityType specifying the type of the entity
Returns:
the response entity
Throws:
ClientRuntimeException - if there are exceptions that the Wink client encounters

setEntity

void setEntity(java.lang.Object entity)
Set the response entity

Parameters:
entity - response entity to set

consumeContent

void consumeContent()
Consumes entity content. The real behavior of this method depends on the actual implementation. It's needed to call this method, if the calling code decides not to handle content.

There is no need to call this method, if getEntity() was invoked.

Calling this method multiple times will not cause an error.



Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.