tmf.core: Internalize timestamp types
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / internal / tmf / core / timestamp / TmfNanoTimestamp.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Modified from TmfSimpleTimestamp to use nanosecond scale
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.internal.tmf.core.timestamp;
15
16 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
17 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
18
19 /**
20 * A simplified timestamp where scale is nanoseconds and precision is set to 0.
21 */
22 public final class TmfNanoTimestamp extends TmfTimestamp {
23
24 private final long fValue;
25
26 // ------------------------------------------------------------------------
27 // Constructors
28 // ------------------------------------------------------------------------
29
30 /**
31 * Default constructor (value = 0)
32 */
33 public TmfNanoTimestamp() {
34 this(0);
35 }
36
37 /**
38 * Full constructor
39 *
40 * @param value
41 * the timestamp value
42 */
43 public TmfNanoTimestamp(final long value) {
44 fValue = value;
45 }
46
47 @Override
48 public long getValue() {
49 return fValue;
50 }
51
52
53 @Override
54 public int getScale() {
55 return ITmfTimestamp.NANOSECOND_SCALE;
56 }
57
58 /**
59 * @since 2.0
60 */
61 @Override
62 public long toNanos() {
63 return getValue();
64 }
65 }
This page took 0.048216 seconds and 5 git commands to generate.