To fix .... error about Override automatically added by Eclipse
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfTimeRange.java
CommitLineData
8c8bf09f
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.event;
14
15/**
951d134a 16 * <b><u>TmfTimeRange</u></b>
8c8bf09f
ASL
17 * <p>
18 * A utility class to define time ranges.
19 */
20public class TmfTimeRange {
21
62d1696a
FC
22 // ========================================================================
23 // Constants
24 // ========================================================================
25
26 public static TmfTimeRange Eternity = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
27
1f506a43 28 // ========================================================================
8c8bf09f 29 // Attributes
1f506a43 30 // ========================================================================
8c8bf09f
ASL
31
32 private final TmfTimestamp fStartTime;
33 private final TmfTimestamp fEndTime;
34
1f506a43 35 // ========================================================================
8c8bf09f 36 // Constructors
1f506a43 37 // ========================================================================
8c8bf09f 38
28b94d61
FC
39 /**
40 *
41 */
42 @SuppressWarnings("unused")
43 private TmfTimeRange() {
44 fStartTime = null;
45 fEndTime = null;
46 }
47
8c8bf09f
ASL
48 /**
49 * @param startTime
50 * @param endTime
51 */
52 public TmfTimeRange(TmfTimestamp startTime, TmfTimestamp endTime) {
1f506a43
FC
53 fStartTime = startTime;
54 fEndTime = endTime;
8c8bf09f 55 }
28b94d61
FC
56
57 /**
58 * @param other
59 */
60 public TmfTimeRange(TmfTimeRange other) {
61 assert(other != null);
62 fStartTime = other.fStartTime;
63 fEndTime = other.fEndTime;
64 }
8c8bf09f 65
951d134a
FC
66 @Override
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);
72 }
73 return false;
74 }
75
1f506a43 76 // ========================================================================
8c8bf09f 77 // Accessors
1f506a43 78 // ========================================================================
8c8bf09f
ASL
79
80 /**
81 * @return The time range start time
82 */
83 public TmfTimestamp getStartTime() {
1f506a43 84 return fStartTime;
8c8bf09f
ASL
85 }
86
87 /**
88 * @return The time range end time
89 */
90 public TmfTimestamp getEndTime() {
1f506a43 91 return fEndTime;
8c8bf09f
ASL
92 }
93
1f506a43 94 // ========================================================================
8c8bf09f 95 // Predicates
1f506a43 96 // ========================================================================
8c8bf09f
ASL
97
98 /**
99 * Check if the timestamp is within the time range
100 *
101 * @param ts
102 * @return
103 */
104 public boolean contains(TmfTimestamp ts) {
1f506a43
FC
105 boolean result = (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
106 return result;
8c8bf09f
ASL
107 }
108
8d2e2848
FC
109 /* (non-Javadoc)
110 * @see java.lang.Object#toString()
111 */
112 @Override
113 public String toString() {
28b94d61 114 return "[TmfTimeRange(" + fStartTime.toString() + ":" + fEndTime.toString() + ")]";
8d2e2848
FC
115 }
116
8c8bf09f 117}
This page took 0.030345 seconds and 5 git commands to generate.