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.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.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   * @author Christian Bauer
31   */
32  public class ImageItem extends Item{
33  
34      public static final Class CLASS = new Class("object.item.imageItem");
35  
36      public ImageItem() {
37          setClazz(CLASS);
38      }
39  
40      public ImageItem(Item other) {
41          super(other);
42      }
43  
44      public ImageItem(String id, Container parent, String title, String creator, Res... resource) {
45          this(id, parent.getId(), title, creator, resource);
46      }
47  
48      public ImageItem(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 String getDescription() {
56          return getFirstPropertyValue(DC.DESCRIPTION.class);
57      }
58  
59      public ImageItem setDescription(String description) {
60          replaceFirstProperty(new DC.DESCRIPTION(description));
61          return this;
62      }
63  
64      public String getLongDescription() {
65          return getFirstPropertyValue(UPNP.LONG_DESCRIPTION.class);
66      }
67  
68      public ImageItem setLongDescription(String description) {
69          replaceFirstProperty(new UPNP.LONG_DESCRIPTION(description));
70          return this;
71      }
72  
73      public Person getFirstPublisher() {
74          return getFirstPropertyValue(DC.PUBLISHER.class);
75      }
76  
77      public Person[] getPublishers() {
78          List<Person> list = getPropertyValues(DC.PUBLISHER.class);
79          return list.toArray(new Person[list.size()]);
80      }
81  
82      public ImageItem setPublishers(Person[] publishers) {
83          removeProperties(DC.PUBLISHER.class);
84          for (Person publisher : publishers) {
85              addProperty(new DC.PUBLISHER(publisher));
86          }
87          return this;
88      }
89  
90      public StorageMedium getStorageMedium() {
91          return getFirstPropertyValue(UPNP.STORAGE_MEDIUM.class);
92      }
93  
94      public ImageItem setStorageMedium(StorageMedium storageMedium) {
95          replaceFirstProperty(new UPNP.STORAGE_MEDIUM(storageMedium));
96          return this;
97      }
98  
99      public String getRating() {
100         return getFirstPropertyValue(UPNP.RATING.class);
101     }
102 
103     public ImageItem setRating(String rating) {
104         replaceFirstProperty(new UPNP.RATING(rating));
105         return this;
106     }
107 
108     public String getDate() {
109         return getFirstPropertyValue(DC.DATE.class);
110     }
111 
112     public ImageItem setDate(String date) {
113         replaceFirstProperty(new DC.DATE(date));
114         return this;
115     }
116 
117     public String getFirstRights() {
118         return getFirstPropertyValue(DC.RIGHTS.class);
119     }
120 
121     public String[] getRights() {
122         List<String> list = getPropertyValues(DC.RIGHTS.class);
123         return list.toArray(new String[list.size()]);
124     }
125 
126     public ImageItem setRights(String[] rights) {
127         removeProperties(DC.RIGHTS.class);
128         for (String right : rights) {
129             addProperty(new DC.RIGHTS(right));
130         }
131         return this;
132     }
133 }