datastore: Make the serialization package public
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 10 May 2017 14:37:04 +0000 (10:37 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 12 May 2017 17:59:55 +0000 (13:59 -0400)
Change-Id: Iddfdc46fa84448aefda0e8da0e1d9fe107a8d97b
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/96745
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
21 files changed:
statesystem/org.eclipse.tracecompass.datastore.core.tests/src/org/eclipse/tracecompass/internal/datastore/core/serialization/SafeByteBufferWrapperTest.java
statesystem/org.eclipse.tracecompass.datastore.core/META-INF/MANIFEST.MF
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/interval/HTInterval.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/interval/IHTInterval.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/interval/IHTIntervalReader.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/interval/ISerializableObject.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferReader.java [new file with mode: 0644]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferWriter.java [new file with mode: 0644]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/SafeByteBufferFactory.java [new file with mode: 0644]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/package-info.java [new file with mode: 0644]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/datastore/core/serialization/SafeByteBufferWrapper.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/historytree/HTNode.java
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferReader.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferWriter.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/SafeByteBufferFactory.java [deleted file]
statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/package-info.java [deleted file]
statesystem/org.eclipse.tracecompass.segmentstore.core.tests/src/org/eclipse/tracecompass/segmentstore/core/tests/AbstractTestSegmentStore.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/statevalue/CustomStateValueTest.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/stubs/org/eclipse/tracecompass/statesystem/core/tests/stubs/statevalues/CustomStateValueStub.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/provisional/statesystem/core/statevalue/CustomStateValue.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTInterval.java

index 80df618b2282455d0ed314ac7b38bb491d5aebcb..5882dd5083121cb45e30842f0cccf502140d8ba3 100644 (file)
@@ -16,9 +16,9 @@ import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.junit.Test;
 
 /**
index 3a8aacbfe68f91580d9d56a9793344508eb218eb..8a9f5789214ee349d39531f8a4bf9823f4fda08d 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.1.0.qualifier
 Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.tracecompass.datastore.core;singleton:=true
 Bundle-Activator: org.eclipse.tracecompass.internal.datastore.core.Activator
@@ -12,6 +12,7 @@ Eclipse-ExtensibleAPI: true
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.common.core
 Export-Package: org.eclipse.tracecompass.datastore.core.interval,
+ org.eclipse.tracecompass.datastore.core.serialization,
  org.eclipse.tracecompass.internal.datastore.core;x-internal:=true,
  org.eclipse.tracecompass.internal.datastore.core.condition;x-internal:=true,
  org.eclipse.tracecompass.internal.datastore.core.historytree;x-internal:=true,
@@ -20,12 +21,7 @@ Export-Package: org.eclipse.tracecompass.datastore.core.interval,
  org.eclipse.tracecompass.internal.provisional.datastore.core.exceptions,
  org.eclipse.tracecompass.internal.provisional.datastore.core.historytree;x-friends:="org.eclipse.tracecompass.segmentstore.core,org.eclipse.tracecompass.segmentstore.core.tests",
  org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.classic;x-friends:="org.eclipse.tracecompass.statesystem.core,org.eclipse.tracecompass.statesystem.core.tests",
- org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.overlapping;x-friends:="org.eclipse.tracecompass.segmentstore.core,org.eclipse.tracecompass.segmentstore.core.tests",
- org.eclipse.tracecompass.internal.provisional.datastore.core.serialization;
-  x-friends:="org.eclipse.tracecompass.statesystem.core,
-   org.eclipse.tracecompass.statesystem.core.tests,
-   org.eclipse.tracecompass.segmentstore.core,
-   org.eclipse.tracecompass.segmentstore.core.tests"
+ org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.overlapping;x-friends:="org.eclipse.tracecompass.segmentstore.core,org.eclipse.tracecompass.segmentstore.core.tests"
 Import-Package: com.google.common.annotations,
  com.google.common.base,
  com.google.common.cache,
index 29b0867ef9adb42e1ad8193858990cf1a19735dd..f00f01e3801c2972ed19b6da8ecd18abc1755e8f 100644 (file)
@@ -14,12 +14,13 @@ import java.util.StringJoiner;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
 
 /**
  * Basic implementation of {@link IHTInterval}.
  *
  * @author Geneviève Bastien
+ * @since 1.1
  */
 public class HTInterval implements IHTInterval {
 
index ee33a8d20028b178c6ee573dbac4257292ea22d2..19a69ef589647e9d7e98acfd0b5923d9468398c5 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.datastore.core.interval;
  *
  * @author Alexandre Montplaisir
  * @author Geneviève Bastien
+ * @since 1.1
  */
 public interface IHTInterval extends ISerializableObject {
 
index bb12060330d32791a3e36e512f2eeefe6928d2e7..a0f4f64947f8d8556888aad0a4f7281f69997a60 100644 (file)
@@ -9,7 +9,7 @@
 
 package org.eclipse.tracecompass.datastore.core.interval;
 
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
 
 /**
  * A factory that reads object from a byte buffer and create a new object
@@ -17,6 +17,7 @@ import org.eclipse.tracecompass.internal.provisional.datastore.core.serializatio
  * @author Geneviève Bastien
  * @param <E>
  *            The type of objects that will be read
+ * @since 1.1
  */
 @FunctionalInterface
 public interface IHTIntervalReader<E extends IHTInterval> {
index b55ec996ee0d70be09dda7806d246814cdf425b9..95e8392c3ac903c4f4d74c47b18550075515b100 100644 (file)
@@ -9,12 +9,13 @@
 
 package org.eclipse.tracecompass.datastore.core.interval;
 
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
 
 /**
  * An object that can be serialized
  *
  * @author Geneviève Bastien
+ * @since 1.1
  */
 public interface ISerializableObject {
 
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferReader.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferReader.java
new file mode 100644 (file)
index 0000000..50a2c17
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.datastore.core.serialization;
+
+/**
+ * Interface for a safe ByteBuffer for reading purposes. This interface allows
+ * only to read data from a buffer, no other operation is allowed on it. The
+ * implementations must make sure that only the allowed data can be read.
+ *
+ * @author Geneviève Bastien
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 1.1
+ */
+public interface ISafeByteBufferReader {
+
+    /**
+     * Reads a byte at the buffer's current position
+     *
+     * @return The byte read
+     */
+    byte get();
+
+    /**
+     * Transfers bytes from this buffer's current position into the destination
+     * array
+     *
+     * @param dst
+     *            The destination array
+     */
+    void get(byte[] dst);
+
+    /**
+     * Reads the char at the buffer's current position
+     *
+     * @return The char read
+     */
+    char getChar();
+
+    /**
+     * Reads the double at the buffer's current position
+     *
+     * @return The double read
+     */
+    double getDouble();
+
+    /**
+     * Reads the float at the buffer's current position
+     *
+     * @return The float read
+     */
+    float getFloat();
+
+    /**
+     * Reads the int at the buffer's current position
+     *
+     * @return The int read
+     */
+    int getInt();
+
+    /**
+     * Reads the long at the buffer's current position
+     *
+     * @return The long read
+     */
+    long getLong();
+
+    /**
+     * Reads the short at the buffer's current position
+     *
+     * @return The short read
+     */
+    short getShort();
+
+    /**
+     * Gets a string from the byte buffer.
+     *
+     * @return The string value read
+     */
+    String getString();
+
+}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferWriter.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/ISafeByteBufferWriter.java
new file mode 100644 (file)
index 0000000..6e82956
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.datastore.core.serialization;
+
+/**
+ * Interface for a safe ByteBuffer for writing purposes. This interface allows
+ * only to write data from a buffer, no other operation is allowed on it. The
+ * implementation needs to make sure that the buffer does not write over the
+ * limits of the buffer.
+ *
+ * @author Geneviève Bastien
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 1.1
+ */
+public interface ISafeByteBufferWriter {
+
+    /**
+     * Writes a byte at the buffer's current position
+     *
+     * @param value
+     *            The byte to write
+     */
+    void put(byte value);
+
+    /**
+     * Transfers the bytes from the src array in the buffer at the current
+     * position
+     *
+     * @param src
+     *            the byte array to write
+     */
+    void put(byte[] src);
+
+    /**
+     * Writes a char at the buffer's current position
+     *
+     * @param value
+     *            The char to write
+     */
+    void putChar(char value);
+
+    /**
+     * Writes a double at the buffer's current position
+     *
+     * @param value
+     *            The double to write
+     */
+    void putDouble(double value);
+
+    /**
+     * Writes a float at the buffer's current position
+     *
+     * @param value
+     *            The float to write
+     */
+    void putFloat(float value);
+
+    /**
+     * Writes an int at the buffer's current position
+     *
+     * @param value
+     *            The int to write
+     */
+    void putInt(int value);
+
+    /**
+     * Writes a long at the buffer's current position
+     *
+     * @param value
+     *            The long to write
+     */
+    void putLong(long value);
+
+    /**
+     * Writes a short at the buffer's current position
+     *
+     * @param value
+     *            The short to write
+     */
+    void putShort(short value);
+
+    /**
+     * Writes a string value in the byte buffer. The implementation can decide
+     * what format it will use. They can also have a maximum size, in which case
+     * string should be truncated if they are larger than that.
+     *
+     * @param value
+     *            The String value to write to the buffer
+     */
+    void putString(String value);
+
+}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/SafeByteBufferFactory.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/SafeByteBufferFactory.java
new file mode 100644 (file)
index 0000000..2714d23
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.datastore.core.serialization;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.tracecompass.internal.datastore.core.serialization.SafeByteBufferWrapper;
+
+/**
+ * Class that creates instances of safe byte buffers wrappers from a part of a
+ * ByteBuffer instance
+ *
+ * @author Geneviève Bastien
+ * @since 1.1
+ */
+public final class SafeByteBufferFactory {
+
+    private SafeByteBufferFactory() {
+
+    }
+
+    /**
+     * Creates a new safe byte buffer reader from the ByteBuffer's current
+     * position with a size limited to 'size'.
+     *
+     * @param buffer
+     *            The big ByteBuffer to safely wrap for reading
+     * @param size
+     *            The size of the new sub-buffer
+     * @return The safe byte buffer reader instance
+     */
+    public static ISafeByteBufferReader wrapReader(ByteBuffer buffer, int size) {
+        int pos = buffer.position();
+        // Slice the main buffer, so that position 0 is the current position
+        // set it as read-only also
+        ByteBuffer readOnlyBuffer = buffer.slice().asReadOnlyBuffer();
+        readOnlyBuffer.order(buffer.order());
+        // Set its limit to the request limit
+        readOnlyBuffer.limit(size);
+        // Operations on fBuffer will not affect the main buffer's position, so
+        // we set its position to after the limit
+        buffer.position(pos + size);
+        return new SafeByteBufferWrapper(readOnlyBuffer);
+    }
+
+    /**
+     * Creates a new safe byte buffer writer from the ByteBuffer's current
+     * position with a size limited to 'size'.
+     *
+     * @param buffer
+     *            The big ByteBuffer to safely wrap for reading
+     * @param size
+     *            The size of the new sub-buffer
+     * @return The safe byte buffer writer instance
+     */
+    public static ISafeByteBufferWriter wrapWriter(ByteBuffer buffer, int size) {
+        int pos = buffer.position();
+        // Slice the main buffer, so that position 0 is the current position
+        ByteBuffer readWriteBuffer = buffer.slice();
+        readWriteBuffer.order(buffer.order());
+        // Set its limit to the request limit
+        readWriteBuffer.limit(size);
+        // Operations on fBuffer will not affect the main buffer's position, so
+        // we set its position to after the limit
+        buffer.position(pos + size);
+        return new SafeByteBufferWrapper(readWriteBuffer);
+    }
+
+    /**
+     * Get the serialized of a string object if it uses the
+     * {@link ISafeByteBufferWriter#putString(String)} method
+     *
+     * @param string
+     *            The string to write to the buffer
+     * @return The size of the string serialized by the
+     *         {@link ISafeByteBufferWriter#putString(String)} method, or -1 if
+     *         the string cannot be serialized
+     */
+    public static int getStringSizeInBuffer(String string) {
+        return SafeByteBufferWrapper.getStringSizeInBuffer(string);
+    }
+
+}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/package-info.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/datastore/core/serialization/package-info.java
new file mode 100644 (file)
index 0000000..8497b24
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.datastore.core.serialization;
index 1e21b19388cdf8a8346e2c0f42fff757167dddae..ab292442d1c808a0323eb235df88ec55203d82e6 100644 (file)
@@ -11,8 +11,8 @@ package org.eclipse.tracecompass.internal.datastore.core.serialization;
 
 import java.nio.ByteBuffer;
 
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
 
 /**
  * This class is a wrapper around a ByteBuffer. The size to read/write to the
index b56964c45e4d2fdeb8dd9478b97739449211bbcb..f79f61065b3e288e445002cab08960218a206dfb 100644 (file)
@@ -28,11 +28,11 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.datastore.core.interval.IHTInterval;
 import org.eclipse.tracecompass.datastore.core.interval.IHTIntervalReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.eclipse.tracecompass.internal.provisional.datastore.core.condition.TimeRangeCondition;
 import org.eclipse.tracecompass.internal.provisional.datastore.core.exceptions.RangeException;
 import org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.AbstractHistoryTree.IHTNodeFactory;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferReader.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferReader.java
deleted file mode 100644 (file)
index 26649b1..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.provisional.datastore.core.serialization;
-
-/**
- * Interface for a safe ByteBuffer for reading purposes. This interface allows
- * only to read data from a buffer, no other operation is allowed on it. The
- * implementations must make sure that only the allowed data can be read.
- *
- * @author Geneviève Bastien
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ISafeByteBufferReader {
-
-    /**
-     * Reads a byte at the buffer's current position
-     *
-     * @return The byte read
-     */
-    byte get();
-
-    /**
-     * Transfers bytes from this buffer's current position into the destination
-     * array
-     *
-     * @param dst
-     *            The destination array
-     */
-    void get(byte[] dst);
-
-    /**
-     * Reads the char at the buffer's current position
-     *
-     * @return The char read
-     */
-    char getChar();
-
-    /**
-     * Reads the double at the buffer's current position
-     *
-     * @return The double read
-     */
-    double getDouble();
-
-    /**
-     * Reads the float at the buffer's current position
-     *
-     * @return The float read
-     */
-    float getFloat();
-
-    /**
-     * Reads the int at the buffer's current position
-     *
-     * @return The int read
-     */
-    int getInt();
-
-    /**
-     * Reads the long at the buffer's current position
-     *
-     * @return The long read
-     */
-    long getLong();
-
-    /**
-     * Reads the short at the buffer's current position
-     *
-     * @return The short read
-     */
-    short getShort();
-
-    /**
-     * Gets a string from the byte buffer.
-     *
-     * @return The string value read
-     */
-    String getString();
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferWriter.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/ISafeByteBufferWriter.java
deleted file mode 100644 (file)
index e49c77a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.provisional.datastore.core.serialization;
-
-/**
- * Interface for a safe ByteBuffer for writing purposes. This interface allows
- * only to write data from a buffer, no other operation is allowed on it. The
- * implementation needs to make sure that the buffer does not write over the
- * limits of the buffer.
- *
- * @author Geneviève Bastien
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ISafeByteBufferWriter {
-
-    /**
-     * Writes a byte at the buffer's current position
-     *
-     * @param value
-     *            The byte to write
-     */
-    void put(byte value);
-
-    /**
-     * Transfers the bytes from the src array in the buffer at the current
-     * position
-     *
-     * @param src
-     *            the byte array to write
-     */
-    void put(byte[] src);
-
-    /**
-     * Writes a char at the buffer's current position
-     *
-     * @param value
-     *            The char to write
-     */
-    void putChar(char value);
-
-    /**
-     * Writes a double at the buffer's current position
-     *
-     * @param value
-     *            The double to write
-     */
-    void putDouble(double value);
-
-    /**
-     * Writes a float at the buffer's current position
-     *
-     * @param value
-     *            The float to write
-     */
-    void putFloat(float value);
-
-    /**
-     * Writes an int at the buffer's current position
-     *
-     * @param value
-     *            The int to write
-     */
-    void putInt(int value);
-
-    /**
-     * Writes a long at the buffer's current position
-     *
-     * @param value
-     *            The long to write
-     */
-    void putLong(long value);
-
-    /**
-     * Writes a short at the buffer's current position
-     *
-     * @param value
-     *            The short to write
-     */
-    void putShort(short value);
-
-    /**
-     * Writes a string value in the byte buffer. The implementation can decide
-     * what format it will use. They can also have a maximum size, in which case
-     * string should be truncated if they are larger than that.
-     *
-     * @param value
-     *            The String value to write to the buffer
-     */
-    void putString(String value);
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/SafeByteBufferFactory.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/SafeByteBufferFactory.java
deleted file mode 100644 (file)
index 7086e68..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.provisional.datastore.core.serialization;
-
-import java.nio.ByteBuffer;
-
-import org.eclipse.tracecompass.internal.datastore.core.serialization.SafeByteBufferWrapper;
-
-/**
- * Class that creates instances of safe byte buffers wrappers from a part of a
- * ByteBuffer instance
- *
- * @author Geneviève Bastien
- */
-public final class SafeByteBufferFactory {
-
-    private SafeByteBufferFactory() {
-
-    }
-
-    /**
-     * Creates a new safe byte buffer reader from the ByteBuffer's current
-     * position with a size limited to 'size'.
-     *
-     * @param buffer
-     *            The big ByteBuffer to safely wrap for reading
-     * @param size
-     *            The size of the new sub-buffer
-     * @return The safe byte buffer reader instance
-     */
-    public static ISafeByteBufferReader wrapReader(ByteBuffer buffer, int size) {
-        int pos = buffer.position();
-        // Slice the main buffer, so that position 0 is the current position
-        // set it as read-only also
-        ByteBuffer readOnlyBuffer = buffer.slice().asReadOnlyBuffer();
-        readOnlyBuffer.order(buffer.order());
-        // Set its limit to the request limit
-        readOnlyBuffer.limit(size);
-        // Operations on fBuffer will not affect the main buffer's position, so
-        // we set its position to after the limit
-        buffer.position(pos + size);
-        return new SafeByteBufferWrapper(readOnlyBuffer);
-    }
-
-    /**
-     * Creates a new safe byte buffer writer from the ByteBuffer's current
-     * position with a size limited to 'size'.
-     *
-     * @param buffer
-     *            The big ByteBuffer to safely wrap for reading
-     * @param size
-     *            The size of the new sub-buffer
-     * @return The safe byte buffer writer instance
-     */
-    public static ISafeByteBufferWriter wrapWriter(ByteBuffer buffer, int size) {
-        int pos = buffer.position();
-        // Slice the main buffer, so that position 0 is the current position
-        ByteBuffer readWriteBuffer = buffer.slice();
-        readWriteBuffer.order(buffer.order());
-        // Set its limit to the request limit
-        readWriteBuffer.limit(size);
-        // Operations on fBuffer will not affect the main buffer's position, so
-        // we set its position to after the limit
-        buffer.position(pos + size);
-        return new SafeByteBufferWrapper(readWriteBuffer);
-    }
-
-    /**
-     * Get the serialized of a string object if it uses the
-     * {@link ISafeByteBufferWriter#putString(String)} method
-     *
-     * @param string
-     *            The string to write to the buffer
-     * @return The size of the string serialized by the
-     *         {@link ISafeByteBufferWriter#putString(String)} method, or -1 if
-     *         the string cannot be serialized
-     */
-    public static int getStringSizeInBuffer(String string) {
-        return SafeByteBufferWrapper.getStringSizeInBuffer(string);
-    }
-
-}
diff --git a/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/package-info.java b/statesystem/org.eclipse.tracecompass.datastore.core/src/org/eclipse/tracecompass/internal/provisional/datastore/core/serialization/package-info.java
deleted file mode 100644 (file)
index bdff1c0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-@org.eclipse.jdt.annotation.NonNullByDefault
-package org.eclipse.tracecompass.internal.provisional.datastore.core.serialization;
index ff5e2a1098c4dd6837748fd00796e10e2071f438..cb97a813db1f74c897ce1c6209f78282b76c1913 100644 (file)
@@ -26,8 +26,8 @@ import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.datastore.core.interval.IHTIntervalReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.eclipse.tracecompass.internal.provisional.segmentstore.core.ISegment2;
 import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
index 4dec1cb9ee08aae0645588d842107d2839c9cf93..aa313a330f9b1e54a8b85d88215090db2562a452 100644 (file)
@@ -14,9 +14,9 @@ import static org.junit.Assert.assertEquals;
 import java.nio.ByteBuffer;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.eclipse.tracecompass.internal.provisional.statesystem.core.statevalue.CustomStateValue;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
index 52d8625429ece8360272832854c0a3c8a808eca9..edce83c078b3731e1ac8712bb0da890d6d12de6e 100644 (file)
@@ -11,8 +11,8 @@ package org.eclipse.tracecompass.statesystem.core.tests.stubs.statevalues;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.eclipse.tracecompass.internal.provisional.statesystem.core.statevalue.CustomStateValue;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
index 8c7cf51470981c3bfc88aabd0c2cebba71c7c792..1a90cef4c45316fe98036b8c3223b20808fdd716 100644 (file)
@@ -12,8 +12,8 @@ package org.eclipse.tracecompass.internal.provisional.statesystem.core.statevalu
 import java.nio.BufferOverflowException;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
 import org.eclipse.tracecompass.internal.statesystem.core.Activator;
 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
 
index e0ab848711d4370b4d53376ef9bfc78d68324c8a..0edcf3f69297775aaf7b18153dc37cba34a07f24 100644 (file)
@@ -21,9 +21,9 @@ import java.nio.charset.Charset;
 import java.util.Objects;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferReader;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.ISafeByteBufferWriter;
-import org.eclipse.tracecompass.internal.provisional.datastore.core.serialization.SafeByteBufferFactory;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
+import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferWriter;
+import org.eclipse.tracecompass.datastore.core.serialization.SafeByteBufferFactory;
 import org.eclipse.tracecompass.internal.provisional.statesystem.core.statevalue.CustomStateValue;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
This page took 0.039887 seconds and 5 git commands to generate.