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 AttributeTag implements Encodable { 29 30 /*** 31 * Top level tags 32 */ 33 epgSystem(ElementTag.epg, 0x80), 34 35 programmeGroupsVersion(ElementTag.programmeGroups, 0x80), 36 programmeGroupsCreationTime(ElementTag.programmeGroups, 0x81), 37 programmeGroupsOriginator(ElementTag.programmeGroups, 0x82), 38 39 programmeGroupId(ElementTag.programmeGroup, 0x80), 40 programmeGroupShortId(ElementTag.programmeGroup, 0x81), 41 programmeGroupVersion(ElementTag.programmeGroup, 0x82), 42 programmeGroupType(ElementTag.programmeGroup, 0x83), 43 programmeGroupNumOfItems(ElementTag.programmeGroup, 0x84), 44 45 scheduleVersion(ElementTag.schedule, 0x80), 46 scheduleCreationTime(ElementTag.schedule, 0x81), 47 scheduleOriginator(ElementTag.schedule, 0x82), 48 49 scopeStartTime(ElementTag.scope, 0x80), 50 scopeStopTime(ElementTag.scope, 0x81), 51 52 serviceScopeId(ElementTag.serviceScope, 0x80), 53 54 alternateSourceProtocol(ElementTag.alternateSource, 0x80), 55 alternateSourceType(ElementTag.alternateSource, 0x81), 56 alternateSourceUrl(ElementTag.alternateSource, 0x82), 57 58 serviceInformationVersion(ElementTag.serviceInformation, 0x80), 59 serviceInformationCreationTime(ElementTag.serviceInformation, 0x81), 60 serviceInformationOriginator(ElementTag.serviceInformation, 0x82), 61 serviceInformationServiceProvider(ElementTag.serviceInformation, 0x83), 62 serviceInformationSystem(ElementTag.serviceInformation, 0x84), 63 64 ensembleId(ElementTag.ensemble, 0x80), 65 ensembleVersion(ElementTag.ensemble, 0x81), 66 67 frequencyType(ElementTag.frequency, 0x80), 68 frequencyKHz(ElementTag.frequency, 0x81), 69 70 serviceVersion(ElementTag.service, 0x80), 71 serviceFormat(ElementTag.service, 0x81), 72 serviceBitrate(ElementTag.service, 0x83), 73 74 simulcastSystem(ElementTag.simulcast, 0x80), 75 simulcastId(ElementTag.simulcast, 0x81), 76 77 serviceIdId(ElementTag.serviceID, 0x80), 78 serviceIdType(ElementTag.serviceID, 0x81), 79 80 CAType(ElementTag.CA, 0x80), 81 82 keywordsLang(ElementTag.keywords, 0x80), 83 84 multimediaMimeValue(ElementTag.multimedia, 0x80), 85 multimediaLan(ElementTag.multimedia, 0x81), 86 multimediaUrl(ElementTag.multimedia, 0x82), 87 multimediaType(ElementTag.multimedia, 0x83), 88 multimediaWidth(ElementTag.multimedia, 0x84), 89 multimediaHeight(ElementTag.multimedia, 0x85), 90 91 timeTime(ElementTag.time, 0x80), 92 timeDuration(ElementTag.time, 0x81), 93 timeActualTime(ElementTag.time, 0x82), 94 timeActualDuration(ElementTag.time, 0x83), 95 96 relativeTimeTime(ElementTag.relativeTime, 0x80), 97 relativeTimeDuration(ElementTag.relativeTime, 0x81), 98 relativeTimeActualTime(ElementTag.relativeTime, 0x82), 99 relativeTimeActualDuration(ElementTag.relativeTime, 0x83), 100 101 bearerId(ElementTag.bearer, 0x80), 102 bearerTrigger(ElementTag.bearer, 0x81), 103 104 memberOfId(ElementTag.memberOf, 0x80), 105 memberOfShortId(ElementTag.memberOf, 0x81), 106 memberOfIndex(ElementTag.memberOf, 0x82), 107 108 epgLanguageLang(ElementTag.epgLanguage, 0x80), 109 110 linkUrl(ElementTag.link, 0x80), 111 linkMimeValue(ElementTag.link, 0x81), 112 linkLang(ElementTag.link, 0x82), 113 linkDescription(ElementTag.link, 0x83), 114 linkExpiryTime(ElementTag.link, 0x84), 115 116 programmeId(ElementTag.programme, 0x80), 117 programmeShortId(ElementTag.programme, 0x81), 118 programmeVersion(ElementTag.programme, 0x82), 119 programmeRecommendation(ElementTag.programme, 0x83), 120 programmeBroadcast(ElementTag.programme, 0x84), 121 programmeLang(ElementTag.programme, 0x86), 122 programmeBitRate(ElementTag.programme, 0x87), 123 124 programmeEventId(ElementTag.programmeEvent, 0x80), 125 programmeEventShortId(ElementTag.programmeEvent, 0x81), 126 programmeEventVersion(ElementTag.programmeEvent, 0x82), 127 programmeEventRecommendation(ElementTag.programmeEvent, 0x83), 128 programmeEventBroadcast(ElementTag.programmeEvent, 0x84), 129 130 shortNameLang(ElementTag.shortName, 0x80), 131 132 mediumNameLang(ElementTag.mediumName, 0x80), 133 134 longNameLang(ElementTag.longName, 0x80), 135 136 shortDescriptionLang(ElementTag.shortDescription, 0x80), 137 138 longDescriptionLang(ElementTag.longDescription, 0x80), 139 140 genreHref(ElementTag.genre, 0x80), 141 genreType(ElementTag.genre, 0x81); 142 143 /*** 144 * Parent element tag - this is needed to be able 145 * to parse an attribute tag successfully. 146 */ 147 private ElementTag parent; 148 149 /*** 150 * Attribute tag value 151 */ 152 private byte value; 153 154 /*** 155 * 156 * @param value 157 */ 158 AttributeTag(ElementTag parent, int value) { 159 this.parent = parent; 160 this.value = (byte)value; 161 } 162 163 /*** 164 * @see com.gcapmedia.dab.epg.binary.Encodable#getBytes() 165 */ 166 public byte[] getBytes() { 167 BitBuilder bits = new BitBuilder(8); 168 bits.put(0, value); 169 return bits.toByteArray(); 170 } 171 172 /*** 173 * @return Returns the tags parent element tag 174 */ 175 public ElementTag getParent() { 176 return parent; 177 } 178 179 /*** 180 * @return Returns the tag value 181 */ 182 public int getValue() { 183 return value & 0xFF; 184 } 185 186 /*** 187 * @see com.gcapmedia.dab.epg.binary.Encodable#getLength() 188 */ 189 public int getLength() { 190 return 1; 191 } 192 193 /*** 194 * Parse an object from its byte array representation 195 * @param parent Tag parent 196 * @param bytes Byte array representation 197 */ 198 public static AttributeTag fromBytes(ElementTag parent, byte[] bytes) { 199 BitParser parser = new BitParser(bytes); 200 int value = parser.getInt(0, 8); 201 AttributeTag result = null; 202 for(AttributeTag tag : values()) { 203 if(tag.parent == parent && tag.getValue() == value) { 204 result = tag; 205 break; 206 } 207 } 208 if(result == null) { 209 throw new IllegalArgumentException("Tag not found for value: 0x" + Integer.toHexString(value) + " from parent: " + parent); 210 } 211 return result; 212 } 213 214 }