1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.event
;
16 * <b><u>TmfTimeRange</u></b>
18 * A utility class to define time ranges.
20 public class TmfTimeRange
{
22 // ========================================================================
24 // ========================================================================
26 public static TmfTimeRange Eternity
= new TmfTimeRange(TmfTimestamp
.BigBang
, TmfTimestamp
.BigCrunch
);
28 // ========================================================================
30 // ========================================================================
32 private final TmfTimestamp fStartTime
;
33 private final TmfTimestamp fEndTime
;
35 // ========================================================================
37 // ========================================================================
42 @SuppressWarnings("unused")
43 private TmfTimeRange() {
52 public TmfTimeRange(TmfTimestamp startTime
, TmfTimestamp endTime
) {
53 fStartTime
= startTime
;
60 public TmfTimeRange(TmfTimeRange other
) {
61 assert(other
!= null);
62 fStartTime
= other
.fStartTime
;
63 fEndTime
= other
.fEndTime
;
67 public boolean equals(Object other
) {
68 if (other
instanceof TmfTimeRange
) {
69 TmfTimeRange range
= (TmfTimeRange
) other
;
70 return range
.fStartTime
.equals(fStartTime
) &&
71 range
.fEndTime
.equals(fEndTime
);
76 // ========================================================================
78 // ========================================================================
81 * @return The time range start time
83 public TmfTimestamp
getStartTime() {
88 * @return The time range end time
90 public TmfTimestamp
getEndTime() {
94 // ========================================================================
96 // ========================================================================
99 * Check if the timestamp is within the time range
104 public boolean contains(TmfTimestamp ts
) {
105 boolean result
= (fStartTime
.compareTo(ts
, true) <= 0) && (fEndTime
.compareTo(ts
, true) >= 0);
110 * @see java.lang.Object#toString()
113 public String
toString() {
114 return "[TmfTimeRange(" + fStartTime
.toString() + ":" + fEndTime
.toString() + ")]";
This page took 0.034125 seconds and 6 git commands to generate.