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 org.joda.time.DateTime; 25 import org.joda.time.Duration; 26 import org.joda.time.Period; 27 import org.joda.time.ReadableInstant; 28 29 /*** 30 * <p>Describes the timing information of a programme, both billed and actual 31 * relative to its parent</p> 32 */ 33 public class RelativeTime { 34 35 /*** 36 * Billed programme start time relative to the billed 37 * start time of the parent 38 */ 39 private Duration billedTime; 40 41 /*** 42 * Billed programme duration 43 */ 44 private Duration billedDuration; 45 46 /*** 47 * Actual programme start time relative to the actual 48 * start time of the parent 49 */ 50 private Duration actualTime; 51 52 /*** 53 * Actual programme duration 54 */ 55 private Duration actualDuration; 56 57 /*** 58 * Create a new relative programme time 59 * @param billedTime Billed programme time relative to its parent 60 * @param billedDuration Billed programme duration 61 */ 62 public RelativeTime(Duration billedTime, Duration billedDuration) { 63 this.billedTime = billedTime; 64 this.billedDuration = billedDuration; 65 } 66 67 /*** 68 * Create a new relative programme time 69 * @param billedTime Billed programme time relative to its parent 70 * @param billedDuration Billed programme duration 71 */ 72 public RelativeTime(ReadableInstant parent, Period timePeriod, Period billedPeriod) { 73 this.billedTime = timePeriod.toDurationFrom(parent); 74 this.billedDuration = billedPeriod.toDurationFrom(new DateTime(parent).plus(billedTime)); 75 } 76 77 /*** 78 * Create a new programme time 79 * @param billedTime Billed programme time relative to its parent 80 * @param billedDuration Billed programme duration 81 * @param actualTime Actual start time of the programme relative to its parent 82 * @param actualDuration Actual duration of the programme 83 */ 84 public RelativeTime(Duration billedTime, Duration billedDuration, Duration actualTime, Duration actualDuration) { 85 this.billedTime = billedTime; 86 this.billedDuration = billedDuration; 87 this.actualTime = actualTime; 88 this.actualDuration = actualDuration; 89 } 90 91 /*** 92 * @return Returns the actual duration of the programme 93 */ 94 public Duration getActualDuration() { 95 return actualDuration; 96 } 97 98 /*** 99 * @param actualDuration Sets the actual duration of the programme 100 */ 101 public void setActualDuration(Duration actualDuration) { 102 this.actualDuration = actualDuration; 103 } 104 105 /*** 106 * @return Returns the actual start time of the programme relative 107 * to its parent 108 */ 109 public Duration getActualTime() { 110 return actualTime; 111 } 112 113 /*** 114 * @param actualTime Sets the actual start time of the programme 115 * relative to its parent 116 */ 117 public void setActualTime(Duration actualTime) { 118 this.actualTime = actualTime; 119 } 120 121 /*** 122 * @return Returns the billed duration of the programme 123 */ 124 public Duration getBilledDuration() { 125 return billedDuration; 126 } 127 128 /*** 129 * @return Returns the billed start time of the programme 130 * relative to its parent 131 */ 132 public Duration getBilledTime() { 133 return billedTime; 134 } 135 136 }