]> source.dussan.org Git - poi.git/commitdiff
undeprecate get*() methods with 0 offset
authorSergey Vladimirov <sergey@apache.org>
Sun, 23 Oct 2011 21:52:34 +0000 (21:52 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sun, 23 Oct 2011 21:52:34 +0000 (21:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1187981 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/util/LittleEndian.java

index 81dc3536e4a8fdb6c3d840dc5bb1f8daca147cf2..bf654baa0707ee8664828c4136aab1030ffac9cc 100644 (file)
@@ -74,6 +74,20 @@ public class LittleEndian implements LittleEndianConsts
         return copy;
     }
 
+    /**
+     * get a double value from a byte array, reads it in little endian format
+     * then converts the resulting revolting IEEE 754 (curse them) floating
+     * point number to a happy java double
+     * 
+     * @param data
+     *            the byte array
+     * @return the double (64-bit) value
+     */
+    public static double getDouble( byte[] data )
+    {
+        return Double.longBitsToDouble( getLong( data, 0 ) );
+    }
+
     /**
      * get a double value from a byte array, reads it in little endian format
      * then converts the resulting revolting IEEE 754 (curse them) floating
@@ -90,6 +104,20 @@ public class LittleEndian implements LittleEndianConsts
         return Double.longBitsToDouble( getLong( data, offset ) );
     }
 
+    /**
+     * get a float value from a byte array, reads it in little endian format
+     * then converts the resulting revolting IEEE 754 (curse them) floating
+     * point number to a happy java float
+     * 
+     * @param data
+     *            the byte array
+     * @return the double (64-bit) value
+     */
+    public static float getFloat( byte[] data )
+    {
+        return getFloat( data, 0 );
+    }
+
     /**
      * get a float value from a byte array, reads it in little endian format
      * then converts the resulting revolting IEEE 754 (curse them) floating
@@ -112,9 +140,7 @@ public class LittleEndian implements LittleEndianConsts
      * @param data
      *            the byte array
      * @return the int (32-bit) value
-     * @deprecated Use {@link #getInt(byte[], int)}
      */
-    @Deprecated
     public static int getInt( byte[] data )
     {
         return getInt( data, 0 );
@@ -139,6 +165,18 @@ public class LittleEndian implements LittleEndianConsts
         return ( b3 << 24 ) + ( b2 << 16 ) + ( b1 << 8 ) + ( b0 << 0 );
     }
 
+    /**
+     * get a long value from a byte array
+     * 
+     * @param data
+     *            the byte array
+     * @return the long (64-bit) value
+     */
+    public static long getLong( byte[] data )
+    {
+        return getLong( data, 0 );
+    }
+
     /**
      * get a long value from a byte array
      * 
@@ -150,7 +188,7 @@ public class LittleEndian implements LittleEndianConsts
      */
     public static long getLong( byte[] data, int offset )
     {
-        long result = 0;
+        long result = 0xff & data[offset + 7];
 
         for ( int j = offset + LONG_SIZE - 1; j >= offset; j-- )
         {
@@ -166,9 +204,7 @@ public class LittleEndian implements LittleEndianConsts
      * @param data
      *            the byte array
      * @return the short (16-bit) value
-     * @deprecated Use {@link #getShort(byte[], int)} instead
      */
-    @Deprecated
     public static short getShort( byte[] data )
     {
         return getShort( data, 0 );
@@ -212,6 +248,18 @@ public class LittleEndian implements LittleEndianConsts
         return result;
     }
 
+    /**
+     * get the unsigned value of a byte.
+     * 
+     * @param data
+     *            the byte array.
+     * @return the unsigned value of the byte as a 16 bit short
+     */
+    public static short getUByte( byte[] data )
+    {
+        return (short) ( data[0] & 0xFF );
+    }
+
     /**
      * get the unsigned value of a byte.
      * 
@@ -232,9 +280,7 @@ public class LittleEndian implements LittleEndianConsts
      * @param data
      *            the byte array
      * @return the unsigned int (32-bit) value in a long
-     * @deprecated Use {@link #getUInt(byte[], int)}
      */
-    @Deprecated
     public static long getUInt( byte[] data )
     {
         return getUInt( data, 0 );
@@ -277,9 +323,7 @@ public class LittleEndian implements LittleEndianConsts
      * @param data
      *            the byte array
      * @return the unsigned short (16-bit) value in an int
-     * @deprecated Use {@link #getUShort(byte[], int)}
      */
-    @Deprecated
     public static int getUShort( byte[] data )
     {
         return getUShort( data, 0 );