BTree index on disk
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / timestamp / TmfTimestamp.java
index 7fbe99c6a9b1c5c5f9f3a5770ad90ae6ec7bb54f..e3a4ecca737c69eb7028b5ec86d9aff8b7185e17 100644 (file)
@@ -16,6 +16,8 @@
 
 package org.eclipse.linuxtools.tmf.core.timestamp;
 
+import java.nio.ByteBuffer;
+
 /**
  * A generic timestamp implementation. The timestamp is represented by the
  * tuple { value, scale, precision }. By default, timestamps are scaled in
@@ -157,6 +159,18 @@ public class TmfTimestamp implements ITmfTimestamp {
     // ITmfTimestamp
     // ------------------------------------------------------------------------
 
+    /**
+     * Construct the timestamp from the ByteBuffer.
+     *
+     * @param bufferIn
+     *            the buffer to read from
+     *
+     * @since 3.0
+     */
+    public TmfTimestamp(ByteBuffer bufferIn) {
+        this(bufferIn.getLong(), bufferIn.getInt(), bufferIn.getInt());
+    }
+
     @Override
     public long getValue() {
         return fValue;
@@ -356,4 +370,15 @@ public class TmfTimestamp implements ITmfTimestamp {
         }
     }
 
+    /**
+     * Write the time stamp to the ByteBuffer so that it can be saved to disk.
+     * @param bufferOut the buffer to write to
+     *
+     * @since 3.0
+     */
+    public void serialize(ByteBuffer bufferOut) {
+        bufferOut.putLong(fValue);
+        bufferOut.putInt(fScale);
+        bufferOut.putInt(fPrecision);
+    }
 }
This page took 0.024207 seconds and 5 git commands to generate.