ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / linuxtools / statesystem / core / interval / TmfStateInterval.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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.linuxtools.statesystem.core.interval;
14
15 import org.eclipse.linuxtools.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 * @since 3.0
24 */
25 public final class TmfStateInterval implements ITmfStateInterval {
26
27 private final long start;
28 private final long end;
29 private final int attribute;
30 private final ITmfStateValue sv;
31
32 /**
33 * Construct an interval from its given parameters
34 *
35 * @param start
36 * Start time
37 * @param end
38 * End time
39 * @param attribute
40 * Attribute linked to this interval
41 * @param sv
42 * State value this interval will contain
43 */
44 public TmfStateInterval(long start, long end, int attribute,
45 ITmfStateValue sv) {
46 this.start = start;
47 this.end = end;
48 this.attribute = attribute;
49 this.sv = sv;
50 }
51
52 @Override
53 public long getStartTime() {
54 return start;
55 }
56
57 @Override
58 public long getEndTime() {
59 return end;
60 }
61
62 @Override
63 public long getViewerEndTime() {
64 return end + 1;
65 }
66
67 @Override
68 public int getAttribute() {
69 return attribute;
70 }
71
72 @Override
73 public ITmfStateValue getStateValue() {
74 return sv;
75 }
76
77 @Override
78 public boolean intersects(long timestamp) {
79 if (start <= timestamp) {
80 if (end >= timestamp) {
81 return true;
82 }
83 }
84 return false;
85 }
86
87 @Override
88 public String toString() {
89 /* Only used for debugging */
90 StringBuffer buf = new StringBuffer(start + " to "); //$NON-NLS-1$
91 buf.append(end + ", "); //$NON-NLS-1$
92 buf.append(String.format("key = %4d, ", attribute)); //$NON-NLS-1$
93 buf.append("value = " + sv.toString()); //$NON-NLS-1$
94 return buf.toString();
95 }
96
97 }
This page took 0.081785 seconds and 5 git commands to generate.