rcp: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / ctf / core / event / types / FloatDeclaration.java
index 26ed60f8a2a93f0f5aa968d9e302aaff90be0b65..cd19941b599b2df3fb3156ce6b2abbd12d976684 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
  *
  * All rights reserved. This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License v1.0 which
@@ -15,9 +15,9 @@ import java.nio.ByteOrder;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.ctf.core.CTFException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException;
 
 /**
  * A CTF float declaration.
@@ -98,9 +98,6 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
         return fAlignement;
     }
 
-    /**
-     * @since 3.0
-     */
     @Override
     public int getMaximumSize() {
         return fMantissa + fExponent + 1;
@@ -110,12 +107,9 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
     // Operations
     // ------------------------------------------------------------------------
 
-    /**
-     * @since 3.0
-     */
     @Override
     public FloatDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
-            String fieldName, BitBuffer input) throws CTFReaderException {
+            String fieldName, BitBuffer input) throws CTFException {
         ByteOrder byteOrder = input.getByteOrder();
         input.setByteOrder(fByteOrder);
         double value = read(input);
@@ -129,7 +123,7 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
         return "[declaration] float[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
-    private double read(BitBuffer input) throws CTFReaderException {
+    private double read(BitBuffer input) throws CTFException {
         /* Offset the buffer position wrt the current alignment */
         alignRead(input);
         final int exp = getExponent();
@@ -144,13 +138,13 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
     }
 
     private static double readRawFloat32(BitBuffer input, final int manBits,
-            final int expBits) throws CTFReaderException {
+            final int expBits) throws CTFException {
         long temp = input.get(32, false);
         return createFloat(temp, manBits - 1, expBits);
     }
 
     private static double readRawFloat64(BitBuffer input, final int manBits,
-            final int expBits) throws CTFReaderException {
+            final int expBits) throws CTFException {
         long temp = input.get(64, false);
         return createFloat(temp, manBits - 1, expBits);
     }
@@ -181,4 +175,47 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
         ret *= expPow;
         return ret;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (fAlignement ^ (fAlignement >>> 32));
+        result = prime * result + fByteOrder.toString().hashCode(); // don't evaluate object but string
+        result = prime * result + fExponent;
+        result = prime * result + fMantissa;
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        FloatDeclaration other = (FloatDeclaration) obj;
+        if (fAlignement != other.fAlignement) {
+            return false;
+        }
+        if (!fByteOrder.equals(other.fByteOrder)) {
+            return false;
+        }
+        if (fExponent != other.fExponent) {
+            return false;
+        }
+        if (fMantissa != other.fMantissa) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean isBinaryEquivalent(@Nullable IDeclaration obj) {
+        return equals(obj);
+    }
 }
This page took 0.027293 seconds and 5 git commands to generate.