com.duowan.mobile.netroid.request
Class JsonRequest<T>

java.lang.Object
  extended by com.duowan.mobile.netroid.Request<T>
      extended by com.duowan.mobile.netroid.request.JsonRequest<T>
Type Parameters:
T - JSON type of response expected
All Implemented Interfaces:
java.lang.Comparable<Request<T>>
Direct Known Subclasses:
JsonArrayRequest, JsonObjectRequest

public abstract class JsonRequest<T>
extends Request<T>

A request for retrieving a T type response body at a given URL that also optionally sends along a JSON body in the request specified.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.duowan.mobile.netroid.Request
Request.Method, Request.Priority
 
Constructor Summary
JsonRequest(int method, java.lang.String url, java.lang.String requestBody, Listener<T> listener)
           
 
Method Summary
 byte[] getBody()
          Returns the raw POST or PUT body to be sent.
 java.lang.String getBodyContentType()
           
protected abstract  Response<T> parseNetworkResponse(NetworkResponse response)
          Subclasses must implement this to parse the raw network response and return an appropriate response type.
 
Methods inherited from class com.duowan.mobile.netroid.Request
addHeader, addMarker, cancel, compareTo, deliverCancel, deliverDownloadProgress, deliverError, deliverFinish, deliverNetworking, deliverPreExecute, deliverRetry, deliverSuccess, deliverUsedCache, finish, getCacheExpireTime, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getUrl, handleResponse, hasHadResponseDelivered, isCanceled, isForceUpdate, markDelivered, parseNetworkError, perform, prepare, removeHeader, setCacheExpireTime, setForceUpdate, setListener, setRequestQueue, setRetryPolicy, setSequence, setTag, shouldCache, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonRequest

public JsonRequest(int method,
                   java.lang.String url,
                   java.lang.String requestBody,
                   Listener<T> listener)
Method Detail

parseNetworkResponse

protected abstract Response<T> parseNetworkResponse(NetworkResponse response)
Description copied from class: Request
Subclasses must implement this to parse the raw network response and return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.

Specified by:
parseNetworkResponse in class Request<T>
Parameters:
response - Response from the network
Returns:
The parsed response, or null in the case of an error

getBodyContentType

public java.lang.String getBodyContentType()
Overrides:
getBodyContentType in class Request<T>

getBody

public byte[] getBody()
Description copied from class: Request
Returns the raw POST or PUT body to be sent.

Overrides:
getBody in class Request<T>