UndefinedResult.java
Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2005-2015 Team XBMC
00003  *      http://xbmc.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with XBMC Remote; see the file license.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *  http://www.gnu.org/copyleft/gpl.html
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 }


smarthome_media_kodi_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 21:03:49