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.Person;
19 import org.fourthline.cling.support.model.PersonWithRole;
20 import org.fourthline.cling.support.model.Res;
21 import org.fourthline.cling.support.model.StorageMedium;
22 import org.fourthline.cling.support.model.container.Container;
23
24 import java.net.URI;
25 import java.util.Arrays;
26 import java.util.List;
27
28 import static org.fourthline.cling.support.model.DIDLObject.Property.DC;
29 import static org.fourthline.cling.support.model.DIDLObject.Property.UPNP;
30
31
32
33
34 public class TextItem extends Item {
35
36 public static final Class CLASS = new Class("object.item.textItem");
37
38 public TextItem() {
39 setClazz(CLASS);
40 }
41
42 public TextItem(Item other) {
43 super(other);
44 }
45
46 public TextItem(String id, Container parent, String title, String creator, Res... resource) {
47 this(id, parent.getId(), title, creator, resource);
48 }
49
50 public TextItem(String id, String parentID, String title, String creator, Res... resource) {
51 super(id, parentID, title, creator, CLASS);
52 if (resource != null) {
53 getResources().addAll(Arrays.asList(resource));
54 }
55 }
56
57 public PersonWithRole getFirstAuthor() {
58 return getFirstPropertyValue(UPNP.AUTHOR.class);
59 }
60
61 public PersonWithRole[] getAuthors() {
62 List<PersonWithRole> list = getPropertyValues(UPNP.AUTHOR.class);
63 return list.toArray(new PersonWithRole[list.size()]);
64 }
65
66 public TextItem setAuthors(PersonWithRole[] persons) {
67 removeProperties(UPNP.AUTHOR.class);
68 for (PersonWithRole p: persons) {
69 addProperty(new UPNP.AUTHOR(p));
70 }
71 return this;
72 }
73
74 public String getDescription() {
75 return getFirstPropertyValue(DC.DESCRIPTION.class);
76 }
77
78 public TextItem setDescription(String description) {
79 replaceFirstProperty(new DC.DESCRIPTION(description));
80 return this;
81 }
82
83 public String getLongDescription() {
84 return getFirstPropertyValue(UPNP.LONG_DESCRIPTION.class);
85 }
86
87 public TextItem setLongDescription(String description) {
88 replaceFirstProperty(new UPNP.LONG_DESCRIPTION(description));
89 return this;
90 }
91
92 public String getLanguage() {
93 return getFirstPropertyValue(DC.LANGUAGE.class);
94 }
95
96 public TextItem setLanguage(String language) {
97 replaceFirstProperty(new DC.LANGUAGE(language));
98 return this;
99 }
100
101 public StorageMedium getStorageMedium() {
102 return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
103 }
104
105 public TextItem setStorageMedium(StorageMedium storageMedium) {
106 replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
107 return this;
108 }
109
110 public String getDate() {
111 return getFirstPropertyValue(DC.DATE.class);
112 }
113
114 public TextItem setDate(String date) {
115 replaceFirstProperty(new DC.DATE(date));
116 return this;
117 }
118
119 public URI getFirstRelation() {
120 return getFirstPropertyValue(DC.RELATION.class);
121 }
122
123 public URI[] getRelations() {
124 List<URI> list = getPropertyValues(DC.RELATION.class);
125 return list.toArray(new URI[list.size()]);
126 }
127
128 public TextItem setRelations(URI[] relations) {
129 removeProperties(DC.RELATION.class);
130 for (URI relation : relations) {
131 addProperty(new DC.RELATION(relation));
132 }
133 return this;
134 }
135
136 public String getFirstRights() {
137 return getFirstPropertyValue(DC.RIGHTS.class);
138 }
139
140 public String[] getRights() {
141 List<String> list = getPropertyValues(DC.RIGHTS.class);
142 return list.toArray(new String[list.size()]);
143 }
144
145 public TextItem setRights(String[] rights) {
146 removeProperties(DC.RIGHTS.class);
147 for (String right : rights) {
148 addProperty(new DC.RIGHTS(right));
149 }
150 return this;
151 }
152
153 public String getRating() {
154 return getFirstPropertyValue(UPNP.RATING.class);
155 }
156
157 public TextItem setRating(String rating) {
158 replaceFirstProperty(new UPNP.RATING(rating));
159 return this;
160 }
161
162 public Person getFirstContributor() {
163 return getFirstPropertyValue(DC.CONTRIBUTOR.class);
164 }
165
166 public Person[] getContributors() {
167 List<Person> list = getPropertyValues(DC.CONTRIBUTOR.class);
168 return list.toArray(new Person[list.size()]);
169 }
170
171 public TextItem setContributors(Person[] contributors) {
172 removeProperties(DC.CONTRIBUTOR.class);
173 for (Person p : contributors) {
174 addProperty(new DC.CONTRIBUTOR(p));
175 }
176 return this;
177 }
178
179 public Person getFirstPublisher() {
180 return getFirstPropertyValue(DC.PUBLISHER.class);
181 }
182
183 public Person[] getPublishers() {
184 List<Person> list = getPropertyValues(DC.PUBLISHER.class);
185 return list.toArray(new Person[list.size()]);
186 }
187
188 public TextItem setPublishers(Person[] publishers) {
189 removeProperties(DC.PUBLISHER.class);
190 for (Person publisher : publishers) {
191 addProperty(new DC.PUBLISHER(publisher));
192 }
193 return this;
194 }
195
196 }