]> source.dussan.org Git - poi.git/commitdiff
correctly save PlfLst
authorSergey Vladimirov <sergey@apache.org>
Sun, 2 Oct 2011 00:11:10 +0000 (00:11 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sun, 2 Oct 2011 00:11:10 +0000 (00:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178105 13f79535-47bb-0310-9956-ffa450edef68

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

index fb47009c9d460543ed776415aad48a6b767cf573..3d1c9cd937815c47a87d328f120ba303839e7c84 100644 (file)
@@ -495,4 +495,42 @@ public class LittleEndian implements LittleEndianConsts {
 
         return copy;
     }
+
+    /**
+     * Read short array
+     * 
+     * @param  data                        the original byte array
+     * @param  offset                      Where to start copying from.
+     * @param  size                        Number of bytes to copy.
+     * @throws IndexOutOfBoundsException
+     *             - if read would cause access of data outside array bounds.
+     */
+    public static short[] getShortArray( byte[] data, int offset, int size )
+    {
+        short[] result = new short[size / SHORT_SIZE];
+        for ( int i = 0; i < result.length; i++ )
+        {
+            result[i] = getShort( data, offset + i * SHORT_SIZE );
+        }
+        return result;
+    }
+
+    /**
+     * Stores short array in buffer
+     * 
+     * @param data
+     *            the byte array
+     * @param offset
+     *            a starting offset into the byte array
+     * @param value
+     *            the short (16-bit) values
+     */
+    public static void putShortArray( byte[] data, int offset, short[] value )
+    {
+        for ( short s : value )
+        {
+            putShort( data, offset, s );
+            offset += SHORT_SIZE;
+        }
+    }
 }