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.Res;
20 import org.fourthline.cling.support.model.StorageMedium;
21 import org.fourthline.cling.support.model.container.Container;
22
23 import java.util.List;
24
25 import static org.fourthline.cling.support.model.DIDLObject.Property.DC;
26 import static org.fourthline.cling.support.model.DIDLObject.Property.UPNP;
27
28
29
30
31 public class AudioBook extends AudioItem {
32
33 public static final Class CLASS = new Class("object.item.audioItem.audioBook");
34
35 public AudioBook() {
36 setClazz(CLASS);
37 }
38
39 public AudioBook(Item other) {
40 super(other);
41 }
42
43 public AudioBook(String id, Container parent, String title, String creator, Res... resource) {
44 this(id, parent.getId(), title, creator, null, null, null, resource);
45 }
46
47 public AudioBook(String id, Container parent, String title, String creator, String producer, String contributor, String date, Res... resource) {
48 this(id, parent.getId(), title, creator, new Person(producer), new Person(contributor), date, resource);
49 }
50
51 public AudioBook(String id, String parentID, String title, String creator, Person producer, Person contributor, String date, Res... resource) {
52 super(id, parentID, title, creator, resource);
53 setClazz(CLASS);
54 if (producer != null)
55 addProperty(new UPNP.PRODUCER(producer));
56 if (contributor != null)
57 addProperty(new DC.CONTRIBUTOR(contributor));
58 if (date != null)
59 setDate(date);
60 }
61
62 public StorageMedium getStorageMedium() {
63 return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
64 }
65
66 public AudioBook setStorageMedium(StorageMedium storageMedium) {
67 replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
68 return this;
69 }
70
71 public Person getFirstProducer() {
72 return getFirstPropertyValue(UPNP.PRODUCER.class);
73 }
74
75 public Person[] getProducers() {
76 List<Person> list = getPropertyValues(UPNP.PRODUCER.class);
77 return list.toArray(new Person[list.size()]);
78 }
79
80 public AudioBook setProducers(Person[] persons) {
81 removeProperties(UPNP.PRODUCER.class);
82 for (Person p : persons) {
83 addProperty(new UPNP.PRODUCER(p));
84 }
85 return this;
86 }
87
88 public Person getFirstContributor() {
89 return getFirstPropertyValue(DC.CONTRIBUTOR.class);
90 }
91
92 public Person[] getContributors() {
93 List<Person> list = getPropertyValues(DC.CONTRIBUTOR.class);
94 return list.toArray(new Person[list.size()]);
95 }
96
97 public AudioBook setContributors(Person[] contributors) {
98 removeProperties(DC.CONTRIBUTOR.class);
99 for (Person p : contributors) {
100 addProperty(new DC.CONTRIBUTOR(p));
101 }
102 return this;
103 }
104
105 public String getDate() {
106 return getFirstPropertyValue(DC.DATE.class);
107 }
108
109 public AudioBook setDate(String date) {
110 replaceFirstProperty(new DC.DATE(date));
111 return this;
112 }
113
114 }