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
00034 public final class LibraryModel {
00035
00042 public static class GenreDetail extends ItemModel.BaseDetail {
00043 public final static String API_TYPE = "Library.Details.Genre";
00044
00045
00046 public static final String GENREID = "genreid";
00047 public static final String THUMBNAIL = "thumbnail";
00048 public static final String TITLE = "title";
00049
00050
00051 public final Integer genreid;
00052 public final String thumbnail;
00053 public final String title;
00054
00059 public GenreDetail(JsonNode node) {
00060 super(node);
00061 genreid = parseInt(node, GENREID);
00062 thumbnail = parseString(node, THUMBNAIL);
00063 title = parseString(node, TITLE);
00064 }
00065
00066 @Override
00067 public JsonNode toJsonNode() {
00068 final ObjectNode node = (ObjectNode)super.toJsonNode();
00069 node.put(GENREID, genreid);
00070 node.put(THUMBNAIL, thumbnail);
00071 node.put(TITLE, title);
00072 return node;
00073 }
00074
00080 static List<GenreDetail> getLibraryModelGenreDetailList(JsonNode node, String key) {
00081 if (node.has(key)) {
00082 final ArrayNode a = (ArrayNode)node.get(key);
00083 final List<GenreDetail> l = new ArrayList<GenreDetail>(a.size());
00084 for (int i = 0; i < a.size(); i++) {
00085 l.add(new GenreDetail((JsonNode)a.get(i)));
00086 }
00087 return l;
00088 }
00089 return new ArrayList<GenreDetail>(0);
00090 }
00091
00097 @Override
00098 public void writeToParcel(Parcel parcel, int flags) {
00099 super.writeToParcel(parcel, flags);
00100 parcel.writeValue(genreid);
00101 parcel.writeValue(thumbnail);
00102 parcel.writeValue(title);
00103 }
00104
00108 protected GenreDetail(Parcel parcel) {
00109 super(parcel);
00110 genreid = parcel.readInt();
00111 thumbnail = parcel.readString();
00112 title = parcel.readString();
00113 }
00114
00118 public static final Parcelable.Creator<GenreDetail> CREATOR = new Parcelable.Creator<GenreDetail>() {
00119 @Override
00120 public GenreDetail createFromParcel(Parcel parcel) {
00121 return new GenreDetail(parcel);
00122 }
00123 @Override
00124 public GenreDetail[] newArray(int n) {
00125 return new GenreDetail[n];
00126 }
00127 };
00128
00129 @Override
00130 public int describeContents() {
00131 return 0;
00132 }
00133 }
00134
00138 public interface GenreFields {
00139
00140 public final String TITLE = "title";
00141 public final String THUMBNAIL = "thumbnail";
00142
00143 public final static Set<String> values = new HashSet<String>(Arrays.asList(TITLE, THUMBNAIL));
00144 }
00145 }