Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package org.xbmc.android.jsonrpc.api;
00023
00024 import java.io.IOException;
00025
00026 import org.codehaus.jackson.JsonNode;
00027 import org.codehaus.jackson.JsonProcessingException;
00028 import org.codehaus.jackson.map.ObjectMapper;
00029 import org.codehaus.jackson.node.ObjectNode;
00030
00031 import android.os.Parcel;
00032 import android.os.Parcelable;
00033 import android.util.Log;
00034
00048 public class UndefinedResult implements Parcelable {
00049
00050 private final static String TAG = UndefinedResult.class.getSimpleName();
00051 private final static ObjectMapper OM = new ObjectMapper();
00052
00053 private final JsonNode mResponse;
00054
00059 public UndefinedResult(JsonNode node) {
00060 mResponse = node;
00061 }
00062
00068 public JsonNode getResponse() {
00069 return mResponse;
00070 }
00071
00076 public ObjectNode getResult() {
00077 return (ObjectNode)mResponse.get("result");
00078 }
00079
00080 @Override
00081 public void writeToParcel(Parcel parcel, int flags) {
00082 parcel.writeValue(mResponse.toString());
00083 }
00084
00085 @Override
00086 public int describeContents() {
00087 return 0;
00088 }
00089
00094 private UndefinedResult(Parcel parcel) {
00095 ObjectNode response = null;
00096 try {
00097 response = (ObjectNode)OM.readTree(parcel.readString());
00098 } catch (JsonProcessingException e) {
00099 Log.e(TAG, "Error reading JSON object from parcel: " + e.getMessage(), e);
00100 } catch (IOException e) {
00101 Log.e(TAG, "I/O exception reading JSON object from parcel: " + e.getMessage(), e);
00102 } finally {
00103 mResponse = response;
00104 }
00105 }
00106
00110 public static final Parcelable.Creator<UndefinedResult> CREATOR = new Parcelable.Creator<UndefinedResult>() {
00111 @Override
00112 public UndefinedResult createFromParcel(Parcel parcel) {
00113 return new UndefinedResult(parcel);
00114 }
00115 @Override
00116 public UndefinedResult[] newArray(int n) {
00117 return new UndefinedResult[n];
00118 }
00119 };
00120 }