lttng: Update Javadoc for the kernel event handler
[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>
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
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.
21 *
22
23 *
24 * @author alexmont
25 *
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
36 *
37 * @param start
38 * @param end
39 * @param attribute
40 * @param sv
41 */
42 public TmfStateInterval(long start, long end, int attribute,
43 ITmfStateValue sv) {
44 this.start = start;
45 this.end = end;
46 this.attribute = attribute;
47 this.sv = sv;
48 }
49
50 @Override
51 public long getStartTime() {
52 return start;
53 }
54
55 @Override
56 public long getEndTime() {
57 return end;
58 }
59
eaad89a0
AM
60 @Override
61 public long getViewerEndTime() {
62 return end + 1;
63 }
64
a52fde77
AM
65 @Override
66 public int getAttribute() {
67 return attribute;
68 }
69
70 @Override
71 public ITmfStateValue getStateValue() {
72 return sv;
73 }
74
75 @Override
76 public boolean intersects(long timestamp) {
77 if (start <= timestamp) {
78 if (end >= timestamp) {
79 return true;
80 }
81 }
82 return false;
83 }
84
85 @Override
86 public String toString() {
87 /* Only used for debugging */
88 StringBuffer buf = new StringBuffer(start + " to "); //$NON-NLS-1$
89 buf.append(end + ' ');
90 buf.append(String.format("key = %4d, ", attribute)); //$NON-NLS-1$
91 buf.append("value = " + sv.toString()); //$NON-NLS-1$
92 return buf.toString();
93 }
94
95}
This page took 0.033905 seconds and 5 git commands to generate.