tmf: Correctly save the history backend's end time
[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
60 @Override
61 public int getAttribute() {
62 return attribute;
63 }
64
65 @Override
66 public ITmfStateValue getStateValue() {
67 return sv;
68 }
69
70 @Override
71 public boolean intersects(long timestamp) {
72 if (start <= timestamp) {
73 if (end >= timestamp) {
74 return true;
75 }
76 }
77 return false;
78 }
79
80 @Override
81 public String toString() {
82 /* Only used for debugging */
83 StringBuffer buf = new StringBuffer(start + " to "); //$NON-NLS-1$
84 buf.append(end + ' ');
85 buf.append(String.format("key = %4d, ", attribute)); //$NON-NLS-1$
86 buf.append("value = " + sv.toString()); //$NON-NLS-1$
87 return buf.toString();
88 }
89
90}
This page took 0.027851 seconds and 5 git commands to generate.