T
- response type.public abstract class ScRequest<T extends ScResponse> extends Request<T>
Request.Method, Request.Priority
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
mBodyFields |
Modifier | Constructor and Description |
---|---|
protected |
ScRequest(int method,
java.lang.String url,
Response.Listener<T> successListener,
Response.ErrorListener errorListener)
Creates a new request with the given URL, error listener, success listener and method type.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String key,
java.lang.String value)
Adds header for request.
|
void |
addOperationBeforeSuccessfulResponseSaved(android.content.ContentProviderOperation operation) |
protected void |
deliverResponse(T response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
|
java.util.ArrayList<android.content.ContentProviderOperation> |
getBeforeSaveContentProviderOperations() |
byte[] |
getBody()
Encodes body to UTF-8 and converts it to bytes.
|
java.lang.String |
getBodyContentType()
Returns content type.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns request headers.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getParams()
Returns a Map of parameters to be used for a POST or PUT request.
|
protected Response<T> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
protected abstract ScResponse |
parseResponse(java.lang.String response) |
java.lang.String |
toString()
Returns string representation of the
ScRequest . |
addMarker, cancel, compareTo, deliverError, getCacheEntry, getCacheKey, getMethod, getParamsEncoding, getPostBody, getPostBodyContentType, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache
protected ScRequest(int method, java.lang.String url, Response.Listener<T> successListener, Response.ErrorListener errorListener)
method
- method type, one of the Method
url
- endpoint urlsuccessListener
- success listener for requesterrorListener
- error listener for requestprotected abstract ScResponse parseResponse(java.lang.String response) throws org.json.JSONException
org.json.JSONException
public void addOperationBeforeSuccessfulResponseSaved(android.content.ContentProviderOperation operation)
public java.util.ArrayList<android.content.ContentProviderOperation> getBeforeSaveContentProviderOperations()
public void addHeader(java.lang.String key, java.lang.String value)
key
- header namevalue
- header valuegetHeaders()
public java.util.Map<java.lang.String,java.lang.String> getHeaders() throws AuthFailureError
getHeaders
in class Request<T extends ScResponse>
Map
of headersAuthFailureError
- In the event of auth failureaddHeader(String, String)
public java.lang.String getBodyContentType()
getBodyContentType
in class Request<T extends ScResponse>
String
content type.protected void deliverResponse(T response)
Request
deliverResponse
in class Request<T extends ScResponse>
response
- The parsed response returned by
Request.parseNetworkResponse(NetworkResponse)
protected Response<T> parseNetworkResponse(NetworkResponse response)
Request
parseNetworkResponse
in class Request<T extends ScResponse>
response
- Response from the networkprotected java.util.Map<java.lang.String,java.lang.String> getParams() throws AuthFailureError
Request
AuthFailureError
as authentication may be required to provide these values.
Note that you can directly override Request.getBody()
for custom data.
getParams
in class Request<T extends ScResponse>
AuthFailureError
- in the event of auth failurepublic byte[] getBody() throws AuthFailureError
getBody
in class Request<T extends ScResponse>
byte[]
bytes or null
if UnsupportedEncodingException
happened.AuthFailureError
public java.lang.String toString()
ScRequest
.toString
in class Request<T extends ScResponse>
ScRequest