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 PlaylistModel {
00036
00043 public static class Item extends AbstractModel {
00044 public final static String API_TYPE = "Playlist.Item";
00045
00046
00047 public final Albumid albumid;
00048 public final Artistid artistid;
00049 public final Episodeid episodeid;
00050 public final File file;
00051 public final Genreid genreid;
00052 public final Movieid movieid;
00053 public final Musicvideoid musicvideoid;
00054 public final RecursiveDirectoryMedia recursiveDirectoryMedia;
00055 public final Songid songid;
00056
00060 public Item(Albumid albumid) {
00061 this.albumid = albumid;
00062 this.artistid = null;
00063 this.episodeid = null;
00064 this.file = null;
00065 this.genreid = null;
00066 this.movieid = null;
00067 this.musicvideoid = null;
00068 this.recursiveDirectoryMedia = null;
00069 this.songid = null;
00070 }
00071
00075 public Item(Artistid artistid) {
00076 this.artistid = artistid;
00077 this.albumid = null;
00078 this.episodeid = null;
00079 this.file = null;
00080 this.genreid = null;
00081 this.movieid = null;
00082 this.musicvideoid = null;
00083 this.recursiveDirectoryMedia = null;
00084 this.songid = null;
00085 }
00086
00090 public Item(Episodeid episodeid) {
00091 this.episodeid = episodeid;
00092 this.albumid = null;
00093 this.artistid = null;
00094 this.file = null;
00095 this.genreid = null;
00096 this.movieid = null;
00097 this.musicvideoid = null;
00098 this.recursiveDirectoryMedia = null;
00099 this.songid = null;
00100 }
00101
00105 public Item(File file) {
00106 this.file = file;
00107 this.albumid = null;
00108 this.artistid = null;
00109 this.episodeid = null;
00110 this.genreid = null;
00111 this.movieid = null;
00112 this.musicvideoid = null;
00113 this.recursiveDirectoryMedia = null;
00114 this.songid = null;
00115 }
00116
00120 public Item(Genreid genreid) {
00121 this.genreid = genreid;
00122 this.albumid = null;
00123 this.artistid = null;
00124 this.episodeid = null;
00125 this.file = null;
00126 this.movieid = null;
00127 this.musicvideoid = null;
00128 this.recursiveDirectoryMedia = null;
00129 this.songid = null;
00130 }
00131
00135 public Item(Movieid movieid) {
00136 this.movieid = movieid;
00137 this.albumid = null;
00138 this.artistid = null;
00139 this.episodeid = null;
00140 this.file = null;
00141 this.genreid = null;
00142 this.musicvideoid = null;
00143 this.recursiveDirectoryMedia = null;
00144 this.songid = null;
00145 }
00146
00150 public Item(Musicvideoid musicvideoid) {
00151 this.musicvideoid = musicvideoid;
00152 this.albumid = null;
00153 this.artistid = null;
00154 this.episodeid = null;
00155 this.file = null;
00156 this.genreid = null;
00157 this.movieid = null;
00158 this.recursiveDirectoryMedia = null;
00159 this.songid = null;
00160 }
00161
00165 public Item(RecursiveDirectoryMedia recursiveDirectoryMedia) {
00166 this.recursiveDirectoryMedia = recursiveDirectoryMedia;
00167 this.albumid = null;
00168 this.artistid = null;
00169 this.episodeid = null;
00170 this.file = null;
00171 this.genreid = null;
00172 this.movieid = null;
00173 this.musicvideoid = null;
00174 this.songid = null;
00175 }
00176
00180 public Item(Songid songid) {
00181 this.songid = songid;
00182 this.albumid = null;
00183 this.artistid = null;
00184 this.episodeid = null;
00185 this.file = null;
00186 this.genreid = null;
00187 this.movieid = null;
00188 this.musicvideoid = null;
00189 this.recursiveDirectoryMedia = null;
00190 }
00191
00192 @Override
00193 public JsonNode toJsonNode() {
00194 if (albumid != null) {
00195 return albumid.toJsonNode();
00196 }
00197 if (artistid != null) {
00198 return artistid.toJsonNode();
00199 }
00200 if (episodeid != null) {
00201 return episodeid.toJsonNode();
00202 }
00203 if (file != null) {
00204 return file.toJsonNode();
00205 }
00206 if (genreid != null) {
00207 return genreid.toJsonNode();
00208 }
00209 if (movieid != null) {
00210 return movieid.toJsonNode();
00211 }
00212 if (musicvideoid != null) {
00213 return musicvideoid.toJsonNode();
00214 }
00215 if (recursiveDirectoryMedia != null) {
00216 return recursiveDirectoryMedia.toJsonNode();
00217 }
00218 if (songid != null) {
00219 return songid.toJsonNode();
00220 }
00221 return null;
00222 }
00223
00229 @Override
00230 public void writeToParcel(Parcel parcel, int flags) {
00231 parcel.writeValue(albumid);
00232 parcel.writeValue(artistid);
00233 parcel.writeValue(episodeid);
00234 parcel.writeValue(file);
00235 parcel.writeValue(genreid);
00236 parcel.writeValue(movieid);
00237 parcel.writeValue(musicvideoid);
00238 parcel.writeValue(recursiveDirectoryMedia);
00239 parcel.writeValue(songid);
00240 }
00241
00245 protected Item(Parcel parcel) {
00246 albumid = parcel.<Albumid>readParcelable(Albumid.class.getClassLoader());
00247 artistid = parcel.<Artistid>readParcelable(Artistid.class.getClassLoader());
00248 episodeid = parcel.<Episodeid>readParcelable(Episodeid.class.getClassLoader());
00249 file = parcel.<File>readParcelable(File.class.getClassLoader());
00250 genreid = parcel.<Genreid>readParcelable(Genreid.class.getClassLoader());
00251 movieid = parcel.<Movieid>readParcelable(Movieid.class.getClassLoader());
00252 musicvideoid = parcel.<Musicvideoid>readParcelable(Musicvideoid.class.getClassLoader());
00253 recursiveDirectoryMedia = parcel.<RecursiveDirectoryMedia>readParcelable(RecursiveDirectoryMedia.class.getClassLoader());
00254 songid = parcel.<Songid>readParcelable(Songid.class.getClassLoader());
00255 }
00256
00260 public static final Parcelable.Creator<Item> CREATOR = new Parcelable.Creator<Item>() {
00261 @Override
00262 public Item createFromParcel(Parcel parcel) {
00263 return new Item(parcel);
00264 }
00265 @Override
00266 public Item[] newArray(int n) {
00267 return new Item[n];
00268 }
00269 };
00270
00271 @Override
00272 public int describeContents() {
00273 return 0;
00274 }
00275
00280 public static class File extends AbstractModel {
00281
00282
00283 public static final String FILE = "file";
00284
00285
00286 public final String file;
00287
00291 public File(String file) {
00292 this.file = file;
00293 }
00294
00295 @Override
00296 public JsonNode toJsonNode() {
00297 final ObjectNode node = OM.createObjectNode();
00298 node.put(FILE, file);
00299 return node;
00300 }
00301
00307 @Override
00308 public void writeToParcel(Parcel parcel, int flags) {
00309 parcel.writeValue(file);
00310 }
00311
00315 protected File(Parcel parcel) {
00316 file = parcel.readString();
00317 }
00318
00322 public static final Parcelable.Creator<File> CREATOR = new Parcelable.Creator<File>() {
00323 @Override
00324 public File createFromParcel(Parcel parcel) {
00325 return new File(parcel);
00326 }
00327 @Override
00328 public File[] newArray(int n) {
00329 return new File[n];
00330 }
00331 };
00332
00333 @Override
00334 public int describeContents() {
00335 return 0;
00336 }
00337 }
00338
00343 public static class RecursiveDirectoryMedia extends AbstractModel {
00344
00345
00346 public static final String DIRECTORY = "directory";
00347 public static final String MEDIA = "media";
00348 public static final String RECURSIVE = "recursive";
00349
00350
00351 public final String directory;
00352 public final String media;
00353 public final Boolean recursive;
00354
00360 public RecursiveDirectoryMedia(String directory, String media, Boolean recursive) {
00361 this.directory = directory;
00362 this.media = media;
00363 this.recursive = recursive;
00364 }
00365
00366 @Override
00367 public JsonNode toJsonNode() {
00368 final ObjectNode node = OM.createObjectNode();
00369 node.put(DIRECTORY, directory);
00370 node.put(MEDIA, media);
00371 node.put(RECURSIVE, recursive);
00372 return node;
00373 }
00374
00380 @Override
00381 public void writeToParcel(Parcel parcel, int flags) {
00382 parcel.writeValue(directory);
00383 parcel.writeValue(media);
00384 parcel.writeInt(recursive ? 1 : 0);
00385 }
00386
00390 protected RecursiveDirectoryMedia(Parcel parcel) {
00391 directory = parcel.readString();
00392 media = parcel.readString();
00393 recursive = parcel.readInt() == 1;
00394 }
00395
00399 public static final Parcelable.Creator<RecursiveDirectoryMedia> CREATOR = new Parcelable.Creator<RecursiveDirectoryMedia>() {
00400 @Override
00401 public RecursiveDirectoryMedia createFromParcel(Parcel parcel) {
00402 return new RecursiveDirectoryMedia(parcel);
00403 }
00404 @Override
00405 public RecursiveDirectoryMedia[] newArray(int n) {
00406 return new RecursiveDirectoryMedia[n];
00407 }
00408 };
00409
00410 @Override
00411 public int describeContents() {
00412 return 0;
00413 }
00414
00418 public interface Media {
00419
00420 public final String VIDEO = "video";
00421 public final String MUSIC = "music";
00422 public final String PICTURES = "pictures";
00423 public final String FILES = "files";
00424 public final String PROGRAMS = "programs";
00425
00426 public final static Set<String> values = new HashSet<String>(Arrays.asList(VIDEO, MUSIC, PICTURES, FILES, PROGRAMS));
00427 }
00428 }
00429
00434 public static class Movieid extends AbstractModel {
00435
00436
00437 public static final String MOVIEID = "movieid";
00438
00439
00440 public final Integer movieid;
00441
00445 public Movieid(Integer movieid) {
00446 this.movieid = movieid;
00447 }
00448
00449 @Override
00450 public JsonNode toJsonNode() {
00451 final ObjectNode node = OM.createObjectNode();
00452 node.put(MOVIEID, movieid);
00453 return node;
00454 }
00455
00461 @Override
00462 public void writeToParcel(Parcel parcel, int flags) {
00463 parcel.writeValue(movieid);
00464 }
00465
00469 protected Movieid(Parcel parcel) {
00470 movieid = parcel.readInt();
00471 }
00472
00476 public static final Parcelable.Creator<Movieid> CREATOR = new Parcelable.Creator<Movieid>() {
00477 @Override
00478 public Movieid createFromParcel(Parcel parcel) {
00479 return new Movieid(parcel);
00480 }
00481 @Override
00482 public Movieid[] newArray(int n) {
00483 return new Movieid[n];
00484 }
00485 };
00486
00487 @Override
00488 public int describeContents() {
00489 return 0;
00490 }
00491 }
00492
00497 public static class Episodeid extends AbstractModel {
00498
00499
00500 public static final String EPISODEID = "episodeid";
00501
00502
00503 public final Integer episodeid;
00504
00508 public Episodeid(Integer episodeid) {
00509 this.episodeid = episodeid;
00510 }
00511
00512 @Override
00513 public JsonNode toJsonNode() {
00514 final ObjectNode node = OM.createObjectNode();
00515 node.put(EPISODEID, episodeid);
00516 return node;
00517 }
00518
00524 @Override
00525 public void writeToParcel(Parcel parcel, int flags) {
00526 parcel.writeValue(episodeid);
00527 }
00528
00532 protected Episodeid(Parcel parcel) {
00533 episodeid = parcel.readInt();
00534 }
00535
00539 public static final Parcelable.Creator<Episodeid> CREATOR = new Parcelable.Creator<Episodeid>() {
00540 @Override
00541 public Episodeid createFromParcel(Parcel parcel) {
00542 return new Episodeid(parcel);
00543 }
00544 @Override
00545 public Episodeid[] newArray(int n) {
00546 return new Episodeid[n];
00547 }
00548 };
00549
00550 @Override
00551 public int describeContents() {
00552 return 0;
00553 }
00554 }
00555
00560 public static class Musicvideoid extends AbstractModel {
00561
00562
00563 public static final String MUSICVIDEOID = "musicvideoid";
00564
00565
00566 public final Integer musicvideoid;
00567
00571 public Musicvideoid(Integer musicvideoid) {
00572 this.musicvideoid = musicvideoid;
00573 }
00574
00575 @Override
00576 public JsonNode toJsonNode() {
00577 final ObjectNode node = OM.createObjectNode();
00578 node.put(MUSICVIDEOID, musicvideoid);
00579 return node;
00580 }
00581
00587 @Override
00588 public void writeToParcel(Parcel parcel, int flags) {
00589 parcel.writeValue(musicvideoid);
00590 }
00591
00595 protected Musicvideoid(Parcel parcel) {
00596 musicvideoid = parcel.readInt();
00597 }
00598
00602 public static final Parcelable.Creator<Musicvideoid> CREATOR = new Parcelable.Creator<Musicvideoid>() {
00603 @Override
00604 public Musicvideoid createFromParcel(Parcel parcel) {
00605 return new Musicvideoid(parcel);
00606 }
00607 @Override
00608 public Musicvideoid[] newArray(int n) {
00609 return new Musicvideoid[n];
00610 }
00611 };
00612
00613 @Override
00614 public int describeContents() {
00615 return 0;
00616 }
00617 }
00618
00623 public static class Artistid extends AbstractModel {
00624
00625
00626 public static final String ARTISTID = "artistid";
00627
00628
00629 public final Integer artistid;
00630
00634 public Artistid(Integer artistid) {
00635 this.artistid = artistid;
00636 }
00637
00638 @Override
00639 public JsonNode toJsonNode() {
00640 final ObjectNode node = OM.createObjectNode();
00641 node.put(ARTISTID, artistid);
00642 return node;
00643 }
00644
00650 @Override
00651 public void writeToParcel(Parcel parcel, int flags) {
00652 parcel.writeValue(artistid);
00653 }
00654
00658 protected Artistid(Parcel parcel) {
00659 artistid = parcel.readInt();
00660 }
00661
00665 public static final Parcelable.Creator<Artistid> CREATOR = new Parcelable.Creator<Artistid>() {
00666 @Override
00667 public Artistid createFromParcel(Parcel parcel) {
00668 return new Artistid(parcel);
00669 }
00670 @Override
00671 public Artistid[] newArray(int n) {
00672 return new Artistid[n];
00673 }
00674 };
00675
00676 @Override
00677 public int describeContents() {
00678 return 0;
00679 }
00680 }
00681
00686 public static class Albumid extends AbstractModel {
00687
00688
00689 public static final String ALBUMID = "albumid";
00690
00691
00692 public final Integer albumid;
00693
00697 public Albumid(Integer albumid) {
00698 this.albumid = albumid;
00699 }
00700
00701 @Override
00702 public JsonNode toJsonNode() {
00703 final ObjectNode node = OM.createObjectNode();
00704 node.put(ALBUMID, albumid);
00705 return node;
00706 }
00707
00713 @Override
00714 public void writeToParcel(Parcel parcel, int flags) {
00715 parcel.writeValue(albumid);
00716 }
00717
00721 protected Albumid(Parcel parcel) {
00722 albumid = parcel.readInt();
00723 }
00724
00728 public static final Parcelable.Creator<Albumid> CREATOR = new Parcelable.Creator<Albumid>() {
00729 @Override
00730 public Albumid createFromParcel(Parcel parcel) {
00731 return new Albumid(parcel);
00732 }
00733 @Override
00734 public Albumid[] newArray(int n) {
00735 return new Albumid[n];
00736 }
00737 };
00738
00739 @Override
00740 public int describeContents() {
00741 return 0;
00742 }
00743 }
00744
00749 public static class Songid extends AbstractModel {
00750
00751
00752 public static final String SONGID = "songid";
00753
00754
00755 public final Integer songid;
00756
00760 public Songid(Integer songid) {
00761 this.songid = songid;
00762 }
00763
00764 @Override
00765 public JsonNode toJsonNode() {
00766 final ObjectNode node = OM.createObjectNode();
00767 node.put(SONGID, songid);
00768 return node;
00769 }
00770
00776 @Override
00777 public void writeToParcel(Parcel parcel, int flags) {
00778 parcel.writeValue(songid);
00779 }
00780
00784 protected Songid(Parcel parcel) {
00785 songid = parcel.readInt();
00786 }
00787
00791 public static final Parcelable.Creator<Songid> CREATOR = new Parcelable.Creator<Songid>() {
00792 @Override
00793 public Songid createFromParcel(Parcel parcel) {
00794 return new Songid(parcel);
00795 }
00796 @Override
00797 public Songid[] newArray(int n) {
00798 return new Songid[n];
00799 }
00800 };
00801
00802 @Override
00803 public int describeContents() {
00804 return 0;
00805 }
00806 }
00807
00812 public static class Genreid extends AbstractModel {
00813
00814
00815 public static final String GENREID = "genreid";
00816
00817
00818 public final Integer genreid;
00819
00823 public Genreid(Integer genreid) {
00824 this.genreid = genreid;
00825 }
00826
00827 @Override
00828 public JsonNode toJsonNode() {
00829 final ObjectNode node = OM.createObjectNode();
00830 node.put(GENREID, genreid);
00831 return node;
00832 }
00833
00839 @Override
00840 public void writeToParcel(Parcel parcel, int flags) {
00841 parcel.writeValue(genreid);
00842 }
00843
00847 protected Genreid(Parcel parcel) {
00848 genreid = parcel.readInt();
00849 }
00850
00854 public static final Parcelable.Creator<Genreid> CREATOR = new Parcelable.Creator<Genreid>() {
00855 @Override
00856 public Genreid createFromParcel(Parcel parcel) {
00857 return new Genreid(parcel);
00858 }
00859 @Override
00860 public Genreid[] newArray(int n) {
00861 return new Genreid[n];
00862 }
00863 };
00864
00865 @Override
00866 public int describeContents() {
00867 return 0;
00868 }
00869 }
00870 }
00871
00878 public static class PropertyValue extends AbstractModel {
00879 public final static String API_TYPE = "Playlist.Property.Value";
00880
00881
00882 public static final String SIZE = "size";
00883 public static final String TYPE = "type";
00884
00885
00886 public final Integer size;
00887 public final String type;
00888
00893 public PropertyValue(Integer size, String type) {
00894 this.size = size;
00895 this.type = type;
00896 }
00897
00902 public PropertyValue(JsonNode node) {
00903 size = parseInt(node, SIZE);
00904 type = parseString(node, TYPE);
00905 }
00906
00907 @Override
00908 public JsonNode toJsonNode() {
00909 final ObjectNode node = OM.createObjectNode();
00910 node.put(SIZE, size);
00911 node.put(TYPE, type);
00912 return node;
00913 }
00914
00920 static List<PropertyValue> getPlaylistModelPropertyValueList(JsonNode node, String key) {
00921 if (node.has(key)) {
00922 final ArrayNode a = (ArrayNode)node.get(key);
00923 final List<PropertyValue> l = new ArrayList<PropertyValue>(a.size());
00924 for (int i = 0; i < a.size(); i++) {
00925 l.add(new PropertyValue((JsonNode)a.get(i)));
00926 }
00927 return l;
00928 }
00929 return new ArrayList<PropertyValue>(0);
00930 }
00931
00937 @Override
00938 public void writeToParcel(Parcel parcel, int flags) {
00939 parcel.writeValue(size);
00940 parcel.writeValue(type);
00941 }
00942
00946 protected PropertyValue(Parcel parcel) {
00947 size = parcel.readInt();
00948 type = parcel.readString();
00949 }
00950
00954 public static final Parcelable.Creator<PropertyValue> CREATOR = new Parcelable.Creator<PropertyValue>() {
00955 @Override
00956 public PropertyValue createFromParcel(Parcel parcel) {
00957 return new PropertyValue(parcel);
00958 }
00959 @Override
00960 public PropertyValue[] newArray(int n) {
00961 return new PropertyValue[n];
00962 }
00963 };
00964
00965 @Override
00966 public int describeContents() {
00967 return 0;
00968 }
00969
00973 public interface Type {
00974
00975 public final String UNKNOWN = "unknown";
00976 public final String VIDEO = "video";
00977 public final String AUDIO = "audio";
00978 public final String PICTURE = "picture";
00979 public final String MIXED = "mixed";
00980
00981 public final static Set<String> values = new HashSet<String>(Arrays.asList(UNKNOWN, VIDEO, AUDIO, PICTURE, MIXED));
00982 }
00983 }
00984
00988 public interface PropertyName {
00989
00990 public final String TYPE = "type";
00991 public final String SIZE = "size";
00992
00993 public final static Set<String> values = new HashSet<String>(Arrays.asList(TYPE, SIZE));
00994 }
00995
00999 public interface Type {
01000
01001 public final String UNKNOWN = "unknown";
01002 public final String VIDEO = "video";
01003 public final String AUDIO = "audio";
01004 public final String PICTURE = "picture";
01005 public final String MIXED = "mixed";
01006
01007 public final static Set<String> values = new HashSet<String>(Arrays.asList(UNKNOWN, VIDEO, AUDIO, PICTURE, MIXED));
01008 }
01009 }