tmf: Bug 476129: NullPointerException in GenerateTestValues.java
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / timestamp / ITmfTimestamp.java
CommitLineData
5179fc01 1/*******************************************************************************
065cc19b 2 * Copyright (c) 2012, 2014 Ericsson
f8177ba2 3 *
5179fc01
FC
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
f8177ba2 8 *
5179fc01
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
065cc19b 11 * Alexandre Montplaisir - Removed concept of precision
5179fc01
FC
12 *******************************************************************************/
13
2bdf0193 14package org.eclipse.tracecompass.tmf.core.timestamp;
3bd46eef 15
5dca27ae 16import org.eclipse.jdt.annotation.NonNull;
2bdf0193 17import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
5179fc01
FC
18
19/**
7636a88e 20 * The fundamental time reference in the TMF.
21 * <p>
22 * It defines a generic timestamp interface in its most basic form:
23 * <ul>
24 * <li>timestamp = [value] * 10**[scale] +/- [precision]
25 * </ul>
26 * Where:
27 * <ul>
28 * <li>[value] is an unstructured integer value
29 * <li>[scale] is the magnitude of the value wrt some application-specific
30 * base unit (e.g. the second)
31 * <li>[precision] indicates the error on the value (useful for comparing
32 * timestamps in different scales). Default: 0.
33 * </ul>
f8177ba2 34 *
d337369a 35 * @author Francois Chouinard
f8177ba2 36 *
f7703ed6 37 * @see ITmfEvent
d337369a 38 * @see TmfTimeRange
5179fc01 39 */
0316808c 40public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
5179fc01 41
f8177ba2
FC
42 // ------------------------------------------------------------------------
43 // Constants
44 // ------------------------------------------------------------------------
45
46 /**
47 * The millisecond scale factor (10e0)
f8177ba2 48 */
304712fe 49 int SECOND_SCALE = 0;
f8177ba2
FC
50
51 /**
52 * The millisecond scale factor (10e-3)
f8177ba2 53 */
304712fe 54 int MILLISECOND_SCALE = -3;
f8177ba2
FC
55
56 /**
57 * The microsecond scale factor (10e-6)
f8177ba2 58 */
304712fe 59 int MICROSECOND_SCALE = -6;
f8177ba2
FC
60
61 /**
62 * The nanosecond scale factor (10e-9)
f8177ba2 63 */
304712fe 64 int NANOSECOND_SCALE = -9;
f8177ba2 65
a4115405
FC
66 // ------------------------------------------------------------------------
67 // Getters
68 // ------------------------------------------------------------------------
69
5179fc01
FC
70 /**
71 * @return the timestamp value (magnitude)
72 */
57a2a5ca 73 long getValue();
5179fc01
FC
74
75 /**
76 * @return the timestamp scale (exponent)
77 */
57a2a5ca 78 int getScale();
5179fc01 79
a4115405
FC
80 // ------------------------------------------------------------------------
81 // Operations
82 // ------------------------------------------------------------------------
83
5179fc01 84 /**
f8177ba2
FC
85 * Normalize (adjust scale and offset) of the timestamp
86 *
5179fc01
FC
87 * @param offset the offset to apply to the timestamp value (after scaling)
88 * @param scale the new timestamp scale
89 * @return a new 'adjusted' ITmfTimestamp
90 */
5dca27ae 91 @NonNull ITmfTimestamp normalize(long offset, int scale);
5179fc01 92
5179fc01 93 /**
085d898f 94 * Returns the difference between [this] and [ts] as a timestamp
f8177ba2 95 *
5179fc01
FC
96 * @param ts the other timestamp
97 * @return the time difference (this - other) as an ITmfTimestamp
98 */
6cfc180e 99 @NonNull ITmfTimestamp getDelta(ITmfTimestamp ts);
5179fc01 100
1de55ea2
AM
101 /**
102 * Returns if this timestamp intersects the given time range. Borders are
103 * inclusive (for more fine-grained behavior, you can use
104 * {@link #compareTo(ITmfTimestamp)}.
105 *
106 * @param range
107 * The time range to compare to
108 * @return True if this timestamp is part of the time range, false if not
109 */
57a2a5ca 110 boolean intersects(TmfTimeRange range);
1de55ea2 111
a4115405
FC
112 // ------------------------------------------------------------------------
113 // Comparable
114 // ------------------------------------------------------------------------
115
d7dbf09a 116 @Override
b9e37ffd 117 int compareTo(ITmfTimestamp ts);
4df4581d 118
f8177ba2
FC
119 /**
120 * Format the timestamp as per the format provided
121 *
122 * @param format the timestamp formatter
123 * @return the formatted timestamp
f8177ba2 124 */
57a2a5ca 125 String toString(final TmfTimestampFormat format);
f8177ba2 126
5179fc01 127}
This page took 0.079328 seconds and 5 git commands to generate.