Android Open Source - RestLib Rest Response






From Project

Back to project page RestLib.

License

The source code is released under:

MIT License

If you think the Android project RestLib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package github.crazymumu.restlib;
//from w  w  w .ja v a  2  s  . c o m
import android.os.Parcel;
import android.os.Parcelable;

/**
 * After receiving and interpreting a request message, a server responds with an
 * HTTP response message.
 * 
 * @author Crazy MuMu
 */
public class RestResponse implements Parcelable {
  /**
   * Individual resources are identified in requests, for example using URIs
   * in web-based REST systems.
   */
  private String resource;
  
  /**
   * The operation supported by the web API using HTTP method.
   */
  private String method;
  
  /**
   * The Status-Code element is a 3-digit integer result code of the attempt
   * to understand and satisfy the request.
   */
  private int statusCode;
  
  /**
   * The message entity of this response.
   */
  private String result;
  
  public RestResponse() {
  }
  
  public RestResponse(String resource, String method, int statusCode, String result) {
    this.resource = resource;
    this.method = method;
    this.statusCode = statusCode;
    this.result = result;
  }
  
  /**
   * Returns the individual resource is identified in request, for example
   * using URIs in web-based REST systems.
   * 
   * @return the individual resource is identified in request.
   */
  public String getResource() {
    return resource;
  }

  /**
   * Returns the operation supported by the web API using HTTP method.
   * 
   * @return the operation supported by the web API using HTTP method.
   */
  public String getRequestMethod() {
    return method;
  }

  /**
   * Returns the integer result code of the request.
   * 
   * @return the integer result code of the request.
   */
  public int getStatusCode() {
    return statusCode;
  }

  /**
   * Returns the message entity of this response.
   * 
   * @return the message entity of this response.
   */
  public String getResult() {
    return result;
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(resource);
    dest.writeString(method);
    dest.writeInt(statusCode);
    dest.writeString(result);
  }
  
  private RestResponse(Parcel source) {
    resource = source.readString();
    method = source.readString();
    statusCode= source.readInt();
    result = source.readString();
  }
  
  public static final Parcelable.Creator<RestResponse> CREATOR = new Parcelable.Creator<RestResponse>() {
    @Override
    public RestResponse createFromParcel(Parcel source) {
      return new RestResponse(source);
    }

    @Override
    public RestResponse[] newArray(int size) {
      return new RestResponse[size];
    }
  };
}




Java Source Code List

github.crazymumu.restlib.RestRequest.java
github.crazymumu.restlib.RestResponse.java
github.crazymumu.restlib.RestResultReceiver.java
github.crazymumu.restlib.RestResult.java
github.crazymumu.restlib.RestService.java
github.crazymumu.restlib.core.CustomSSLSocketFactory.java
github.crazymumu.restlib.core.HttpsClient.java
github.crazymumu.restlib.core.SSLContextAlgorithm.java
github.crazymumu.restlib.http.RequestMethod.java
github.crazymumu.restlib.http.StatusCode.java
github.crazymumu.restlib.http.UserAgent.java
github.crazymumu.restlib.sample.MainActivity.java