You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC
svn commit: r1890120 [26/43] - in /poi/trunk/poi/src:
main/java/org/apache/poi/ main/java/org/apache/poi/ddf/
main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/
main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/
main/java...
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SSCellRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SSCellRange.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SSCellRange.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/util/SSCellRange.java Sat May 22 20:56:44 2021
@@ -32,91 +32,91 @@ import org.apache.poi.util.Internal;
@Internal
public final class SSCellRange<K extends Cell> implements CellRange<K> {
- private final int _height;
- private final int _width;
- private final K[] _flattenedArray;
- private final int _firstRow;
- private final int _firstColumn;
-
- private SSCellRange(int firstRow, int firstColumn, int height, int width, K[] flattenedArray) {
- _firstRow = firstRow;
- _firstColumn = firstColumn;
- _height = height;
- _width = width;
- _flattenedArray = flattenedArray.clone();
- }
-
- public static <B extends Cell> SSCellRange<B> create(int firstRow, int firstColumn, int height, int width, List<B> flattenedList, Class<B> cellClass) {
- int nItems = flattenedList.size();
- if (height * width != nItems) {
- throw new IllegalArgumentException("Array size mismatch.");
- }
-
- @SuppressWarnings("unchecked")
- B[] flattenedArray = (B[]) Array.newInstance(cellClass, nItems);
- flattenedList.toArray(flattenedArray);
- return new SSCellRange<>(firstRow, firstColumn, height, width, flattenedArray);
- }
+ private final int _height;
+ private final int _width;
+ private final K[] _flattenedArray;
+ private final int _firstRow;
+ private final int _firstColumn;
+
+ private SSCellRange(int firstRow, int firstColumn, int height, int width, K[] flattenedArray) {
+ _firstRow = firstRow;
+ _firstColumn = firstColumn;
+ _height = height;
+ _width = width;
+ _flattenedArray = flattenedArray.clone();
+ }
+
+ public static <B extends Cell> SSCellRange<B> create(int firstRow, int firstColumn, int height, int width, List<B> flattenedList, Class<B> cellClass) {
+ int nItems = flattenedList.size();
+ if (height * width != nItems) {
+ throw new IllegalArgumentException("Array size mismatch.");
+ }
+
+ @SuppressWarnings("unchecked")
+ B[] flattenedArray = (B[]) Array.newInstance(cellClass, nItems);
+ flattenedList.toArray(flattenedArray);
+ return new SSCellRange<>(firstRow, firstColumn, height, width, flattenedArray);
+ }
- @Override
+ @Override
public int getHeight() {
- return _height;
- }
- @Override
- public int getWidth() {
- return _width;
- }
- @Override
- public int size() {
- return _height*_width;
- }
-
- @Override
- public String getReferenceText() {
- CellRangeAddress cra = new CellRangeAddress(_firstRow, _firstRow+_height-1, _firstColumn, _firstColumn+_width-1);
- return cra.formatAsString();
- }
-
- @Override
- public K getTopLeftCell() {
- return _flattenedArray[0];
- }
-
- @Override
- public K getCell(int relativeRowIndex, int relativeColumnIndex) {
- if (relativeRowIndex < 0 || relativeRowIndex >= _height) {
- throw new ArrayIndexOutOfBoundsException("Specified row " + relativeRowIndex
- + " is outside the allowable range (0.." + (_height-1) + ").");
- }
- if (relativeColumnIndex < 0 || relativeColumnIndex >= _width) {
- throw new ArrayIndexOutOfBoundsException("Specified colummn " + relativeColumnIndex
- + " is outside the allowable range (0.." + (_width-1) + ").");
- }
- int flatIndex = _width * relativeRowIndex + relativeColumnIndex;
- return _flattenedArray[flatIndex];
- }
- @Override
- public K[] getFlattenedCells() {
- return _flattenedArray.clone();
- }
-
- @Override
- public K[][] getCells() {
- Class<?> itemCls = _flattenedArray.getClass();
- @SuppressWarnings("unchecked")
- K[][] result = (K[][]) Array.newInstance(itemCls, _height);
- itemCls = itemCls.getComponentType();
- for (int r=_height-1; r>=0; r--) {
- @SuppressWarnings("unchecked")
- K[] row = (K[]) Array.newInstance(itemCls, _width);
- int flatIndex = _width * r;
- System.arraycopy(_flattenedArray, flatIndex, row, 0, _width);
- }
- return result;
- }
-
- @Override
- public Iterator<K> iterator() {
- return Stream.of(_flattenedArray).iterator();
- }
+ return _height;
+ }
+ @Override
+ public int getWidth() {
+ return _width;
+ }
+ @Override
+ public int size() {
+ return _height*_width;
+ }
+
+ @Override
+ public String getReferenceText() {
+ CellRangeAddress cra = new CellRangeAddress(_firstRow, _firstRow+_height-1, _firstColumn, _firstColumn+_width-1);
+ return cra.formatAsString();
+ }
+
+ @Override
+ public K getTopLeftCell() {
+ return _flattenedArray[0];
+ }
+
+ @Override
+ public K getCell(int relativeRowIndex, int relativeColumnIndex) {
+ if (relativeRowIndex < 0 || relativeRowIndex >= _height) {
+ throw new ArrayIndexOutOfBoundsException("Specified row " + relativeRowIndex
+ + " is outside the allowable range (0.." + (_height-1) + ").");
+ }
+ if (relativeColumnIndex < 0 || relativeColumnIndex >= _width) {
+ throw new ArrayIndexOutOfBoundsException("Specified colummn " + relativeColumnIndex
+ + " is outside the allowable range (0.." + (_width-1) + ").");
+ }
+ int flatIndex = _width * relativeRowIndex + relativeColumnIndex;
+ return _flattenedArray[flatIndex];
+ }
+ @Override
+ public K[] getFlattenedCells() {
+ return _flattenedArray.clone();
+ }
+
+ @Override
+ public K[][] getCells() {
+ Class<?> itemCls = _flattenedArray.getClass();
+ @SuppressWarnings("unchecked")
+ K[][] result = (K[][]) Array.newInstance(itemCls, _height);
+ itemCls = itemCls.getComponentType();
+ for (int r=_height-1; r>=0; r--) {
+ @SuppressWarnings("unchecked")
+ K[] row = (K[]) Array.newInstance(itemCls, _width);
+ int flatIndex = _width * r;
+ System.arraycopy(_flattenedArray, flatIndex, row, 0, _width);
+ }
+ return result;
+ }
+
+ @Override
+ public Iterator<K> iterator() {
+ return Stream.of(_flattenedArray).iterator();
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/util/WorkbookUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/util/WorkbookUtil.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/util/WorkbookUtil.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/util/WorkbookUtil.java Sat May 22 20:56:44 2021
@@ -22,28 +22,28 @@ package org.apache.poi.ss.util;
*/
public class WorkbookUtil {
- /**
- * Creates a valid sheet name, which is conform to the rules.
- * In any case, the result safely can be used for
- * {@link org.apache.poi.ss.usermodel.Workbook#setSheetName(int, String)}.
- * <br>
- * Rules:
- * <ul>
- * <li>never null</li>
- * <li>minimum length is 1</li>
- * <li>maximum length is 31</li>
- * <li>doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [ </li>
- * <li>Sheet names must not begin or end with ' (apostrophe)</li>
- * </ul>
- * Invalid characters are replaced by one space character ' '.
- *
- * @param nameProposal can be any string, will be truncated if necessary,
- * allowed to be null
- * @return a valid string, "empty" if to short, "null" if null
- */
- public static String createSafeSheetName(final String nameProposal) {
- return createSafeSheetName(nameProposal, ' ');
- }
+ /**
+ * Creates a valid sheet name, which is conform to the rules.
+ * In any case, the result safely can be used for
+ * {@link org.apache.poi.ss.usermodel.Workbook#setSheetName(int, String)}.
+ * <br>
+ * Rules:
+ * <ul>
+ * <li>never null</li>
+ * <li>minimum length is 1</li>
+ * <li>maximum length is 31</li>
+ * <li>doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [ </li>
+ * <li>Sheet names must not begin or end with ' (apostrophe)</li>
+ * </ul>
+ * Invalid characters are replaced by one space character ' '.
+ *
+ * @param nameProposal can be any string, will be truncated if necessary,
+ * allowed to be null
+ * @return a valid string, "empty" if to short, "null" if null
+ */
+ public static String createSafeSheetName(final String nameProposal) {
+ return createSafeSheetName(nameProposal, ' ');
+ }
/**
* Creates a valid sheet name, which is conform to the rules.
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/ArrayUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/ArrayUtil.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/ArrayUtil.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/ArrayUtil.java Sat May 22 20:56:44 2021
@@ -26,9 +26,9 @@ import java.util.Arrays;
@Internal
public final class ArrayUtil {
- private ArrayUtil() {}
+ private ArrayUtil() {}
- /**
+ /**
* Moves a number of entries in an array to another point in the array,
* shifting those inbetween as required.
* @param array The array to alter
@@ -37,50 +37,50 @@ public final class ArrayUtil {
* @param numToMove The number of entries to move
*/
public static void arrayMoveWithin(Object[] array, int moveFrom, int moveTo, int numToMove) {
- // If we're not asked to do anything, return now
- if(numToMove <= 0) { return; }
- if(moveFrom == moveTo) { return; }
-
- // Check that the values supplied are valid
- if(moveFrom < 0 || moveFrom >= array.length) {
- throw new IllegalArgumentException("The moveFrom must be a valid array index");
- }
- if(moveTo < 0 || moveTo >= array.length) {
- throw new IllegalArgumentException("The moveTo must be a valid array index");
- }
- if(moveFrom+numToMove > array.length) {
- throw new IllegalArgumentException("Asked to move more entries than the array has");
- }
- if(moveTo+numToMove > array.length) {
- throw new IllegalArgumentException("Asked to move to a position that doesn't have enough space");
- }
-
- // Grab the bit to move
- Object[] toMove = Arrays.copyOfRange(array, moveFrom, moveFrom+numToMove);
-
- // Grab the bit to be shifted
- Object[] toShift;
- int shiftTo;
- if(moveFrom > moveTo) {
- // Moving to an earlier point in the array
- // Grab everything between the two points
- toShift = Arrays.copyOfRange(array, moveTo, moveFrom);
- shiftTo = moveTo + numToMove;
- } else {
- // Moving to a later point in the array
- // Grab everything from after the toMove block, to the new point
- toShift = Arrays.copyOfRange(array, moveFrom+numToMove, moveTo+numToMove);
- shiftTo = moveFrom;
- }
+ // If we're not asked to do anything, return now
+ if(numToMove <= 0) { return; }
+ if(moveFrom == moveTo) { return; }
+
+ // Check that the values supplied are valid
+ if(moveFrom < 0 || moveFrom >= array.length) {
+ throw new IllegalArgumentException("The moveFrom must be a valid array index");
+ }
+ if(moveTo < 0 || moveTo >= array.length) {
+ throw new IllegalArgumentException("The moveTo must be a valid array index");
+ }
+ if(moveFrom+numToMove > array.length) {
+ throw new IllegalArgumentException("Asked to move more entries than the array has");
+ }
+ if(moveTo+numToMove > array.length) {
+ throw new IllegalArgumentException("Asked to move to a position that doesn't have enough space");
+ }
+
+ // Grab the bit to move
+ Object[] toMove = Arrays.copyOfRange(array, moveFrom, moveFrom+numToMove);
+
+ // Grab the bit to be shifted
+ Object[] toShift;
+ int shiftTo;
+ if(moveFrom > moveTo) {
+ // Moving to an earlier point in the array
+ // Grab everything between the two points
+ toShift = Arrays.copyOfRange(array, moveTo, moveFrom);
+ shiftTo = moveTo + numToMove;
+ } else {
+ // Moving to a later point in the array
+ // Grab everything from after the toMove block, to the new point
+ toShift = Arrays.copyOfRange(array, moveFrom+numToMove, moveTo+numToMove);
+ shiftTo = moveFrom;
+ }
- // Copy the moved block to its new location
- System.arraycopy(toMove, 0, array, moveTo, toMove.length);
+ // Copy the moved block to its new location
+ System.arraycopy(toMove, 0, array, moveTo, toMove.length);
- // And copy the shifted block to the shifted location
- System.arraycopy(toShift, 0, array, shiftTo, toShift.length);
+ // And copy the shifted block to the shifted location
+ System.arraycopy(toShift, 0, array, shiftTo, toShift.length);
- // We're done - array will now have everything moved as required
+ // We're done - array will now have everything moved as required
}
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/ByteField.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/ByteField.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/ByteField.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/ByteField.java Sat May 22 20:56:44 2021
@@ -182,11 +182,11 @@ public class ByteField
public void readFromStream(final InputStream stream)
throws IOException
{
- // TODO - are these ~Field used / necessary
- int ib = stream.read();
- if (ib < 0) {
- throw new BufferUnderflowException();
- }
+ // TODO - are these ~Field used / necessary
+ int ib = stream.read();
+ if (ib < 0) {
+ throw new BufferUnderflowException();
+ }
_value = (byte) ib;
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/DelayableLittleEndianOutput.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/DelayableLittleEndianOutput.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/DelayableLittleEndianOutput.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/DelayableLittleEndianOutput.java Sat May 22 20:56:44 2021
@@ -25,8 +25,8 @@ package org.apache.poi.util;
* be written at any stage.
*/
public interface DelayableLittleEndianOutput extends LittleEndianOutput {
- /**
- * Creates an output stream intended for outputting a sequence of {@code size} bytes.
- */
- LittleEndianOutput createDelayedOutput(int size);
+ /**
+ * Creates an output stream intended for outputting a sequence of {@code size} bytes.
+ */
+ LittleEndianOutput createDelayedOutput(int size);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java Sat May 22 20:56:44 2021
@@ -23,103 +23,103 @@ import java.io.ByteArrayInputStream;
* Adapts a plain byte array to {@link LittleEndianInput}
*/
public class LittleEndianByteArrayInputStream extends ByteArrayInputStream implements LittleEndianInput {
- /**
- * Creates <code>LittleEndianByteArrayInputStream</code>
- * that uses <code>buf</code> as its
- * buffer array. The initial value of <code>pos</code>
- * is <code>offset</code> and the initial value
- * of <code>count</code> is the minimum of <code>offset+length</code>
- * and <code>buf.length</code>.
- * The buffer array is not copied. The buffer's mark is
- * set to the specified offset.
- *
- * @param buf the input buffer.
- * @param offset the offset in the buffer of the first byte to read.
- * @param length the maximum number of bytes to read from the buffer.
- */
- public LittleEndianByteArrayInputStream(byte[] buf, int offset, int length) { // NOSONAR
- super(buf, offset, length);
- }
-
- /**
- * Creates <code>LittleEndianByteArrayInputStream</code>
- * that uses <code>buf</code> as its
- * buffer array. The initial value of <code>pos</code>
- * is <code>offset</code> and the initial value
- * of <code>count</code> is the minimum of <code>offset+buf.length</code>
- * and <code>buf.length</code>.
- * The buffer array is not copied. The buffer's mark is
- * set to the specified offset.
- *
- * @param buf the input buffer.
- * @param offset the offset in the buffer of the first byte to read.
- */
- public LittleEndianByteArrayInputStream(byte[] buf, int offset) {
- this(buf, offset, buf.length - offset);
- }
-
- /**
- * Creates a <code>LittleEndianByteArrayInputStream</code>
- * so that it uses <code>buf</code> as its
- * buffer array.
- * The buffer array is not copied.
- * The initial value of <code>pos</code>
- * is <code>0</code> and the initial value
- * of <code>count</code> is the length of
- * <code>buf</code>.
- *
- * @param buf the input buffer.
- */
- public LittleEndianByteArrayInputStream(byte[] buf) {
- super(buf);
- }
-
- protected void checkPosition(int i) {
- if (i > count - pos) {
- throw new RuntimeException("Buffer overrun, having " + count + " bytes in the stream and position is at " + pos +
- ", but trying to increment position by " + i);
- }
- }
-
- public int getReadIndex() {
- return pos;
- }
-
- public void setReadIndex(int pos) {
- if (pos < 0 || pos >= count) {
- throw new IndexOutOfBoundsException();
- }
- this.pos = pos;
- }
+ /**
+ * Creates <code>LittleEndianByteArrayInputStream</code>
+ * that uses <code>buf</code> as its
+ * buffer array. The initial value of <code>pos</code>
+ * is <code>offset</code> and the initial value
+ * of <code>count</code> is the minimum of <code>offset+length</code>
+ * and <code>buf.length</code>.
+ * The buffer array is not copied. The buffer's mark is
+ * set to the specified offset.
+ *
+ * @param buf the input buffer.
+ * @param offset the offset in the buffer of the first byte to read.
+ * @param length the maximum number of bytes to read from the buffer.
+ */
+ public LittleEndianByteArrayInputStream(byte[] buf, int offset, int length) { // NOSONAR
+ super(buf, offset, length);
+ }
+
+ /**
+ * Creates <code>LittleEndianByteArrayInputStream</code>
+ * that uses <code>buf</code> as its
+ * buffer array. The initial value of <code>pos</code>
+ * is <code>offset</code> and the initial value
+ * of <code>count</code> is the minimum of <code>offset+buf.length</code>
+ * and <code>buf.length</code>.
+ * The buffer array is not copied. The buffer's mark is
+ * set to the specified offset.
+ *
+ * @param buf the input buffer.
+ * @param offset the offset in the buffer of the first byte to read.
+ */
+ public LittleEndianByteArrayInputStream(byte[] buf, int offset) {
+ this(buf, offset, buf.length - offset);
+ }
+
+ /**
+ * Creates a <code>LittleEndianByteArrayInputStream</code>
+ * so that it uses <code>buf</code> as its
+ * buffer array.
+ * The buffer array is not copied.
+ * The initial value of <code>pos</code>
+ * is <code>0</code> and the initial value
+ * of <code>count</code> is the length of
+ * <code>buf</code>.
+ *
+ * @param buf the input buffer.
+ */
+ public LittleEndianByteArrayInputStream(byte[] buf) {
+ super(buf);
+ }
+
+ protected void checkPosition(int i) {
+ if (i > count - pos) {
+ throw new RuntimeException("Buffer overrun, having " + count + " bytes in the stream and position is at " + pos +
+ ", but trying to increment position by " + i);
+ }
+ }
+
+ public int getReadIndex() {
+ return pos;
+ }
+
+ public void setReadIndex(int pos) {
+ if (pos < 0 || pos >= count) {
+ throw new IndexOutOfBoundsException();
+ }
+ this.pos = pos;
+ }
- @Override
+ @Override
public byte readByte() {
- checkPosition(1);
- return (byte)read();
- }
+ checkPosition(1);
+ return (byte)read();
+ }
- @Override
+ @Override
public int readInt() {
- final int size = LittleEndianConsts.INT_SIZE;
- checkPosition(size);
- int le = LittleEndian.getInt(buf, pos);
+ final int size = LittleEndianConsts.INT_SIZE;
+ checkPosition(size);
+ int le = LittleEndian.getInt(buf, pos);
long skipped = super.skip(size);
assert skipped == size : "Buffer overrun";
- return le;
- }
+ return le;
+ }
- @Override
+ @Override
public long readLong() {
- final int size = LittleEndianConsts.LONG_SIZE;
- checkPosition(size);
- long le = LittleEndian.getLong(buf, pos);
+ final int size = LittleEndianConsts.LONG_SIZE;
+ checkPosition(size);
+ long le = LittleEndian.getLong(buf, pos);
long skipped = super.skip(size);
assert skipped == size : "Buffer overrun";
- return le;
- }
+ return le;
+ }
- @Override
+ @Override
public short readShort() {
final int size = LittleEndianConsts.SHORT_SIZE;
checkPosition(size);
@@ -127,20 +127,20 @@ public class LittleEndianByteArrayInputS
long skipped = super.skip(size);
assert skipped == size : "Buffer overrun";
return le;
- }
+ }
- @Override
+ @Override
public int readUByte() {
- return readByte() & 0x00FF;
- }
+ return readByte() & 0x00FF;
+ }
- @Override
+ @Override
public int readUShort() {
return readShort() & 0x00FFFF;
- }
+ }
- public long readUInt() {
- return readInt() & 0x00FFFFFFFFL;
+ public long readUInt() {
+ return readInt() & 0x00FFFFFFFFL;
}
@Override
@@ -148,28 +148,28 @@ public class LittleEndianByteArrayInputS
return Double.longBitsToDouble(readLong());
}
- @Override
+ @Override
public void readFully(byte[] buffer, int off, int len) {
- checkPosition(len);
- read(buffer, off, len);
- }
+ checkPosition(len);
+ read(buffer, off, len);
+ }
- @Override
+ @Override
public void readFully(byte[] buffer) {
checkPosition(buffer.length);
read(buffer, 0, buffer.length);
- }
+ }
@Override
public void readPlain(byte[] buf, int off, int len) {
readFully(buf, off, len);
}
- /**
- * Change the limit of the ByteArrayInputStream
- * @param size the new limit - is truncated to length of internal buffer
- */
- public void limit(int size) {
- count = Math.min(size, buf.length);
- }
+ /**
+ * Change the limit of the ByteArrayInputStream
+ * @param size the new limit - is truncated to length of internal buffer
+ */
+ public void limit(int size) {
+ count = Math.min(size, buf.length);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java Sat May 22 20:56:44 2021
@@ -23,99 +23,99 @@ import java.io.OutputStream;
* Adapts a plain byte array to {@link LittleEndianOutput}
*/
public final class LittleEndianByteArrayOutputStream extends OutputStream implements LittleEndianOutput, DelayableLittleEndianOutput {
- private final byte[] _buf;
- private final int _endIndex;
- private int _writeIndex;
-
- public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset, int maxWriteLen) { // NOSONAR
- if (startOffset < 0 || startOffset > buf.length) {
- throw new IllegalArgumentException("Specified startOffset (" + startOffset
- + ") is out of allowable range (0.." + buf.length + ")");
- }
- _buf = buf;
- _writeIndex = startOffset;
- _endIndex = startOffset + maxWriteLen;
- if (_endIndex < startOffset || _endIndex > buf.length) {
- throw new IllegalArgumentException("calculated end index (" + _endIndex
- + ") is out of allowable range (" + _writeIndex + ".." + buf.length + ")");
- }
- }
- public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset) {
- this(buf, startOffset, buf.length - startOffset);
- }
-
- private void checkPosition(int i) {
- if (i > _endIndex - _writeIndex) {
- throw new RuntimeException("Buffer overrun");
- }
- }
+ private final byte[] _buf;
+ private final int _endIndex;
+ private int _writeIndex;
+
+ public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset, int maxWriteLen) { // NOSONAR
+ if (startOffset < 0 || startOffset > buf.length) {
+ throw new IllegalArgumentException("Specified startOffset (" + startOffset
+ + ") is out of allowable range (0.." + buf.length + ")");
+ }
+ _buf = buf;
+ _writeIndex = startOffset;
+ _endIndex = startOffset + maxWriteLen;
+ if (_endIndex < startOffset || _endIndex > buf.length) {
+ throw new IllegalArgumentException("calculated end index (" + _endIndex
+ + ") is out of allowable range (" + _writeIndex + ".." + buf.length + ")");
+ }
+ }
+ public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset) {
+ this(buf, startOffset, buf.length - startOffset);
+ }
+
+ private void checkPosition(int i) {
+ if (i > _endIndex - _writeIndex) {
+ throw new RuntimeException("Buffer overrun");
+ }
+ }
- @Override
+ @Override
public void writeByte(int v) {
- checkPosition(1);
- _buf[_writeIndex++] = (byte)v;
- }
+ checkPosition(1);
+ _buf[_writeIndex++] = (byte)v;
+ }
- @Override
+ @Override
public void writeDouble(double v) {
- writeLong(Double.doubleToLongBits(v));
- }
+ writeLong(Double.doubleToLongBits(v));
+ }
- @Override
+ @Override
public void writeInt(int v) {
- checkPosition(4);
- int i = _writeIndex;
- _buf[i++] = (byte)((v >>> 0) & 0xFF);
- _buf[i++] = (byte)((v >>> 8) & 0xFF);
- _buf[i++] = (byte)((v >>> 16) & 0xFF);
- _buf[i++] = (byte)((v >>> 24) & 0xFF);
- _writeIndex = i;
- }
+ checkPosition(4);
+ int i = _writeIndex;
+ _buf[i++] = (byte)((v >>> 0) & 0xFF);
+ _buf[i++] = (byte)((v >>> 8) & 0xFF);
+ _buf[i++] = (byte)((v >>> 16) & 0xFF);
+ _buf[i++] = (byte)((v >>> 24) & 0xFF);
+ _writeIndex = i;
+ }
- @Override
+ @Override
public void writeLong(long v) {
- writeInt((int)(v >> 0));
- writeInt((int)(v >> 32));
- }
+ writeInt((int)(v >> 0));
+ writeInt((int)(v >> 32));
+ }
- @Override
+ @Override
public void writeShort(int v) {
- checkPosition(2);
- int i = _writeIndex;
- _buf[i++] = (byte)((v >>> 0) & 0xFF);
- _buf[i++] = (byte)((v >>> 8) & 0xFF);
- _writeIndex = i;
- }
+ checkPosition(2);
+ int i = _writeIndex;
+ _buf[i++] = (byte)((v >>> 0) & 0xFF);
+ _buf[i++] = (byte)((v >>> 8) & 0xFF);
+ _writeIndex = i;
+ }
- @Override
+ @Override
public void write(int b) {
- writeByte(b);
+ writeByte(b);
}
- @Override
+ @Override
public void write(byte[] b) {
- int len = b.length;
- checkPosition(len);
- System.arraycopy(b, 0, _buf, _writeIndex, len);
- _writeIndex += len;
- }
+ int len = b.length;
+ checkPosition(len);
+ System.arraycopy(b, 0, _buf, _writeIndex, len);
+ _writeIndex += len;
+ }
- @Override
+ @Override
public void write(byte[] b, int offset, int len) {
- checkPosition(len);
- System.arraycopy(b, offset, _buf, _writeIndex, len);
- _writeIndex += len;
- }
-
- public int getWriteIndex() {
- return _writeIndex;
- }
+ checkPosition(len);
+ System.arraycopy(b, offset, _buf, _writeIndex, len);
+ _writeIndex += len;
+ }
- @Override
+ public int getWriteIndex() {
+ return _writeIndex;
+ }
+
+ @Override
public LittleEndianOutput createDelayedOutput(int size) {
- checkPosition(size);
- LittleEndianOutput result = new LittleEndianByteArrayOutputStream(_buf, _writeIndex, size);
- _writeIndex += size;
- return result;
- }
+ checkPosition(size);
+ LittleEndianOutput result = new LittleEndianByteArrayOutputStream(_buf, _writeIndex, size);
+ _writeIndex += size;
+ return result;
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInput.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInput.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInput.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInput.java Sat May 22 20:56:44 2021
@@ -18,24 +18,24 @@
package org.apache.poi.util;
public interface LittleEndianInput {
- int available();
- byte readByte();
- int readUByte();
- short readShort();
- int readUShort();
- int readInt();
- long readLong();
- double readDouble();
- void readFully(byte[] buf);
- void readFully(byte[] buf, int off, int len);
+ int available();
+ byte readByte();
+ int readUByte();
+ short readShort();
+ int readUShort();
+ int readInt();
+ long readLong();
+ double readDouble();
+ void readFully(byte[] buf);
+ void readFully(byte[] buf, int off, int len);
- /**
- * Usually acts the same as {@link #readFully(byte[], int, int)}, but
- * for an encrypted stream the raw (unencrypted) data is filled
- *
- * @param buf the byte array to receive the bytes
- * @param off the start offset into the byte array
- * @param len the amount of bytes to fill
- */
- void readPlain(byte[] buf, int off, int len);
+ /**
+ * Usually acts the same as {@link #readFully(byte[], int, int)}, but
+ * for an encrypted stream the raw (unencrypted) data is filled
+ *
+ * @param buf the byte array to receive the bytes
+ * @param off the start offset into the byte array
+ * @param len the amount of bytes to fill
+ */
+ void readPlain(byte[] buf, int off, int len);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianInputStream.java Sat May 22 20:56:44 2021
@@ -30,69 +30,69 @@ import java.io.InputStream;
*/
public class LittleEndianInputStream extends FilterInputStream implements LittleEndianInput {
- private static final int BUFFERED_SIZE = 8096;
+ private static final int BUFFERED_SIZE = 8096;
- private static final int EOF = -1;
- private int readIndex = 0;
- private int markIndex = -1;
-
- public LittleEndianInputStream(InputStream is) {
- super(is.markSupported() ? is : new BufferedInputStream(is, BUFFERED_SIZE));
- }
-
- @Override
- @SuppressForbidden("just delegating")
- public int available() {
- try {
- return super.available();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public byte readByte() {
- return (byte)readUByte();
- }
-
- @Override
- public int readUByte() {
+ private static final int EOF = -1;
+ private int readIndex = 0;
+ private int markIndex = -1;
+
+ public LittleEndianInputStream(InputStream is) {
+ super(is.markSupported() ? is : new BufferedInputStream(is, BUFFERED_SIZE));
+ }
+
+ @Override
+ @SuppressForbidden("just delegating")
+ public int available() {
+ try {
+ return super.available();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public byte readByte() {
+ return (byte)readUByte();
+ }
+
+ @Override
+ public int readUByte() {
byte[] buf = new byte[1];
- try {
- checkEOF(read(buf), 1);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return LittleEndian.getUByte(buf);
- }
-
- /**
- * get a float value, reads it in little endian format
- * then converts the resulting revolting IEEE 754 (curse them) floating
- * point number to a happy java float
- *
- * @return the float (32-bit) value
- */
- public float readFloat() {
- return Float.intBitsToFloat( readInt() );
- }
-
- @Override
- public double readDouble() {
- return Double.longBitsToDouble(readLong());
- }
-
- @Override
- public int readInt() {
+ try {
+ checkEOF(read(buf), 1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return LittleEndian.getUByte(buf);
+ }
+
+ /**
+ * get a float value, reads it in little endian format
+ * then converts the resulting revolting IEEE 754 (curse them) floating
+ * point number to a happy java float
+ *
+ * @return the float (32-bit) value
+ */
+ public float readFloat() {
+ return Float.intBitsToFloat( readInt() );
+ }
+
+ @Override
+ public double readDouble() {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ @Override
+ public int readInt() {
byte[] buf = new byte[LittleEndianConsts.INT_SIZE];
- try {
- checkEOF(read(buf), buf.length);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return LittleEndian.getInt(buf);
- }
-
+ try {
+ checkEOF(read(buf), buf.length);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return LittleEndian.getInt(buf);
+ }
+
/**
* get an unsigned int value from an InputStream
*
@@ -105,39 +105,39 @@ public class LittleEndianInputStream ext
long retNum = readInt();
return retNum & 0x00FFFFFFFFL;
}
-
- @Override
- public long readLong() {
+
+ @Override
+ public long readLong() {
byte[] buf = new byte[LittleEndianConsts.LONG_SIZE];
- try {
- checkEOF(read(buf), LittleEndianConsts.LONG_SIZE);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return LittleEndian.getLong(buf);
- }
-
- @Override
- public short readShort() {
- return (short)readUShort();
- }
-
- @Override
- public int readUShort() {
+ try {
+ checkEOF(read(buf), LittleEndianConsts.LONG_SIZE);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return LittleEndian.getLong(buf);
+ }
+
+ @Override
+ public short readShort() {
+ return (short)readUShort();
+ }
+
+ @Override
+ public int readUShort() {
byte[] buf = new byte[LittleEndianConsts.SHORT_SIZE];
- try {
- checkEOF(read(buf), LittleEndianConsts.SHORT_SIZE);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return LittleEndian.getUShort(buf);
- }
-
- private static void checkEOF(int actualBytes, int expectedBytes) {
- if (expectedBytes != 0 && (actualBytes == -1 || actualBytes != expectedBytes)) {
- throw new RuntimeException("Unexpected end-of-file");
- }
- }
+ try {
+ checkEOF(read(buf), LittleEndianConsts.SHORT_SIZE);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return LittleEndian.getUShort(buf);
+ }
+
+ private static void checkEOF(int actualBytes, int expectedBytes) {
+ if (expectedBytes != 0 && (actualBytes == -1 || actualBytes != expectedBytes)) {
+ throw new RuntimeException("Unexpected end-of-file");
+ }
+ }
@Override
public void readFully(byte[] buf) {
@@ -147,55 +147,55 @@ public class LittleEndianInputStream ext
@Override
public void readFully(byte[] buf, int off, int len) {
try {
- checkEOF(_read(buf, off, len), len);
+ checkEOF(_read(buf, off, len), len);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- int readBytes = super.read(b, off, len);
- readIndex += readBytes;
- return readBytes;
- }
-
- @Override
- public synchronized void mark(int readlimit) {
- super.mark(readlimit);
- markIndex = readIndex;
- }
-
- @Override
- public synchronized void reset() throws IOException {
- super.reset();
- if (markIndex > -1) {
- readIndex = markIndex;
- markIndex = -1;
- }
- }
-
- public int getReadIndex() {
- return readIndex;
- }
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int readBytes = super.read(b, off, len);
+ readIndex += readBytes;
+ return readBytes;
+ }
+
+ @Override
+ public synchronized void mark(int readlimit) {
+ super.mark(readlimit);
+ markIndex = readIndex;
+ }
+ @Override
+ public synchronized void reset() throws IOException {
+ super.reset();
+ if (markIndex > -1) {
+ readIndex = markIndex;
+ markIndex = -1;
+ }
+ }
+ public int getReadIndex() {
+ return readIndex;
+ }
- //Makes repeated calls to super.read() until length is read or EOF is reached
- private int _read(byte[] buffer, int offset, int length) throws IOException {
- //lifted directly from org.apache.commons.io.IOUtils 2.4
- int remaining = length;
- while (remaining > 0) {
- int location = length - remaining;
- int count = read(buffer, offset + location, remaining);
- if (EOF == count) {
- break;
- }
- remaining -= count;
- }
- return length - remaining;
- }
+
+ //Makes repeated calls to super.read() until length is read or EOF is reached
+ private int _read(byte[] buffer, int offset, int length) throws IOException {
+ //lifted directly from org.apache.commons.io.IOUtils 2.4
+ int remaining = length;
+ while (remaining > 0) {
+ int location = length - remaining;
+ int count = read(buffer, offset + location, remaining);
+ if (EOF == count) {
+ break;
+ }
+ remaining -= count;
+ }
+
+ return length - remaining;
+ }
@Override
public void readPlain(byte[] buf, int off, int len) {
@@ -203,14 +203,14 @@ public class LittleEndianInputStream ext
}
- public void skipFully(int len) throws IOException {
- if (len == 0) {
- return;
- }
- long skipped = IOUtils.skipFully(this, len);
- if (skipped > Integer.MAX_VALUE) {
- throw new IOException("can't skip further than "+Integer.MAX_VALUE);
- }
- checkEOF((int)skipped, len);
- }
+ public void skipFully(int len) throws IOException {
+ if (len == 0) {
+ return;
+ }
+ long skipped = IOUtils.skipFully(this, len);
+ if (skipped > Integer.MAX_VALUE) {
+ throw new IOException("can't skip further than "+Integer.MAX_VALUE);
+ }
+ checkEOF((int)skipped, len);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutput.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutput.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutput.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutput.java Sat May 22 20:56:44 2021
@@ -18,11 +18,11 @@
package org.apache.poi.util;
public interface LittleEndianOutput {
- void writeByte(int v);
- void writeShort(int v);
- void writeInt(int v);
- void writeLong(long v);
- void writeDouble(double v);
- void write(byte[] b);
- void write(byte[] b, int offset, int len);
+ void writeByte(int v);
+ void writeShort(int v);
+ void writeInt(int v);
+ void writeLong(long v);
+ void writeDouble(double v);
+ void write(byte[] b);
+ void write(byte[] b, int offset, int len);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/LittleEndianOutputStream.java Sat May 22 20:56:44 2021
@@ -22,106 +22,106 @@ import java.io.IOException;
import java.io.OutputStream;
public final class LittleEndianOutputStream extends FilterOutputStream implements LittleEndianOutput {
- public LittleEndianOutputStream(OutputStream out) {
- super(out);
- }
+ public LittleEndianOutputStream(OutputStream out) {
+ super(out);
+ }
- @Override
+ @Override
public void writeByte(int v) {
- try {
- out.write(v);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ try {
+ out.write(v);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
- @Override
+ @Override
public void writeDouble(double v) {
- writeLong(Double.doubleToLongBits(v));
- }
+ writeLong(Double.doubleToLongBits(v));
+ }
- @Override
+ @Override
public void writeInt(int v) {
- int b3 = (v >>> 24) & 0xFF;
- int b2 = (v >>> 16) & 0xFF;
- int b1 = (v >>> 8) & 0xFF;
- int b0 = (v) & 0xFF;
- try {
- out.write(b0);
- out.write(b1);
- out.write(b2);
- out.write(b3);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ int b3 = (v >>> 24) & 0xFF;
+ int b2 = (v >>> 16) & 0xFF;
+ int b1 = (v >>> 8) & 0xFF;
+ int b0 = (v) & 0xFF;
+ try {
+ out.write(b0);
+ out.write(b1);
+ out.write(b2);
+ out.write(b3);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
- @Override
+ @Override
public void writeLong(long v) {
- writeInt((int)(v/* >> 0*/));
- writeInt((int)(v >> 32));
- }
+ writeInt((int)(v/* >> 0*/));
+ writeInt((int)(v >> 32));
+ }
- @Override
+ @Override
public void writeShort(int v) {
- int b1 = (v >>> 8) & 0xFF;
- int b0 = (v) & 0xFF;
- try {
- out.write(b0);
- out.write(b1);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- @Override
+ int b1 = (v >>> 8) & 0xFF;
+ int b0 = (v) & 0xFF;
+ try {
+ out.write(b0);
+ out.write(b1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ @Override
public void write(byte[] b) {
- // suppress IOException for interface method
- try {
- super.write(b);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- @Override
+ // suppress IOException for interface method
+ try {
+ super.write(b);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ @Override
public void write(byte[] b, int off, int len) {
- // suppress IOException for interface method
- try {
- super.write(b, off, len);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-
- /**
- * Put unsigned int into output stream
- *
- * @param value
- * the int (32-bit) value
- */
- public void writeUInt( long value ) {
- try {
- out.write( (byte) ( ( value ) & 0xFF ) );
- out.write( (byte) ( ( value >>> 8 ) & 0xFF ) );
- out.write( (byte) ( ( value >>> 16 ) & 0xFF ) );
- out.write( (byte) ( ( value >>> 24 ) & 0xFF ) );
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Put unsigned short into output stream
- *
- * @param value
- * the unsigned short (16-bit) value
- */
- public void putUShort( int value ) {
- try {
- out.write( (byte) ( ( value ) & 0xFF ) );
- out.write( (byte) ( ( value >>> 8 ) & 0xFF ) );
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
+ // suppress IOException for interface method
+ try {
+ super.write(b, off, len);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
+ * Put unsigned int into output stream
+ *
+ * @param value
+ * the int (32-bit) value
+ */
+ public void writeUInt( long value ) {
+ try {
+ out.write( (byte) ( ( value ) & 0xFF ) );
+ out.write( (byte) ( ( value >>> 8 ) & 0xFF ) );
+ out.write( (byte) ( ( value >>> 16 ) & 0xFF ) );
+ out.write( (byte) ( ( value >>> 24 ) & 0xFF ) );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Put unsigned short into output stream
+ *
+ * @param value
+ * the unsigned short (16-bit) value
+ */
+ public void putUShort( int value ) {
+ try {
+ out.write( (byte) ( ( value ) & 0xFF ) );
+ out.write( (byte) ( ( value >>> 8 ) & 0xFF ) );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: poi/trunk/poi/src/test/java/org/apache/poi/POIDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/POIDataSamples.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/POIDataSamples.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/POIDataSamples.java Sat May 22 20:56:44 2021
@@ -201,8 +201,8 @@ public final class POIDataSamples {
}
if (new File("test-data").exists()) {
- dataDirName = "test-data";
- } else if (new File("../test-data").exists()) {
+ dataDirName = "test-data";
+ } else if (new File("../test-data").exists()) {
dataDirName = "../test-data";
} else {
throw new RuntimeException("Must set system property '" +
Modified: poi/trunk/poi/src/test/java/org/apache/poi/POITestCase.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/POITestCase.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/POITestCase.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/POITestCase.java Sat May 22 20:56:44 2021
@@ -204,20 +204,20 @@ public final class POITestCase {
assertTrue(value <= max, message + ": " + value + " is greater than the maximum value of " + max);
}
- /**
- * Ensures that the temporary directory is defined and exists and
- * ensures ImageIO uses this directory for cache-files
- */
- public static void setImageIOCacheDir() {
- final String tmpDirProperty = System.getProperty("java.io.tmpdir");
- if(tmpDirProperty == null || "".equals(tmpDirProperty)) {
- return;
- }
- // ensure that temp-dir exists because ImageIO requires it
- File tmpDir = new File(tmpDirProperty);
- if(!tmpDir.exists() && !tmpDir.mkdirs()) {
- throw new IllegalStateException("Could not create temporary directory " + tmpDirProperty + ", full path " + tmpDir.getAbsolutePath());
- }
- ImageIO.setCacheDirectory(tmpDir);
- }
+ /**
+ * Ensures that the temporary directory is defined and exists and
+ * ensures ImageIO uses this directory for cache-files
+ */
+ public static void setImageIOCacheDir() {
+ final String tmpDirProperty = System.getProperty("java.io.tmpdir");
+ if(tmpDirProperty == null || "".equals(tmpDirProperty)) {
+ return;
+ }
+ // ensure that temp-dir exists because ImageIO requires it
+ File tmpDir = new File(tmpDirProperty);
+ if(!tmpDir.exists() && !tmpDir.mkdirs()) {
+ throw new IllegalStateException("Could not create temporary directory " + tmpDirProperty + ", full path " + tmpDir.getAbsolutePath());
+ }
+ ImageIO.setCacheDirectory(tmpDir);
+ }
}
Modified: poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java Sat May 22 20:56:44 2021
@@ -37,198 +37,198 @@ final class TestEscherContainerRecord {
private static final POIDataSamples _samples = POIDataSamples.getDDFInstance();
@Test
- void testFillFields() {
- EscherRecordFactory f = new DefaultEscherRecordFactory();
- byte[] data = HexRead.readFromString("0F 02 11 F1 00 00 00 00");
- EscherRecord r = f.createRecord(data, 0);
- r.fillFields(data, 0, f);
- assertTrue(r instanceof EscherContainerRecord);
- assertEquals((short) 0x020F, r.getOptions());
- assertEquals((short) 0xF111, r.getRecordId());
-
- data = HexRead.readFromString("0F 02 11 F1 08 00 00 00" +
- " 02 00 22 F2 00 00 00 00");
- r = f.createRecord(data, 0);
- r.fillFields(data, 0, f);
- EscherRecord c = r.getChild(0);
- assertFalse(c instanceof EscherContainerRecord);
- assertEquals((short) 0x0002, c.getOptions());
- assertEquals((short) 0xF222, c.getRecordId());
- }
-
- @Test
- void testSerialize() {
- UnknownEscherRecord r = new UnknownEscherRecord();
- r.setOptions((short) 0x123F);
- r.setRecordId((short) 0xF112);
- byte[] data = new byte[8];
- r.serialize(0, data, new NullEscherSerializationListener());
-
- assertEquals("[3F, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex(data));
-
- EscherRecord childRecord = new UnknownEscherRecord();
- childRecord.setOptions((short) 0x9999);
- childRecord.setRecordId((short) 0xFF01);
- r.addChildRecord(childRecord);
- data = new byte[16];
- r.serialize(0, data, new NullEscherSerializationListener());
-
- assertEquals("[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex(data));
-
- }
-
- @Test
- void testToString() {
- EscherContainerRecord r = new EscherContainerRecord();
- r.setRecordId(EscherContainerRecord.SP_CONTAINER);
- r.setOptions((short) 0x000F);
+ void testFillFields() {
+ EscherRecordFactory f = new DefaultEscherRecordFactory();
+ byte[] data = HexRead.readFromString("0F 02 11 F1 00 00 00 00");
+ EscherRecord r = f.createRecord(data, 0);
+ r.fillFields(data, 0, f);
+ assertTrue(r instanceof EscherContainerRecord);
+ assertEquals((short) 0x020F, r.getOptions());
+ assertEquals((short) 0xF111, r.getRecordId());
+
+ data = HexRead.readFromString("0F 02 11 F1 08 00 00 00" +
+ " 02 00 22 F2 00 00 00 00");
+ r = f.createRecord(data, 0);
+ r.fillFields(data, 0, f);
+ EscherRecord c = r.getChild(0);
+ assertFalse(c instanceof EscherContainerRecord);
+ assertEquals((short) 0x0002, c.getOptions());
+ assertEquals((short) 0xF222, c.getRecordId());
+ }
+
+ @Test
+ void testSerialize() {
+ UnknownEscherRecord r = new UnknownEscherRecord();
+ r.setOptions((short) 0x123F);
+ r.setRecordId((short) 0xF112);
+ byte[] data = new byte[8];
+ r.serialize(0, data, new NullEscherSerializationListener());
+
+ assertEquals("[3F, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex(data));
+
+ EscherRecord childRecord = new UnknownEscherRecord();
+ childRecord.setOptions((short) 0x9999);
+ childRecord.setRecordId((short) 0xFF01);
+ r.addChildRecord(childRecord);
+ data = new byte[16];
+ r.serialize(0, data, new NullEscherSerializationListener());
+
+ assertEquals("[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex(data));
+
+ }
+
+ @Test
+ void testToString() {
+ EscherContainerRecord r = new EscherContainerRecord();
+ r.setRecordId(EscherContainerRecord.SP_CONTAINER);
+ r.setOptions((short) 0x000F);
String expected =
"{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 8\n" +
- "\t, \"isContainer\": true\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
-
- EscherOptRecord r2 = new EscherOptRecord();
- // don't try to shoot in foot, please -- vlsergey
- // r2.setOptions((short) 0x9876);
- r2.setRecordId(EscherOptRecord.RECORD_ID);
-
- r.addChildRecord(r2);
- expected =
- "{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 16 /* 0x00000010 */\n" +
- "\t, \"isContainer\": true\n" +
- "\t, \"children\": [\n" +
- "\t\t{ /* OPT */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t]\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
-
- r.addChildRecord(r2);
- expected =
- "{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
- "\t, \"isContainer\": true\n" +
- "\t, \"children\": [\n" +
- "\t\t{ /* OPT */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t},\t\t{ /* OPT - index: 1 */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t]\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
- }
-
- private static final class DummyEscherRecord extends EscherRecord {
- public DummyEscherRecord() { }
- @Override
+ "\t \"recordId\": -4092 /* 0xf004 */\n" +
+ "\t, \"version\": 15 /* 0x000f */\n" +
+ "\t, \"instance\": 0\n" +
+ "\t, \"options\": 15 /* 0x000f */\n" +
+ "\t, \"recordSize\": 8\n" +
+ "\t, \"isContainer\": true\n" +
+ "}";
+ expected = expected.replace("\n", System.getProperty("line.separator"));
+ assertEquals(expected, r.toString());
+
+ EscherOptRecord r2 = new EscherOptRecord();
+ // don't try to shoot in foot, please -- vlsergey
+ // r2.setOptions((short) 0x9876);
+ r2.setRecordId(EscherOptRecord.RECORD_ID);
+
+ r.addChildRecord(r2);
+ expected =
+ "{ /* SP_CONTAINER */\n" +
+ "\t \"recordId\": -4092 /* 0xf004 */\n" +
+ "\t, \"version\": 15 /* 0x000f */\n" +
+ "\t, \"instance\": 0\n" +
+ "\t, \"options\": 15 /* 0x000f */\n" +
+ "\t, \"recordSize\": 16 /* 0x00000010 */\n" +
+ "\t, \"isContainer\": true\n" +
+ "\t, \"children\": [\n" +
+ "\t\t{ /* OPT */\n" +
+ "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
+ "\t\t\t, \"version\": 3\n" +
+ "\t\t\t, \"instance\": 0\n" +
+ "\t\t\t, \"options\": 3\n" +
+ "\t\t\t, \"recordSize\": 8\n" +
+ "\t\t\t, \"isContainer\": false\n" +
+ "\t\t\t, \"properties\": [\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t]\n" +
+ "}";
+ expected = expected.replace("\n", System.getProperty("line.separator"));
+ assertEquals(expected, r.toString());
+
+ r.addChildRecord(r2);
+ expected =
+ "{ /* SP_CONTAINER */\n" +
+ "\t \"recordId\": -4092 /* 0xf004 */\n" +
+ "\t, \"version\": 15 /* 0x000f */\n" +
+ "\t, \"instance\": 0\n" +
+ "\t, \"options\": 15 /* 0x000f */\n" +
+ "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
+ "\t, \"isContainer\": true\n" +
+ "\t, \"children\": [\n" +
+ "\t\t{ /* OPT */\n" +
+ "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
+ "\t\t\t, \"version\": 3\n" +
+ "\t\t\t, \"instance\": 0\n" +
+ "\t\t\t, \"options\": 3\n" +
+ "\t\t\t, \"recordSize\": 8\n" +
+ "\t\t\t, \"isContainer\": false\n" +
+ "\t\t\t, \"properties\": [\n" +
+ "\t\t\t]\n" +
+ "\t\t},\t\t{ /* OPT - index: 1 */\n" +
+ "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
+ "\t\t\t, \"version\": 3\n" +
+ "\t\t\t, \"instance\": 0\n" +
+ "\t\t\t, \"options\": 3\n" +
+ "\t\t\t, \"recordSize\": 8\n" +
+ "\t\t\t, \"isContainer\": false\n" +
+ "\t\t\t, \"properties\": [\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t]\n" +
+ "}";
+ expected = expected.replace("\n", System.getProperty("line.separator"));
+ assertEquals(expected, r.toString());
+ }
+
+ private static final class DummyEscherRecord extends EscherRecord {
+ public DummyEscherRecord() { }
+ @Override
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) { return 0; }
- @Override
+ @Override
public int serialize(int offset, byte[] data, EscherSerializationListener listener) { return 0; }
- @Override
+ @Override
public int getRecordSize() { return 10; }
- @Override
+ @Override
public String getRecordName() { return ""; }
- @Override
- public Enum getGenericRecordType() { return EscherRecordTypes.UNKNOWN; }
- @Override
- public DummyEscherRecord copy() { return null; }
- }
-
- @Test
- void testGetRecordSize() {
- EscherContainerRecord r = new EscherContainerRecord();
- r.addChildRecord(new DummyEscherRecord());
- assertEquals(18, r.getRecordSize());
- }
-
- /**
- * We were having problems with reading too much data on an UnknownEscherRecord,
- * but hopefully we now read the correct size.
- */
- @Test
- void testBug44857() {
- byte[] data = _samples.readFile("Container.dat");
-
- // This used to fail with an OutOfMemory
- EscherContainerRecord record = new EscherContainerRecord();
- record.fillFields(data, 0, new DefaultEscherRecordFactory());
-
- Class<?>[] exp = { EscherDggRecord.class, EscherContainerRecord.class, EscherOptRecord.class, EscherSplitMenuColorsRecord.class };
- Class<?>[] act = record.getChildRecords().stream().map(Object::getClass).toArray(Class[]::new);
- assertArrayEquals(exp, act);
- }
-
- /**
- * Ensure {@link EscherContainerRecord} doesn't spill its guts everywhere
- */
- @Test
- void testChildren() {
- EscherContainerRecord ecr = new EscherContainerRecord();
- List<EscherRecord> children0 = ecr.getChildRecords();
- assertEquals(0, children0.size());
-
- EscherRecord chA = new DummyEscherRecord();
- EscherRecord chB = new DummyEscherRecord();
- EscherRecord chC = new DummyEscherRecord();
-
- ecr.addChildRecord(chA);
- ecr.addChildRecord(chB);
- children0.add(chC);
-
- List<EscherRecord> children1 = ecr.getChildRecords();
- assertNotSame(children0, children1);
- assertEquals(2, children1.size());
- assertEquals(chA, children1.get(0));
- assertEquals(chB, children1.get(1));
-
- assertEquals(1, children0.size()); // first copy unchanged
-
- ecr.setChildRecords(children0);
- ecr.addChildRecord(chA);
- List<EscherRecord> children2 = ecr.getChildRecords();
- assertEquals(2, children2.size());
- assertEquals(chC, children2.get(0));
- assertEquals(chA, children2.get(1));
- }
+ @Override
+ public Enum getGenericRecordType() { return EscherRecordTypes.UNKNOWN; }
+ @Override
+ public DummyEscherRecord copy() { return null; }
+ }
+
+ @Test
+ void testGetRecordSize() {
+ EscherContainerRecord r = new EscherContainerRecord();
+ r.addChildRecord(new DummyEscherRecord());
+ assertEquals(18, r.getRecordSize());
+ }
+
+ /**
+ * We were having problems with reading too much data on an UnknownEscherRecord,
+ * but hopefully we now read the correct size.
+ */
+ @Test
+ void testBug44857() {
+ byte[] data = _samples.readFile("Container.dat");
+
+ // This used to fail with an OutOfMemory
+ EscherContainerRecord record = new EscherContainerRecord();
+ record.fillFields(data, 0, new DefaultEscherRecordFactory());
+
+ Class<?>[] exp = { EscherDggRecord.class, EscherContainerRecord.class, EscherOptRecord.class, EscherSplitMenuColorsRecord.class };
+ Class<?>[] act = record.getChildRecords().stream().map(Object::getClass).toArray(Class[]::new);
+ assertArrayEquals(exp, act);
+ }
+
+ /**
+ * Ensure {@link EscherContainerRecord} doesn't spill its guts everywhere
+ */
+ @Test
+ void testChildren() {
+ EscherContainerRecord ecr = new EscherContainerRecord();
+ List<EscherRecord> children0 = ecr.getChildRecords();
+ assertEquals(0, children0.size());
+
+ EscherRecord chA = new DummyEscherRecord();
+ EscherRecord chB = new DummyEscherRecord();
+ EscherRecord chC = new DummyEscherRecord();
+
+ ecr.addChildRecord(chA);
+ ecr.addChildRecord(chB);
+ children0.add(chC);
+
+ List<EscherRecord> children1 = ecr.getChildRecords();
+ assertNotSame(children0, children1);
+ assertEquals(2, children1.size());
+ assertEquals(chA, children1.get(0));
+ assertEquals(chB, children1.get(1));
+
+ assertEquals(1, children0.size()); // first copy unchanged
+
+ ecr.setChildRecords(children0);
+ ecr.addChildRecord(chA);
+ List<EscherRecord> children2 = ecr.getChildRecords();
+ assertEquals(2, children2.size());
+ assertEquals(chC, children2.get(0));
+ assertEquals(chA, children2.get(1));
+ }
}
Modified: poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java Sat May 22 20:56:44 2021
@@ -174,78 +174,78 @@ final class TestEscherOptRecord {
*/
@Test
void testComplexSerialise() {
- byte[] data = {
- 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
- // Simple data follows
- 0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8
- 0x43, 0x01, 0x85-256, 0x00, 0x00, 0x00, // SP @ 14
- 0x44, 0x01, 0x04, 0x00, 0x00, 0x00, // SP @ 20
- 0x45, 0xC1-256, 0x88-256, 0x00, 0x00, 0x00, // SP @ 26
- 0x46, 0xC1-256, 0x90-256, 0x00, 0x00, 0x00, // SP @ 32
- 0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
- 0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
- 0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
- 0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08, // SP 10
- 0xC1-256, 0x01, 0x00, 0x00, 0x01, 0x00,
- 0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
- 0xCD-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xCE-256, 0x01, 0x00, 0x00, 0x00, 0x00, // SP 15
- 0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xFF-256, 0x01, 0x18, 0x00, 0x18, 0x00,
- 0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
- 0x3F, 0x02, 0x00, 0x00, 0x02, 0x00, // SP 21
+ byte[] data = {
+ 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
+ // Simple data follows
+ 0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8
+ 0x43, 0x01, 0x85-256, 0x00, 0x00, 0x00, // SP @ 14
+ 0x44, 0x01, 0x04, 0x00, 0x00, 0x00, // SP @ 20
+ 0x45, 0xC1-256, 0x88-256, 0x00, 0x00, 0x00, // SP @ 26
+ 0x46, 0xC1-256, 0x90-256, 0x00, 0x00, 0x00, // SP @ 32
+ 0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
+ 0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
+ 0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
+ 0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08, // SP 10
+ 0xC1-256, 0x01, 0x00, 0x00, 0x01, 0x00,
+ 0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
+ 0xCD-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xCE-256, 0x01, 0x00, 0x00, 0x00, 0x00, // SP 15
+ 0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0xFF-256, 0x01, 0x18, 0x00, 0x18, 0x00,
+ 0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
+ 0x3F, 0x02, 0x00, 0x00, 0x02, 0x00, // SP 21
- // Complex data follows
+ // Complex data follows
- // Complex data for Array #325
- // Array header
- 0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
- // Array data
- 0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
- 0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
- 0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x1C, 0x00,
- 0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
- 0x00, 0x24, 0x00, 0x44, 0x00,
- 0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
- 0x00, 0x54, 0x00, 0x38, 0x00,
- 0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
- 0x14, 0x00, 0x80-256, 0x00, 0x08, 0x00,
- 0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
- 0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
- 0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
- 0x00, 0x30, 0x00, 0x08, 0x00,
- 0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
- 0x00, 0x48, 0x00, 0x00, 0x00,
- 0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
- // Complex data for Array #326
- // Array header
- 0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
- // Array data
- 0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x00, 0x80-256
- };
+ // Complex data for Array #325
+ // Array header
+ 0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
+ // Array data
+ 0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
+ 0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
+ 0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x1C, 0x00,
+ 0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
+ 0x00, 0x24, 0x00, 0x44, 0x00,
+ 0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
+ 0x00, 0x54, 0x00, 0x38, 0x00,
+ 0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
+ 0x14, 0x00, 0x80-256, 0x00, 0x08, 0x00,
+ 0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
+ 0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
+ 0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
+ 0x00, 0x30, 0x00, 0x08, 0x00,
+ 0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
+ 0x00, 0x48, 0x00, 0x00, 0x00,
+ 0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
+ // Complex data for Array #326
+ // Array header
+ 0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
+ // Array data
+ 0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
+ 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
+ 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x00, 0x80-256
+ };
- // Create the record
+ // Create the record
EscherOptRecord r = new EscherOptRecord();
int filled = r.fillFields( data, new DefaultEscherRecordFactory() );
Modified: poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java Sat May 22 20:56:44 2021
@@ -89,19 +89,19 @@ final class TestUnknownEscherRecord {
"05 00 00 00 " + // remaining bytes
"01 02 03 04";
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
+ r = new UnknownEscherRecord();
+ r.fillFields( HexRead.readFromString( testData ), factory );
- assertEquals( 0x0200, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 12, r.getRecordSize() );
- assertFalse( r.isContainerRecord() );
- assertEquals( 0, r.getChildRecords().size() );
- assertEquals( 4, r.getData().length );
- assertEquals( 1, r.getData()[0] );
- assertEquals( 2, r.getData()[1] );
- assertEquals( 3, r.getData()[2] );
- assertEquals( 4, r.getData()[3] );
+ assertEquals( 0x0200, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+ assertEquals( 12, r.getRecordSize() );
+ assertFalse( r.isContainerRecord() );
+ assertEquals( 0, r.getChildRecords().size() );
+ assertEquals( 4, r.getData().length );
+ assertEquals( 1, r.getData()[0] );
+ assertEquals( 2, r.getData()[1] );
+ assertEquals( 3, r.getData()[2] );
+ assertEquals( 4, r.getData()[3] );
testData =
"0F 02 " + // options
@@ -111,15 +111,15 @@ final class TestUnknownEscherRecord {
"FF FF " + // record id
"00 00 00 00"; // remaining bytes
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
+ r = new UnknownEscherRecord();
+ r.fillFields( HexRead.readFromString( testData ), factory );
- assertEquals( 0x020F, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 8, r.getRecordSize() );
- assertTrue( r.isContainerRecord() );
- assertEquals( 1, r.getChildRecords().size() );
- assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
+ assertEquals( 0x020F, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+ assertEquals( 8, r.getRecordSize() );
+ assertTrue( r.isContainerRecord() );
+ assertEquals( 1, r.getChildRecords().size() );
+ assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
}
@Test
Modified: poi/trunk/poi/src/test/java/org/apache/poi/hpsf/basic/TestEmptyProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/hpsf/basic/TestEmptyProperties.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/hpsf/basic/TestEmptyProperties.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/hpsf/basic/TestEmptyProperties.java Sat May 22 20:56:44 2021
@@ -52,15 +52,15 @@ final class TestEmptyProperties {
/**
* This test file's summary information stream contains some empty properties.
*/
- private static final String POI_FS = "TestCorel.shw";
+ private static final String POI_FS = "TestCorel.shw";
- private static final String[] POI_FILES = {
+ private static final String[] POI_FILES = {
"PerfectOffice_MAIN",
SummaryInformation.DEFAULT_STREAM_NAME,
"Main"
};
- private List<POIFile> poiFiles;
+ private List<POIFile> poiFiles;
/**
* <p>Read a the test file from the "data" directory.</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org