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