View Javadoc

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  /***
28   * <p>Container for all EPG information. It may contain schedule, programme or
29   * group information.:</p>
30   * 
31   * <p><b>Programme Groups</b> are used as a container for group elements.</p>
32   * 
33   * <p><b>Schedules</b> allow programmes to be identified within a given time 
34   * period. Note that for contiguous schedules the stop time of a schedule 
35   * should be equal to the start time of the next schedule</p>
36   * 
37   * <p><b>Alternate Sources</b> are used to indicate whether this or related
38   * EPG data is available elsewhere.<p>
39   * 
40   * <p>Programme, Programme Event and Programme Groups all point 'upwards' to 
41   * their parent group(s) using the memberOf link.</p>
42   */
43  public class Epg {
44  
45  	/***
46  	 * EPG System type
47  	 */
48  	private SystemType type;
49  	
50  	/***
51  	 * Programme Groups
52  	 */
53  	private List<ProgrammeGroup> programmeGroups;
54  	
55  	/***
56  	 * Programmes
57  	 */
58  	private List<Programme> programmes;
59  	
60  	/***
61  	 * Schedule data
62  	 */
63  	private Schedule schedule;
64  	
65  	/***
66  	 * Create a new EPG container for DAB
67  	 */
68  	public Epg() {
69  		this(SystemType.DAB);
70  	}
71  	
72  	/***
73  	 * Create a new EPG container
74  	 * @param type EPG System type
75  	 */
76  	public Epg(SystemType type) {
77  		this.type = type;
78  		programmeGroups = new ArrayList<ProgrammeGroup>();
79  		programmes = new ArrayList<Programme>();
80  	}
81  	
82  	/***
83  	 * Set the EPG system type (DAB or DRM)
84  	 * @param type
85  	 */
86  	public void setSystemType(SystemType type) {
87  		this.type = type;
88  	}
89  	
90  	/***
91  	 * @return Returns the system type
92  	 */
93  	public SystemType getSystemType() {
94  		return type;
95  	}
96  	
97  	/***
98  	 * Add a programme group
99  	 * @param group Programme group to add
100 	 */
101 	public void addProgrammeGroup(ProgrammeGroup group) {
102 		programmeGroups.add(group);
103 	}
104 	
105 	/***
106 	 * @return Returns all programme groups
107 	 */
108 	public List<ProgrammeGroup> getProgrammeGroups() {
109 		return programmeGroups;
110 	}
111 	
112 	/***
113 	 * Add a programme
114 	 * @param programme Programme to add
115 	 */
116 	public void addProgramme(Programme programme) {
117 		programmes.add(programme);
118 	}
119 	
120 	/***
121 	 * @return Returns all programmes
122 	 */
123 	public List<Programme> getProgrammes() {
124 		return programmes;
125 	}
126 	
127 	/***
128 	 * Set the schedule
129 	 * @param schedule Schedule to set
130 	 */
131 	public void setSchedule(Schedule schedule) {
132 		this.schedule = schedule;
133 	}
134 	
135 	/***
136 	 * @return Returns the Schedule
137 	 */
138 	public Schedule getSchedule() {
139 		return schedule;
140 	}
141 	
142 	/***
143 	 * @see java.lang.Object#equals(java.lang.Object)
144 	 */
145 	@Override
146 	public boolean equals(Object obj) {
147 		if(!(obj instanceof Epg)) {
148 			return false;
149 		}
150 		Epg that = (Epg)obj;
151 		
152 		return this.type == that.type &&
153 		       this.programmeGroups.equals(that.programmeGroups) &&
154 		       this.programmes.equals(that.programmes) &&
155 		       this.schedule.equals(that.schedule);
156 	}
157 
158 	/***
159 	 * @see java.lang.Object#toString()
160 	 */
161 	public String toString() {
162 		return "EPG [type=" + type + "]: Programme Groups = " + programmeGroups + ", Programmes = " + programmes + ", schedule = [" + schedule + "]";
163 	}
164 }