ItemModel.java
Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2005-2013 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 package org.xbmc.android.jsonrpc.api.model;
00022 
00023 import android.os.Parcel;
00024 import android.os.Parcelable;
00025 import java.util.ArrayList;
00026 import java.util.List;
00027 import org.codehaus.jackson.JsonNode;
00028 import org.codehaus.jackson.node.ArrayNode;
00029 import org.codehaus.jackson.node.ObjectNode;
00030 import org.xbmc.android.jsonrpc.api.AbstractModel;
00031 
00032 public final class ItemModel {
00033 
00040         public static class BaseDetail extends AbstractModel {
00041                 public final static String API_TYPE = "Item.Details.Base";
00042 
00043                 // field names
00044                 public static final String LABEL = "label";
00045 
00046                 // class members
00047                 public final String label;
00048 
00052                 public BaseDetail(String label) {
00053                         this.label = label;
00054                 }
00055 
00060                 public BaseDetail(JsonNode node) {
00061                         label = node.get(LABEL).getTextValue(); // required value
00062                 }
00063 
00064                 @Override
00065                 public JsonNode toJsonNode() {
00066                         final ObjectNode node = OM.createObjectNode();
00067                         node.put(LABEL, label);
00068                         return node;
00069                 }
00070 
00076                 static List<BaseDetail> getItemModelBaseDetailList(JsonNode node, String key) {
00077                         if (node.has(key)) {
00078                                 final ArrayNode a = (ArrayNode)node.get(key);
00079                                 final List<BaseDetail> l = new ArrayList<BaseDetail>(a.size());
00080                                 for (int i = 0; i < a.size(); i++) {
00081                                         l.add(new BaseDetail((JsonNode)a.get(i)));
00082                                 }
00083                                 return l;
00084                         }
00085                         return new ArrayList<BaseDetail>(0);
00086                 }
00087 
00093                 @Override
00094                 public void writeToParcel(Parcel parcel, int flags) {
00095                         parcel.writeValue(label);
00096                 }
00097 
00101                 protected BaseDetail(Parcel parcel) {
00102                         label = parcel.readString();
00103                 }
00104 
00108                 public static final Parcelable.Creator<BaseDetail> CREATOR = new Parcelable.Creator<BaseDetail>() {
00109                         @Override
00110                         public BaseDetail createFromParcel(Parcel parcel) {
00111                                 return new BaseDetail(parcel);
00112                         }
00113                         @Override
00114                         public BaseDetail[] newArray(int n) {
00115                                 return new BaseDetail[n];
00116                         }
00117                 };
00118 
00119                 @Override
00120                 public int describeContents() {
00121                         return 0;
00122                 }
00123         }
00124 }


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