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