From 72c869d8dc7c95fc038fee7f36bf02fe4dceb842 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Sun, 2 Oct 2011 00:11:10 +0000 Subject: [PATCH] correctly save PlfLst git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1178105 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/util/LittleEndian.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/java/org/apache/poi/util/LittleEndian.java b/src/java/org/apache/poi/util/LittleEndian.java index fb47009c9d..3d1c9cd937 100644 --- a/src/java/org/apache/poi/util/LittleEndian.java +++ b/src/java/org/apache/poi/util/LittleEndian.java @@ -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; + } + } } -- 2.39.5