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.List;
26
27 import org.joda.time.ReadableInstant;
28
29 /***
30 * Indicates the time period covered by a schedule, from the billed start time of the first
31 * programme to the billed end time of the last programme. It can also denote the services
32 * covered.
33 */
34 public class Scope {
35
36 /***
37 * Services covered in this scope
38 */
39 private List<ContentId> services;
40
41 /***
42 * Billed start time of the first programme within this scope
43 */
44 private ReadableInstant startTime;
45
46 /***
47 * Billed end time of the last programme within this scope
48 */
49 private ReadableInstant stopTime;
50
51 /***
52 * Create a new scope
53 */
54 public Scope(ReadableInstant startTime, ReadableInstant stopTime) {
55 services = new ArrayList<ContentId>();
56 this.startTime = startTime;
57 this.stopTime = stopTime;
58 }
59
60 /***
61 * @return Returns the list of services covered in this scope
62 */
63 public List<ContentId> getServices() {
64 return services;
65 }
66
67 /***
68 * @return Returns the billed start time of the first programme
69 * in the scope
70 */
71 public ReadableInstant getStartTime() {
72 return startTime;
73 }
74
75 /***
76 * @return Returns the billed end time of the last programme in
77 * the scope
78 */
79 public ReadableInstant getStopTime() {
80 return stopTime;
81 }
82
83 /***
84 * Adds a service to this scope
85 * @param bearer Service bearer ID to add
86 */
87 public void addService(ContentId bearer) {
88 services.add(bearer);
89 }
90
91 /***
92 * @see java.lang.Object#equals(java.lang.Object)
93 */
94 @Override
95 public boolean equals(Object obj) {
96 if(!(obj instanceof Scope)) {
97 return false;
98 }
99 Scope that = (Scope)obj;
100
101 if(this.startTime != null && that.startTime != null && !this.startTime.isEqual(that.startTime)) {
102 return false;
103 }
104 if(this.stopTime != null && that.stopTime != null && !this.stopTime.isEqual(that.stopTime)) {
105 return false;
106 }
107
108 return this.services.equals(that.services);
109 }
110
111 /***
112 * @see java.lang.Object#toString()
113 */
114 @Override
115 public String toString() {
116 StringBuilder buf = new StringBuilder();
117 buf.append("Scope [start=");
118 if(startTime != null) {
119 buf.append(startTime.toString());
120 } else {
121 buf.append("na");
122 }
123 buf.append(", stop=");
124 if(stopTime != null) {
125 buf.append(stopTime.toString());
126 } else {
127 buf.append("na");
128 }
129 buf.append("]: ");
130 buf.append(services.toString());
131 return buf.toString();
132 }
133
134 }