com.heroku.api.request
Class RequestTransformation<A,B>

java.lang.Object
  extended by com.heroku.api.request.RequestTransformation<A,B>
All Implemented Interfaces:
Request<B>
Direct Known Subclasses:
AppExists

public abstract class RequestTransformation<A,B>
extends Object
implements Request<B>

Transforms a Request<A> into a Request<B> to allow parsing of the raw response to create a B. This is useful for extending standard request classes with a different response type.

Author:
Ryan Brainard

Constructor Summary
RequestTransformation(Request<A> a)
           
 
Method Summary
 String getBody()
          Value of the request body.
 String getEndpoint()
          Path and query parameters of a URL.
 Map<String,String> getHeaders()
          Map of request-specific HTTP headers.
 Http.Method getHttpMethod()
          HTTP method.
abstract  B getResponse(byte[] bytes, int status)
          Response handler.
 Http.Accept getResponseType()
          HTTP Accept header.
 boolean hasBody()
          Whether or not the request has a body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestTransformation

public RequestTransformation(Request<A> a)
Method Detail

getHttpMethod

public Http.Method getHttpMethod()
Description copied from interface: Request
HTTP method. e.g. GET, POST, PUT, DELETE

Specified by:
getHttpMethod in interface Request<B>
Returns:
The HTTP method used in the request.

getEndpoint

public String getEndpoint()
Description copied from interface: Request
Path and query parameters of a URL.

Specified by:
getEndpoint in interface Request<B>
Returns:
The path and query parameters as a String.

hasBody

public boolean hasBody()
Description copied from interface: Request
Whether or not the request has a body.

Specified by:
hasBody in interface Request<B>
Returns:
true if it has a request body, otherwise false

getBody

public String getBody()
Description copied from interface: Request
Value of the request body.

Specified by:
getBody in interface Request<B>
Returns:
Body

getResponseType

public Http.Accept getResponseType()
Description copied from interface: Request
HTTP Accept header.

Specified by:
getResponseType in interface Request<B>
Returns:
The Accept header to be used in the request. Typically "application/json" or "text/xml"
See Also:
Http.Accept

getHeaders

public Map<String,String> getHeaders()
Description copied from interface: Request
Map of request-specific HTTP headers.

Specified by:
getHeaders in interface Request<B>
Returns:
Name/value pairs of HTTP headers.

getResponse

public abstract B getResponse(byte[] bytes,
                              int status)
Description copied from interface: Request
Response handler.

Specified by:
getResponse in interface Request<B>
Parameters:
bytes - Data returned from the request.
status - HTTP status code.
Returns:
The type T as specified by an individual request.


Copyright © 2012. All Rights Reserved.