549ba3d858ec40c612b22d537c54e1d463c459d0
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfTimeRange.java
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
13 package org.eclipse.linuxtools.tmf.event;
14
15 /**
16 * <b><u>TmfTimeWindow</u></b>
17 * <p>
18 * A utility class to define time ranges.
19 */
20 public class TmfTimeRange {
21
22 // ========================================================================
23 // Attributes
24 // ========================================================================
25
26 private final TmfTimestamp fStartTime;
27 private final TmfTimestamp fEndTime;
28
29 // ========================================================================
30 // Constructors
31 // ========================================================================
32
33 /**
34 * @param startTime
35 * @param endTime
36 */
37 public TmfTimeRange(TmfTimestamp startTime, TmfTimestamp endTime) {
38 fStartTime = startTime;
39 fEndTime = endTime;
40 }
41
42 // ========================================================================
43 // Accessors
44 // ========================================================================
45
46 /**
47 * @return The time range start time
48 */
49 public TmfTimestamp getStartTime() {
50 return fStartTime;
51 }
52
53 /**
54 * @return The time range end time
55 */
56 public TmfTimestamp getEndTime() {
57 return fEndTime;
58 }
59
60 // ========================================================================
61 // Predicates
62 // ========================================================================
63
64 /**
65 * Check if the timestamp is within the time range
66 *
67 * @param ts
68 * @return
69 */
70 public boolean contains(TmfTimestamp ts) {
71 boolean result = (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
72 return result;
73 }
74
75 }
This page took 0.032106 seconds and 4 git commands to generate.