com.stackmob.sdk.callback
Class StackMobRawCallback

java.lang.Object
  extended by com.stackmob.sdk.callback.StackMobRawCallback
Direct Known Subclasses:
StackMobCallback

public abstract class StackMobRawCallback
extends Object


Field Summary
protected  String requestBody
           
protected  List<Map.Entry<String,String>> requestHeaders
           
protected  String requestURL
           
protected  HttpVerb requestVerb
           
protected  byte[] responseBody
           
protected  List<Map.Entry<String,String>> responseHeaders
           
protected  Integer responseStatusCode
           
protected  int retriesRemaining
           
 
Constructor Summary
StackMobRawCallback()
           
 
Method Summary
abstract  void done(HttpVerb requestVerb, String requestURL, List<Map.Entry<String,String>> requestHeaders, String requestBody, Integer responseStatusCode, List<Map.Entry<String,String>> responseHeaders, byte[] responseBody)
          the method that will be called when the call to StackMob is complete.
 int getRetriesRemaining()
           
static Integer getTotalNumberOfItemsFromContentRange(List<Map.Entry<String,String>> responseHeaders)
          get the total number of items from the Content-Range header
 int getTotalObjectCountFromPagination()
          get the total number of items from the Content-Range header
 boolean retry(int afterMilliseconds)
          The method that will be called when a retry is possible.
 void setDone(HttpVerb requestVerb, String requestURL, List<Map.Entry<String,String>> requestHeaders, String requestBody, Integer responseStatusCode, List<Map.Entry<String,String>> responseHeaders, byte[] responseBody)
          the method that will be called when the call to StackMob is complete.
 void setRetriesRemaining(int remaining)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestVerb

protected HttpVerb requestVerb

requestURL

protected String requestURL

requestHeaders

protected List<Map.Entry<String,String>> requestHeaders

requestBody

protected String requestBody

responseStatusCode

protected Integer responseStatusCode

responseHeaders

protected List<Map.Entry<String,String>> responseHeaders

responseBody

protected byte[] responseBody

retriesRemaining

protected int retriesRemaining
Constructor Detail

StackMobRawCallback

public StackMobRawCallback()
Method Detail

setDone

public void setDone(HttpVerb requestVerb,
                    String requestURL,
                    List<Map.Entry<String,String>> requestHeaders,
                    String requestBody,
                    Integer responseStatusCode,
                    List<Map.Entry<String,String>> responseHeaders,
                    byte[] responseBody)
the method that will be called when the call to StackMob is complete. may be executed in a background thread

Parameters:
requestVerb - the HTTP verb that was requested
requestURL - the URL that was requested
requestHeaders - the headers in the request
requestBody - the body of the request. will be an empty string for GET, DELETE, etc...
responseStatusCode - the status code of the HTTP response from StackMob
responseHeaders - the response headers from StackMob
responseBody - the response body from StackMob

done

public abstract void done(HttpVerb requestVerb,
                          String requestURL,
                          List<Map.Entry<String,String>> requestHeaders,
                          String requestBody,
                          Integer responseStatusCode,
                          List<Map.Entry<String,String>> responseHeaders,
                          byte[] responseBody)
the method that will be called when the call to StackMob is complete. may be executed in a background thread

Parameters:
requestVerb - the HTTP verb that was requested
requestURL - the URL that was requested
requestHeaders - the headers in the request
requestBody - the body of the request. will be an empty string for GET, DELETE, etc...
responseStatusCode - the status code of the HTTP response from StackMob
responseHeaders - the response headers from StackMob
responseBody - the response body from StackMob

retry

public boolean retry(int afterMilliseconds)
The method that will be called when a retry is possible. This is triggered when there is a distinct and short term reason your request failed, and it should be successful on retry after the specified interval. By default at most three attempts are made before failing. Override to implement your own logic on retry, and return false to stop the request from being automatically retried.

Parameters:
afterMilliseconds - the number of milliseconds to wait until retrying the request.
Returns:
whether or not to automatically retry

getRetriesRemaining

public int getRetriesRemaining()
Returns:
The number of times the request will be automatically retried if necessary

setRetriesRemaining

public void setRetriesRemaining(int remaining)
Parameters:
remaining - the number of times the request should be retried

getTotalObjectCountFromPagination

public int getTotalObjectCountFromPagination()
get the total number of items from the Content-Range header

Returns:
the total number of items returned in the Content-Range header, -1 if there was no Content-Range header or it was malformed, -2 if the Content-Length header was present and well formed but the instance length was "*"

getTotalNumberOfItemsFromContentRange

public static Integer getTotalNumberOfItemsFromContentRange(List<Map.Entry<String,String>> responseHeaders)
get the total number of items from the Content-Range header

Parameters:
responseHeaders - the headers that were returned in the response
Returns:
the total number of items returned in the Content-Range header, -1 if there was no Content-Range header or it was malformed, -2 if the Content-Length header was present and well formed but the instance length was "*"


Copyright © 2012 StackMob. All Rights Reserved.