View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.model.container;
17  
18  import org.fourthline.cling.support.model.Person;
19  import org.fourthline.cling.support.model.StorageMedium;
20  
21  import java.net.URI;
22  import java.util.List;
23  
24  import static org.fourthline.cling.support.model.DIDLObject.Property.DC;
25  import static org.fourthline.cling.support.model.DIDLObject.Property.UPNP;
26  
27  /**
28   * @author Christian Bauer
29   */
30  public class Album extends Container {
31  
32      public static final Class CLASS = new Class("object.container.album");
33  
34      public Album() {
35          setClazz(CLASS);
36      }
37  
38      public Album(Container other) {
39          super(other);
40      }
41  
42      public Album(String id, Container parent, String title, String creator, Integer childCount) {
43          this(id, parent.getId(), title, creator, childCount);
44      }
45  
46      public Album(String id, String parentID, String title, String creator, Integer childCount) {
47          super(id, parentID, title, creator, CLASS, childCount);
48      }
49  
50      public String getDescription() {
51          return getFirstPropertyValue(DC.DESCRIPTION.class);
52      }
53  
54      public Album setDescription(String description) {
55          replaceFirstProperty(new DC.DESCRIPTION(description));
56          return this;
57      }
58  
59      public String getLongDescription() {
60          return getFirstPropertyValue(UPNP.LONG_DESCRIPTION.class);
61      }
62  
63      public Album setLongDescription(String description) {
64          replaceFirstProperty(new UPNP.LONG_DESCRIPTION(description));
65          return this;
66      }
67  
68      public StorageMedium getStorageMedium() {
69          return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
70      }
71  
72      public Album setStorageMedium(StorageMedium storageMedium) {
73          replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
74          return this;
75      }
76  
77      public String getDate() {
78          return getFirstPropertyValue(DC.DATE.class);
79      }
80  
81      public Album setDate(String date) {
82          replaceFirstProperty(new DC.DATE(date));
83          return this;
84      }
85  
86      public URI getFirstRelation() {
87          return getFirstPropertyValue(DC.RELATION.class);
88      }
89  
90      public URI[] getRelations() {
91          List<URI> list = getPropertyValues(DC.RELATION.class);
92          return list.toArray(new URI[list.size()]);
93      }
94  
95      public Album setRelations(URI[] relations) {
96          removeProperties(DC.RELATION.class);
97          for (URI relation : relations) {
98              addProperty(new DC.RELATION(relation));
99          }
100         return this;
101     }
102 
103     public String getFirstRights() {
104         return getFirstPropertyValue(DC.RIGHTS.class);
105     }
106 
107     public String[] getRights() {
108         List<String> list = getPropertyValues(DC.RIGHTS.class);
109         return list.toArray(new String[list.size()]);
110     }
111 
112     public Album setRights(String[] rights) {
113         removeProperties(DC.RIGHTS.class);
114         for (String right : rights) {
115             addProperty(new DC.RIGHTS(right));
116         }
117         return this;
118     }
119 
120     public Person getFirstContributor() {
121         return getFirstPropertyValue(DC.CONTRIBUTOR.class);
122     }
123 
124     public Person[] getContributors() {
125         List<Person> list = getPropertyValues(DC.CONTRIBUTOR.class);
126         return list.toArray(new Person[list.size()]);
127     }
128 
129     public Album setContributors(Person[] contributors) {
130         removeProperties(DC.CONTRIBUTOR.class);
131         for (Person p : contributors) {
132             addProperty(new DC.CONTRIBUTOR(p));
133         }
134         return this;
135     }
136 
137     public Person getFirstPublisher() {
138         return getFirstPropertyValue(DC.PUBLISHER.class);
139     }
140 
141     public Person[] getPublishers() {
142         List<Person> list = getPropertyValues(DC.PUBLISHER.class);
143         return list.toArray(new Person[list.size()]);
144     }
145 
146     public Album setPublishers(Person[] publishers) {
147         removeProperties(DC.PUBLISHER.class);
148         for (Person publisher : publishers) {
149             addProperty(new DC.PUBLISHER(publisher));
150         }
151         return this;
152     }
153 
154 }