statesystem: Remove ITmfStateInterval.getViewerEndTime
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / statesystem / core / interval / TmfStateInterval.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5 *
6 * All rights reserved. This program and the accompanying materials are
7 * made available under the terms of the Eclipse Public License v1.0 which
8 * accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.statesystem.core.interval;
14
15 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
16
17 /**
18 * The StateInterval represents the "state" a particular attribute was in, at a
19 * given time. It is the main object being returned from queries to the state
20 * system.
21 *
22 * @author Alexandre Montplaisir
23 */
24 public final class TmfStateInterval implements ITmfStateInterval {
25
26 private final long start;
27 private final long end;
28 private final int attribute;
29 private final ITmfStateValue sv;
30
31 /**
32 * Construct an interval from its given parameters
33 *
34 * @param start
35 * Start time
36 * @param end
37 * End time
38 * @param attribute
39 * Attribute linked to this interval
40 * @param sv
41 * State value this interval will contain
42 */
43 public TmfStateInterval(long start, long end, int attribute,
44 ITmfStateValue sv) {
45 this.start = start;
46 this.end = end;
47 this.attribute = attribute;
48 this.sv = sv;
49 }
50
51 @Override
52 public long getStartTime() {
53 return start;
54 }
55
56 @Override
57 public long getEndTime() {
58 return end;
59 }
60
61 @Override
62 public int getAttribute() {
63 return attribute;
64 }
65
66 @Override
67 public ITmfStateValue getStateValue() {
68 return sv;
69 }
70
71 @Override
72 public boolean intersects(long timestamp) {
73 if (start <= timestamp) {
74 if (end >= timestamp) {
75 return true;
76 }
77 }
78 return false;
79 }
80
81 @Override
82 public String toString() {
83 /* Only used for debugging */
84 StringBuffer buf = new StringBuffer(start + " to "); //$NON-NLS-1$
85 buf.append(end + ", "); //$NON-NLS-1$
86 buf.append(String.format("key = %4d, ", attribute)); //$NON-NLS-1$
87 buf.append("value = " + sv.toString()); //$NON-NLS-1$
88 return buf.toString();
89 }
90
91 }
This page took 0.039746 seconds and 5 git commands to generate.