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
CommitLineData
a52fde77
AM
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>
5df842b3 5 *
a52fde77
AM
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
5df842b3 10 *
a52fde77
AM
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.core.interval;
14
15import 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.
5df842b3 21 *
a52fde77 22
5df842b3 23 *
a52fde77 24 * @author alexmont
5df842b3 25 *
a52fde77
AM
26 */
27public 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
5df842b3 36 *
a52fde77 37 * @param start
5df842b3 38 * Start time
a52fde77 39 * @param end
5df842b3 40 * End time
a52fde77 41 * @param attribute
5df842b3 42 * Attribute linked to this interval
a52fde77 43 * @param sv
5df842b3 44 * State value this interval will contain
a52fde77
AM
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
eaad89a0
AM
64 @Override
65 public long getViewerEndTime() {
66 return end + 1;
67 }
68
a52fde77
AM
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.031322 seconds and 5 git commands to generate.