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  /***
25   * one line to give the library's name and an idea of what it does.
26   * Copyright (C) year  name of author
27   * 
28   * This library is free software; you can redistribute it and/or
29   * modify it under the terms of the GNU Lesser General Public
30   * License as published by the Free Software Foundation; either
31   * version 2.1 of the License, or (at your option) any later version.
32   *
33   * This library is distributed in the hope that it will be useful,
34   * but WITHOUT ANY WARRANTY; without even the implied warranty of
35   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36   * Lesser General Public License for more details.
37   *
38   * You should have received a copy of the GNU Lesser General Public
39   * License along with this library; if not, write to the Free Software
40   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
41   */
42  
43  import java.util.regex.Pattern;
44  
45  /***
46   * 
47   *
48   */
49  public class Bearer {
50  
51  
52  	/***
53  	 * Bearer trigger validation pattern
54  	 */
55  	private final static Pattern triggerPattern = Pattern.compile("[0-9a-fA-F]{8}");
56  	
57  	/***
58  	 * DAB ID
59  	 */
60  	private ContentId id;
61  	
62  	/***
63  	 * Bearer Trigger
64  	 */
65  	private String trigger;
66  	
67  	/***
68  	 * Create a new bearer
69  	 * @param id Bearer ID
70  	 */
71  	public Bearer(ContentId id) {		
72  		this.id = id;
73  	}
74  	
75  	/***
76  	 * Create a new bearer with trigger
77  	 * @param id Bearer ID
78  	 * @param trigger Bearer Trigger
79  	 */
80  	public Bearer(ContentId id, String trigger) {
81  		
82  		if(trigger == null) {
83  			throw new IllegalArgumentException("A trigger must be specified");
84  		}
85  		
86  		// check arguments
87  		if(!triggerPattern.matcher(trigger).matches()) {
88  			throw new IllegalArgumentException("Bearer Trigger must match the following pattern: " + triggerPattern.pattern());
89  		}
90  		
91  		this.id = id;
92  		this.trigger = trigger;
93  	}
94  	
95  	/***
96  	 * @return Returns the bearer ID
97  	 */
98  	public ContentId getId() {
99  		return id;
100 	}
101 	
102 	/***
103 	 * @return Returns the bearer trigger
104 	 */
105 	public String getTrigger() {
106 		return trigger;
107 	}
108 	
109 }