MDSResponse.java :  » UnTagged » moca » org » moca » net » Android Open Source

Android Open Source » UnTagged » moca 
moca » org » moca » net » MDSResponse.java
package org.moca.net;

/**
 * Characterizes a result from the MDS. The response is a JSON dictionary with two keys.
 *   
 *   - `status' : either SUCCESS or FAILURE, depending on whether the request succeeded
 *  - `code' : the code indicating what the result was
 *  - `data' : miscellaneous data pertaining to the request 
 */
public class MDSResponse<T> {
  private static final String SUCCESS_STRING = "SUCCESS";
  private static final String FAILURE_STRING = "FAILURE";
  
  private String status;
  private String code;
  private T data;
  
  MDSResponse() {
    status = "none";
    code = "";
    data = null;
  }
  
  public boolean succeeded() {
    return SUCCESS_STRING.equals(status);
  }
  
  public boolean failed() {
    return FAILURE_STRING.equals(status);
  }
  
  public T getData() {
    return data;
  }
  
  public String getCode() {
    return code;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.