tmf.core: simplify timestamp implementations
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / 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.tmf.core.timestamp;
15
16 /**
17 * A simplified timestamp where scale is nanoseconds and precision is set to 0.
18 */
19 public final class TmfNanoTimestamp extends TmfTimestamp {
20
21 private final long fValue;
22
23 // ------------------------------------------------------------------------
24 // Constructors
25 // ------------------------------------------------------------------------
26
27 /**
28 * Default constructor (value = 0)
29 */
30 public TmfNanoTimestamp() {
31 this(0);
32 }
33
34 /**
35 * Full constructor
36 *
37 * @param value
38 * the timestamp value
39 */
40 public TmfNanoTimestamp(final long value) {
41 fValue = value;
42 }
43
44 @Override
45 public long getValue() {
46 return fValue;
47 }
48
49
50 @Override
51 public int getScale() {
52 return ITmfTimestamp.NANOSECOND_SCALE;
53 }
54
55 /**
56 * @since 2.0
57 */
58 @Override
59 public long toNanos() {
60 return getValue();
61 }
62 }
This page took 0.038881 seconds and 5 git commands to generate.