com.stackmob.sdk.callback
Class StackMobCallback

java.lang.Object
  extended by com.stackmob.sdk.callback.StackMobRawCallback
      extended by com.stackmob.sdk.callback.StackMobCallback
Direct Known Subclasses:
StackMobCountCallback, StackMobIntermediaryCallback, StackMobModelCallback, StackMobNoopCallback

public abstract class StackMobCallback
extends StackMobRawCallback

The basic callback class for responding to asynchronous StackMob calls. Most methods in the StackMob class take one of these as an argument. It's standard practice to subclass on the fly.

 stackmob.doSomething(argument, new StackMobCallback() {
     public void success(String responseBody) {
         assertNotNull(responseBody);
         latch.countDown();
     }

     public void failure(StackMobException e) {
         fail(e.getMessage());
     }
 }
 
 
When a callback is invoked you will generally not be in the main thread, so react accordingly.


Field Summary
 
Fields inherited from class com.stackmob.sdk.callback.StackMobRawCallback
requestBody, requestHeaders, requestURL, requestVerb, responseBody, responseHeaders, responseStatusCode, retriesRemaining
 
Constructor Summary
StackMobCallback()
           
 
Method Summary
 void done(com.stackmob.sdk.net.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.
abstract  void failure(StackMobException e)
          override this method to handle errors
abstract  void success(String responseBody)
          override this method to handles cases where a call has succeeded.
 void temporaryPasswordResetRequired(StackMobException e)
          the method that will be called in the very specific case where a user has done a login with a temporary password, and now they need to reset their password to continue.
 void unsent(StackMobException e)
          the method that will be called when a call to StackMob cannot even be sent for some reason
 
Methods inherited from class com.stackmob.sdk.callback.StackMobRawCallback
getRetriesRemaining, getTotalNumberOfItemsFromContentRange, getTotalObjectCountFromPagination, retry, setDone, setRetriesRemaining
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackMobCallback

public StackMobCallback()
Method Detail

unsent

public void unsent(StackMobException e)
Description copied from class: StackMobRawCallback
the method that will be called when a call to StackMob cannot even be sent for some reason

Specified by:
unsent in class StackMobRawCallback
Parameters:
e - an error with the reason why

temporaryPasswordResetRequired

public void temporaryPasswordResetRequired(StackMobException e)
Description copied from class: StackMobRawCallback
the method that will be called in the very specific case where a user has done a login with a temporary password, and now they need to reset their password to continue. Respond to this by putting up a reset password screen and then calling StackMobUser.loginResettingTemporaryPassword(String, StackMobCallback) with the new password

Specified by:
temporaryPasswordResetRequired in class StackMobRawCallback
Parameters:
e - an error with the reason why

done

public void done(com.stackmob.sdk.net.HttpVerb requestVerb,
                 String requestURL,
                 List<Map.Entry<String,String>> requestHeaders,
                 String requestBody,
                 Integer responseStatusCode,
                 List<Map.Entry<String,String>> responseHeaders,
                 byte[] responseBody)
Description copied from class: StackMobRawCallback
the method that will be called when the call to StackMob is complete. may be executed in a background thread

Specified by:
done in class StackMobRawCallback
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

success

public abstract void success(String responseBody)
override this method to handles cases where a call has succeeded.

Parameters:
responseBody - the response string received from StackMob

failure

public abstract void failure(StackMobException e)
override this method to handle errors

Parameters:
e - a representation of the error that occurred


Copyright © 2012 StackMob. All Rights Reserved.