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 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.Arrays;
00027 import java.util.HashSet;
00028 import java.util.List;
00029 import java.util.Set;
00030 import org.codehaus.jackson.JsonNode;
00031 import org.codehaus.jackson.node.ArrayNode;
00032 import org.codehaus.jackson.node.ObjectNode;
00033 import org.xbmc.android.jsonrpc.api.AbstractModel;
00034
00035 public final class FavouriteModel {
00036
00043 public static class FavouriteDetail extends AbstractModel {
00044 public final static String API_TYPE = "Favourite.Details.Favourite";
00045
00046
00047 public static final String PATH = "path";
00048 public static final String THUMBNAIL = "thumbnail";
00049 public static final String TITLE = "title";
00050 public static final String TYPE = "type";
00051 public static final String WINDOW = "window";
00052 public static final String WINDOWPARAMETER = "windowparameter";
00053
00054
00055 public final String path;
00056 public final String thumbnail;
00057 public final String title;
00058 public final String type;
00059 public final String window;
00060 public final String windowparameter;
00061
00070 public FavouriteDetail(String path, String thumbnail, String title, String type, String window, String windowparameter) {
00071 this.path = path;
00072 this.thumbnail = thumbnail;
00073 this.title = title;
00074 this.type = type;
00075 this.window = window;
00076 this.windowparameter = windowparameter;
00077 }
00078
00083 public FavouriteDetail(JsonNode node) {
00084 path = parseString(node, PATH);
00085 thumbnail = parseString(node, THUMBNAIL);
00086 title = node.get(TITLE).getTextValue();
00087 type = parseString(node, TYPE);
00088 window = parseString(node, WINDOW);
00089 windowparameter = parseString(node, WINDOWPARAMETER);
00090 }
00091
00092 @Override
00093 public JsonNode toJsonNode() {
00094 final ObjectNode node = OM.createObjectNode();
00095 node.put(PATH, path);
00096 node.put(THUMBNAIL, thumbnail);
00097 node.put(TITLE, title);
00098 node.put(TYPE, type);
00099 node.put(WINDOW, window);
00100 node.put(WINDOWPARAMETER, windowparameter);
00101 return node;
00102 }
00103
00109 static List<FavouriteDetail> getFavouriteModelFavouriteDetailList(JsonNode node, String key) {
00110 if (node.has(key)) {
00111 final ArrayNode a = (ArrayNode)node.get(key);
00112 final List<FavouriteDetail> l = new ArrayList<FavouriteDetail>(a.size());
00113 for (int i = 0; i < a.size(); i++) {
00114 l.add(new FavouriteDetail((JsonNode)a.get(i)));
00115 }
00116 return l;
00117 }
00118 return new ArrayList<FavouriteDetail>(0);
00119 }
00120
00126 @Override
00127 public void writeToParcel(Parcel parcel, int flags) {
00128 parcel.writeValue(path);
00129 parcel.writeValue(thumbnail);
00130 parcel.writeValue(title);
00131 parcel.writeValue(type);
00132 parcel.writeValue(window);
00133 parcel.writeValue(windowparameter);
00134 }
00135
00139 protected FavouriteDetail(Parcel parcel) {
00140 path = parcel.readString();
00141 thumbnail = parcel.readString();
00142 title = parcel.readString();
00143 type = parcel.readString();
00144 window = parcel.readString();
00145 windowparameter = parcel.readString();
00146 }
00147
00151 public static final Parcelable.Creator<FavouriteDetail> CREATOR = new Parcelable.Creator<FavouriteDetail>() {
00152 @Override
00153 public FavouriteDetail createFromParcel(Parcel parcel) {
00154 return new FavouriteDetail(parcel);
00155 }
00156 @Override
00157 public FavouriteDetail[] newArray(int n) {
00158 return new FavouriteDetail[n];
00159 }
00160 };
00161
00162 @Override
00163 public int describeContents() {
00164 return 0;
00165 }
00166
00170 public interface Type {
00171
00172 public final String MEDIA = "media";
00173 public final String WINDOW = "window";
00174 public final String SCRIPT = "script";
00175 public final String UNKNOWN = "unknown";
00176
00177 public final static Set<String> values = new HashSet<String>(Arrays.asList(MEDIA, WINDOW, SCRIPT, UNKNOWN));
00178 }
00179 }
00180
00184 public interface FavouriteFields {
00185
00186 public final String WINDOW = "window";
00187 public final String WINDOWPARAMETER = "windowparameter";
00188 public final String THUMBNAIL = "thumbnail";
00189 public final String PATH = "path";
00190
00191 public final static Set<String> values = new HashSet<String>(Arrays.asList(WINDOW, WINDOWPARAMETER, THUMBNAIL, PATH));
00192 }
00193
00197 public interface Type {
00198
00199 public final String MEDIA = "media";
00200 public final String WINDOW = "window";
00201 public final String SCRIPT = "script";
00202 public final String UNKNOWN = "unknown";
00203
00204 public final static Set<String> values = new HashSet<String>(Arrays.asList(MEDIA, WINDOW, SCRIPT, UNKNOWN));
00205 }
00206 }