1 /***
2 * Java DAB EPG API - Serialize/Deserialize To/From POJOs to XML/Binary as per
3 * ETSI specifications TS 102 818 (XML Specification for DAB EPG) and TS 102
4 * 371 (Transportation and Binary Encoding Specification for EPG).
5 *
6 * Copyright (C) 2007 GCap Media PLC
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 package com.gcapmedia.dab.epg;
23
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
28
29 /***
30 * Describes a grouping of programmes, programme events or other groups.
31 */
32 public class ProgrammeGroup {
33
34 /***
35 * Programme group names
36 */
37 private NameGroup names;
38
39 /***
40 * Programme media descriptions
41 */
42 private MediaGroup media;
43
44 /***
45 * Programme genres
46 */
47 private List<Genre> genres;
48
49 /***
50 * Programme keywords
51 */
52 private Keywords keywords;
53
54 /***
55 * Groups this programme is a member of
56 */
57 private List<Membership> memberships;
58
59 /***
60 * Used to link to additional information or content
61 */
62 private List<Link> links;
63
64 /***
65 * <p>An identifier for a programme, programme event. Unlike a full CRID
66 * this is designed to be more appropriate for limited bandwidth data
67 * channels and for basic EPG receivers. The short CRID (sCRID) is a
68 * 24-bit integer, expressed as a decimal value, with a range of 0 to
69 * 16,777,215 inclusive.</p>
70 *
71 * <p>The following rules should be applied whenever short CRIDs are used
72 * in an EPG service:
73 *
74 * <ul>
75 * <li>The sCRID shall only be unique within a single EPG Service, therefore
76 * a receiver must process it in some way on decoding to ensure that it is
77 * globally unique</li>
78 * <li>The sCRID must not be reused within that EPG service for a minimum of
79 * six month</li>
80 * </ul>
81 * </p>
82 */
83 private int shortId;
84
85 /***
86 * Programme group CRID
87 */
88 private Crid id;
89
90 /***
91 * Schedule version number
92 */
93 private int version;
94
95 /***
96 * Indicates the type of programme grouping
97 */
98 private Type type;
99
100 /***
101 * The number of items within the group
102 */
103 private int numOfItems;
104
105 /***
106 * Create a new programme group
107 */
108 public ProgrammeGroup() {
109 names = new NameGroup();
110 genres = new ArrayList<Genre>();
111 memberships = new ArrayList<Membership>();
112 links = new ArrayList<Link>();
113 }
114
115 /***
116 * @return Returns the name group for this programme group
117 */
118 public NameGroup getNames() {
119 return names;
120 }
121
122 /***
123 * @return Returns media descriptions related to this programme
124 */
125 public MediaGroup getMedia() {
126 return media;
127 }
128
129 /***
130 * Adds a genre to the programme
131 * @param genre Genre to add
132 */
133 public void addGenre(Genre genre) {
134 genres.add(genre);
135 }
136
137 /***
138 * Clears all genre from the programme
139 */
140 public void clearGenres() {
141 genres.clear();
142 }
143
144 /***
145 * Removes a genre from the programme
146 * @param genre Genre to remove
147 */
148 public void removeGenre(Genre genre) {
149 genres.remove(genre);
150 }
151
152 /***
153 * @return Returns the programme genres
154 */
155 public List<Genre> getGenres() {
156 return genres;
157 }
158
159 /***
160 * Set the keywords associated with this programme
161 * @param keywords Keywords to use
162 */
163 public void setKeywords(Keywords keywords) {
164 this.keywords = keywords;
165 }
166
167 /***
168 * @return Returns the keywords associated with this programme
169 */
170 public Keywords getKeywords() {
171 return keywords;
172 }
173
174 /***
175 * @return Returns memberships this programme has
176 */
177 public Collection<Membership> getMemberships() {
178 return Collections.unmodifiableCollection(memberships);
179 }
180
181 /***
182 * Add a membership to this programme
183 * @param membership Membership to add
184 */
185 public void addMembership(Membership membership) {
186 memberships.add(membership);
187 }
188
189 /***
190 * Removes a membership from this programme
191 * @param membership Membership to remove
192 */
193 public void removeMembership(Membership membership) {
194 memberships.remove(membership);
195 }
196
197 /***
198 * Clears all memberships from this programme
199 */
200 public void clearMemberships() {
201 memberships.clear();
202 }
203
204 /***
205 * @return Returns links to additional information or content
206 */
207 public Collection<Link> getLinks() {
208 return Collections.unmodifiableCollection(links);
209 }
210
211 /***
212 * Add a link from this programme to additional information or content
213 * @param link Link to add
214 */
215 public void addLink(Link link) {
216 links.add(link);
217 }
218
219 /***
220 * Remove a link from this programme
221 * @param link Link to remove
222 */
223 public void removeLink(Link link) {
224 links.remove(link);
225 }
226
227 /***
228 * Clear all links from this programme
229 */
230 public void clearLinks() {
231 links.clear();
232 }
233
234 /***
235 * Gets the value of the shortId property.
236 *
237 */
238 public int getShortId() {
239 return shortId;
240 }
241
242 /***
243 * Sets the value of the shortId property.
244 *
245 */
246 public void setShortId(int value) {
247 this.shortId = value;
248 }
249
250 /***
251 * Sets the programme Content Reference ID (CRID)
252 * @param id CRID to set
253 */
254 public void setId(Crid id) {
255 this.id = id;
256 }
257
258 /***
259 * @return Returns the programme Content Reference ID (CRID)
260 */
261 public Crid getId() {
262 return id;
263 }
264
265 /***
266 * Sets the version number of this schedule
267 * @param version Schedule version number
268 */
269 public void setVersion(int version) {
270 this.version = version;
271 }
272
273 /***
274 * @return Returns the schedule version
275 */
276 public int getVersion() {
277 return version;
278 }
279
280 /***
281 * @return Returns the programme group type
282 */
283 public Type getType() {
284 return type;
285 }
286
287 /***
288 * Set the programme group type
289 * @param type Programme group type
290 */
291 public void setType(Type type) {
292 this.type = type;
293 }
294
295 /***
296 * @return Returns the number of items in the group
297 */
298 public int getNumberOfItems() {
299 return numOfItems;
300 }
301
302 /***
303 * Sets the number of items in the group
304 * @param numOfItems Number of items in the group
305 */
306 public void setNumberOfItems(int numOfItems) {
307 this.numOfItems = numOfItems;
308 }
309
310 /***
311 * Indicates the type of programme grouping
312 */
313 public enum Type {
314
315 /***
316 * An ordered or unordered collection of programmes that is shown
317 * in a sequence (e.g. "The News Quiz" season 1)
318 */
319 SERIES("series"),
320
321 /***
322 * A programme theme that is typically associated with a collection
323 * of series (e.g. all episodes of "The News Quiz")
324 */
325 SHOW("show"),
326
327 /***
328 * The editorial concept for a programme from which specific
329 * programme versions have been derived (e.g.
330 */
331 PROGRAM_CONCEPT("programeConcept"),
332
333 /***
334 * A collection of individual programmes that are shown as a group
335 * because they are editorially coherent (e.g. a general sports
336 * programme with individual sub-programmes covering different
337 * events).
338 */
339 MAGAZINE("magazine"),
340
341 /***
342 * A collection of programmes that is used to allow segments from
343 * multiple programmes to be combined in segment groups.
344 */
345 PROGRAM_COMPILATION("programCompilation"),
346
347 /***
348 * Can be used for any group not defined in the preceding list
349 * where all memembers of the group should be acquired if the
350 * group is selected. For example, a group of channel highlights
351 * or recommendations.
352 */
353 OTHER_COLLECTION("otherCollection"),
354
355 /***
356 * Can be used for any group not defined in the list about where
357 * only one member of the group should be acquired if the group
358 * is selected.
359 */
360 OTHER_CHOICE("otherChoice"),
361
362 /***
363 * A collection of programmes on a particular topic or theme.
364 */
365 TOPIC("topic");
366
367 private String value;
368
369 /***
370 * Create a new programme group type
371 */
372 private Type(String value) {
373 this.value = value;
374 }
375
376 /***
377 * @return Returns the string value of the enum
378 */
379 public String value() {
380 return value;
381 }
382
383 /***
384 * Parse the type from a string value
385 */
386 public static Type fromValue(String v) {
387 for (Type c: Type.values()) {
388 if (c.value.equals(v)) {
389 return c;
390 }
391 }
392 throw new IllegalArgumentException(v);
393 }
394
395 /***
396 * @see java.lang.Enum#toString()
397 */
398 public String toString() {
399 return value;
400 }
401
402 }
403
404 }