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.binary;
23  
24  
25  /***
26   * List all defined tag types as per ETSI TS 101 371 V1.2.1 (2006-02)
27   */
28  public enum ElementTag implements Encodable {
29  
30  	/***
31  	 * Top level tags
32  	 */
33  	epg(0x02),
34  	serviceInformation(0x03),
35  	
36  	/***
37  	 * Subtags
38  	 */
39  	tokenTableElement(0x04),
40  	defaultContentIdElement(0x05),
41  	shortName(0x10),
42  	mediumName(0x11),
43  	longName(0x12),
44  	mediaDescription(0x13),
45  	genre(0x14),
46  	CA(0x15),
47  	keywords(0x16),
48  	memberOf(0x17),
49  	link(0x18),
50  	location(0x19),
51  	shortDescription(0x1A),
52  	longDescription(0x1B),
53  	programme(0x1C),
54  	programmeGroups(0x20),
55  	schedule(0x21),
56  	alternateSource(0x22),
57  	programmeGroup(0x23),
58  	scope(0x24),
59  	serviceScope(0x25),
60  	ensemble(0x26),
61  	frequency(0x27),
62  	service(0x28),
63  	serviceID(0x29),
64  	epgLanguage(0x2A),
65  	multimedia(0x2B),
66  	time(0x2C),
67  	bearer(0x2D),
68  	programmeEvent(0x2E),
69  	relativeTime(0x2F),
70  	simulcast(0x30);
71  	
72  	/***
73  	 * 
74  	 */
75  	private byte value;
76  	
77  	/***
78  	 * 
79  	 * @param value
80  	 */
81  	ElementTag(int value) {
82  		this.value = (byte)value;
83  	}
84  	
85  	/***
86  	 * @see com.gcapmedia.dab.epg.binary.Encodable#getBytes()
87  	 */
88  	public byte[] getBytes() {
89  		byte[] bytes = new byte[1];
90  		bytes[0] = value;
91  		return bytes;
92  	}
93  
94  	/***
95  	 * @see com.gcapmedia.dab.epg.binary.Encodable#getLength()
96  	 */
97  	public int getLength() {
98  		return 1;
99  	}
100 	
101 	/***
102 	 * Parse an object from its byte array representation
103 	 * @param parent Tag parent
104 	 * @param bytes Byte array representation
105 	 */
106 	public static ElementTag fromBytes(byte[] bytes) {
107 		BitParser parser = new BitParser(bytes);
108 		int value = parser.getInt(0, 8);
109 		ElementTag result = null;
110 		for(ElementTag tag : values()) {
111 			if(tag.value  == value) {
112 				result = tag;
113 				break;
114 			}
115 		}
116 		return result;
117 	}
118 }