1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.support.model.item;
17
18 import org.fourthline.cling.support.model.PersonWithRole;
19 import org.fourthline.cling.support.model.Res;
20 import org.fourthline.cling.support.model.StorageMedium;
21 import org.fourthline.cling.support.model.container.Container;
22
23 import java.util.Arrays;
24 import java.util.List;
25
26 import static org.fourthline.cling.support.model.DIDLObject.Property.DC;
27 import static org.fourthline.cling.support.model.DIDLObject.Property.UPNP;
28
29
30
31
32 public class PlaylistItem extends Item {
33
34 public static final Class CLASS = new Class("object.item.playlistItem");
35
36 public PlaylistItem() {
37 setClazz(CLASS);
38 }
39
40 public PlaylistItem(Item other) {
41 super(other);
42 }
43
44 public PlaylistItem(String id, Container parent, String title, String creator, Res... resource) {
45 this(id, parent.getId(), title, creator, resource);
46 }
47
48 public PlaylistItem(String id, String parentID, String title, String creator, Res... resource) {
49 super(id, parentID, title, creator, CLASS);
50 if (resource != null) {
51 getResources().addAll(Arrays.asList(resource));
52 }
53 }
54
55 public PersonWithRole getFirstArtist() {
56 return getFirstPropertyValue(UPNP.ARTIST.class);
57 }
58
59 public PersonWithRole[] getArtists() {
60 List<PersonWithRole> list = getPropertyValues(UPNP.ARTIST.class);
61 return list.toArray(new PersonWithRole[list.size()]);
62 }
63
64 public PlaylistItem setArtists(PersonWithRole[] artists) {
65 removeProperties(UPNP.ARTIST.class);
66 for (PersonWithRole artist : artists) {
67 addProperty(new UPNP.ARTIST(artist));
68 }
69 return this;
70 }
71
72 public String getFirstGenre() {
73 return getFirstPropertyValue(UPNP.GENRE.class);
74 }
75
76 public String[] getGenres() {
77 List<String> list = getPropertyValues(UPNP.GENRE.class);
78 return list.toArray(new String[list.size()]);
79 }
80
81 public PlaylistItem setGenres(String[] genres) {
82 removeProperties(UPNP.GENRE.class);
83 for (String genre : genres) {
84 addProperty(new UPNP.GENRE(genre));
85 }
86 return this;
87 }
88
89 public String getDescription() {
90 return getFirstPropertyValue(DC.DESCRIPTION.class);
91 }
92
93 public PlaylistItem setDescription(String description) {
94 replaceFirstProperty(new DC.DESCRIPTION(description));
95 return this;
96 }
97
98 public String getLongDescription() {
99 return getFirstPropertyValue(UPNP.LONG_DESCRIPTION.class);
100 }
101
102 public PlaylistItem setLongDescription(String description) {
103 replaceFirstProperty(new UPNP.LONG_DESCRIPTION(description));
104 return this;
105 }
106
107 public String getLanguage() {
108 return getFirstPropertyValue(DC.LANGUAGE.class);
109 }
110
111 public PlaylistItem setLanguage(String language) {
112 replaceFirstProperty(new DC.LANGUAGE(language));
113 return this;
114 }
115
116 public StorageMedium getStorageMedium() {
117 return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
118 }
119
120 public PlaylistItem setStorageMedium(StorageMedium storageMedium) {
121 replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
122 return this;
123 }
124
125 public String getDate() {
126 return getFirstPropertyValue(DC.DATE.class);
127 }
128
129 public PlaylistItem setDate(String date) {
130 replaceFirstProperty(new DC.DATE(date));
131 return this;
132 }
133
134 }