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.*;
25
26 /***
27 * A programme event can be used to break a programme into sections or to
28 * highlight particular sections of the programme.
29 */
30 public class ProgrammeEvent {
31
32 /***
33 * Programme names
34 */
35 private NameGroup names;
36
37 /***
38 * Programme locations
39 */
40 private List<Location> locations;
41
42 /***
43 * Programme media descriptions
44 */
45 private MediaGroup media;
46
47 /***
48 * Programme genres
49 */
50 private List<Genre> genres;
51
52 /***
53 * Conditional Access type
54 */
55 private CAType ca = CAType.NONE;
56
57 /***
58 * Programme keywords
59 */
60 private Keywords keywords;
61
62 /***
63 * Groups this programme is a member of
64 */
65 private List<Membership> memberships;
66
67 /***
68 * Used to link to additional information or content
69 */
70 private List<Link> links;
71
72 /***
73 * <p>An identifier for a programme, programme event. Unlike a full CRID
74 * this is designed to be more appropriate for limited bandwidth data
75 * channels and for basic EPG receivers. The short CRID (sCRID) is a
76 * 24-bit integer, expressed as a decimal value, with a range of 0 to
77 * 16,777,215 inclusive.</p>
78 *
79 * <p>The following rules should be applied whenever short CRIDs are used
80 * in an EPG service:
81 *
82 * <ul>
83 * <li>The sCRID shall only be unique within a single EPG Service, therefore
84 * a receiver must process it in some way on decoding to ensure that it is
85 * globally unique</li>
86 * <li>The sCRID must not be reused within that EPG service for a minimum of
87 * six month</li>
88 * </ul>
89 * </p>
90 */
91 private int shortId;
92
93 /***
94 * Programme CRID
95 */
96 private Crid id;
97
98 /***
99 * This is used by the broadcaster to indicate a recommended
100 * programme or programme event.
101 */
102 private Recommendation recommendation = Recommendation.NO;
103
104 /***
105 * This indicates, for the duration of this programme or event,
106 * whether the parent service is being broadcast (i.e. "on-air")
107 * or not (i.e. "off-air"). At times when a service is not being
108 * broadcast the broadcast can use this facility to include "dummy"
109 * EPG entries that promote the service.
110 */
111 private BroadcastFlag broadcastFlag;
112
113 /***
114 * Programme locale in order to determine the two letter language
115 * code in ISO 639-1
116 */
117 private Locale locale = Locale.getDefault();
118
119 /***
120 * Create a new programme
121 */
122 public ProgrammeEvent() {
123 names = new NameGroup();
124 media = new MediaGroup();
125 locations = new ArrayList<Location>();
126 genres = new ArrayList<Genre>();
127 memberships = new ArrayList<Membership>();
128 links = new ArrayList<Link>();
129 }
130
131 /***
132 * Sets the broadcast flag.
133 * @param By default, this flag is <b>on-air</b> and should not be set. Can be
134 * set to <b>off-air</b> to generate dummy programmes for when a service is not
135 * being broadcast.
136 */
137 public BroadcastFlag setBroadcastFlag(BroadcastFlag flag) {
138 return broadcastFlag;
139 }
140
141 /***
142 * @return Returns the broadcast flag: Can be set to <b>off-air</b> to generate
143 * dummy programmes for when a service is not being broadcast. By default, this
144 * flag is <b>on-air</b> and should not be set.
145 */
146 public BroadcastFlag getBroadcastFlag() {
147 return broadcastFlag;
148 }
149
150 /***
151 * Sets the Conditional Access (CA) type
152 * @param ca CA type to set
153 */
154 public void setCA(CAType ca) {
155 this.ca = ca;
156 }
157
158 /***
159 * @return Returns the Conditional Access (CA) type
160 */
161 public CAType getCA() {
162 return ca;
163 }
164
165 /***
166 * Adds a genre to the programme
167 * @param genre Genre to add
168 */
169 public void addGenre(Genre genre) {
170 genres.add(genre);
171 }
172
173 /***
174 * Clears all genre from the programme
175 */
176 public void clearGenres() {
177 genres.clear();
178 }
179
180 /***
181 * Removes a genre from the programme
182 * @param genre Genre to remove
183 */
184 public void removeGenre(Genre genre) {
185 genres.remove(genre);
186 }
187
188 /***
189 * @return Returns the programme genres
190 */
191 public List<Genre> getGenres() {
192 return genres;
193 }
194
195 /***
196 * Sets the programme Content Reference ID (CRID)
197 * @param id CRID to set
198 */
199 public void setId(Crid id) {
200 this.id = id;
201 }
202
203 /***
204 * @return Returns the programme Content Reference ID (CRID)
205 */
206 public Crid getId() {
207 return id;
208 }
209
210 /***
211 * Set the keywords associated with this programme
212 * @param keywords Keywords to use
213 */
214 public void setKeywords(Keywords keywords) {
215 this.keywords = keywords;
216 }
217
218 /***
219 * @return Returns the keywords associated with this programme
220 */
221 public Keywords getKeywords() {
222 return keywords;
223 }
224
225 /***
226 * Sets the locale associated with this programme
227 * @param locale Locale associated with this programme
228 */
229 public void setLocale(Locale locale) {
230 this.locale = locale;
231 }
232
233 /***
234 * @return Returns the language code (ISO-639) associated with
235 * this programme
236 */
237 public String getLanguage() {
238 return locale.getLanguage();
239 }
240
241 /***
242 * @return Returns links to additional information or content
243 */
244 public Collection<Link> getLinks() {
245 return Collections.unmodifiableCollection(links);
246 }
247
248 /***
249 * Add a link from this programme to additional information or content
250 * @param link Link to add
251 */
252 public void addLink(Link link) {
253 links.add(link);
254 }
255
256 /***
257 * Remove a link from this programme
258 * @param link Link to remove
259 */
260 public void removeLink(Link link) {
261 links.remove(link);
262 }
263
264 /***
265 * Clear all links from this programme
266 */
267 public void clearLinks() {
268 links.clear();
269 }
270
271 /***
272 * @return Returns all locations from this programme
273 */
274 public Collection<Location> getLocations() {
275 return Collections.unmodifiableCollection(locations);
276 }
277
278 /***
279 * Add a location to this programme
280 * @param location Location to add
281 */
282 public void addLocation(Location location) {
283 locations.add(location);
284 }
285
286 /***
287 * Remove a location from this programme
288 * @param location Location to remove
289 */
290 public void removeLocation(Location location) {
291 locations.remove(location);
292 }
293
294 /***
295 * Clear all locations from this programme
296 */
297 public void clearLocations() {
298 locations.clear();
299 }
300
301 /***
302 * @return Returns media descriptions related to this programme
303 */
304 public MediaGroup getMedia() {
305 return media;
306 }
307
308
309 /***
310 * @return Returns memberships this programme has
311 */
312 public Collection<Membership> getMemberships() {
313 return Collections.unmodifiableCollection(memberships);
314 }
315
316 /***
317 * Add a membership to this programme
318 * @param membership Membership to add
319 */
320 public void addMembership(Membership membership) {
321 memberships.add(membership);
322 }
323
324 /***
325 * Removes a membership from this programme
326 * @param membership Membership to remove
327 */
328 public void removeMembership(Membership membership) {
329 memberships.remove(membership);
330 }
331
332 /***
333 * Clears all memberships from this programme
334 */
335 public void clearMemberships() {
336 memberships.clear();
337 }
338
339 /***
340 * @return Returns the name group for this programme
341 */
342 public NameGroup getNames() {
343 return names;
344 }
345
346 /***
347 * Sets the recommendation flag on this programme
348 * @param recommendation Recommendation flag to set
349 */
350 public void setRecommendation(Recommendation recommendation) {
351 this.recommendation = recommendation;
352 }
353
354 /***
355 * @return Returns whether this programme is recommended
356 */
357 public Recommendation getRecommendation() {
358 return recommendation;
359 }
360
361 /***
362 * Sets the programme Short ID
363 * @param shortId Programme Short ID
364 */
365 public void setShortId(int shortId) {
366 this.shortId = shortId;
367 }
368
369 /***
370 * @return Returns the programme short ID
371 */
372 public int getShortId() {
373 return shortId;
374 }
375
376 /***
377 * @see java.lang.Object#toString()
378 */
379 public String toString() {
380 return "ProgrammeEvent [id=" + id + "]";
381 }
382
383 }