Author: kiwiwings
Date: Mon Apr 6 20:43:16 2020
New Revision: 1876205
URL: http://svn.apache.org/viewvc?rev=1876205&view=rev
Log:
ArrayUtil - remove unused method
Modified:
poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java
poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java
Modified: poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java?rev=1876205&r1=1876204&r2=1876205&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/ArrayUtil.java Mon Apr 6 20:43:16
2020
@@ -20,35 +20,13 @@ package org.apache.poi.util;
/**
* Utility classes for dealing with arrays.
- *
- * @author Glen Stampoultzis
*/
-public class ArrayUtil
-{
- /**
- * This is really a debugging version of <code>System.arraycopy()</code>.
- * Use it to provide better exception messages when copying arrays around.
- * For production use it's better to use the original for speed.
- */
- public static void arraycopy(byte[] src, int src_position, byte[] dst, int
dst_position, int length)
- {
- if (src_position < 0)
- throw new IllegalArgumentException("src_position was less than 0.
Actual value " + src_position);
- if (src_position >= src.length)
- throw new IllegalArgumentException( "src_position was greater than
src array size. Tried to write starting at position " + src_position + " but
the array length is " + src.length );
- if (src_position + length > src.length)
- throw new IllegalArgumentException("src_position + length would
overrun the src array. Expected end at " + (src_position + length) + " actual
end at " + src.length);
- if (dst_position < 0)
- throw new IllegalArgumentException("dst_position was less than 0.
Actual value " + dst_position);
- if (dst_position >= dst.length)
- throw new IllegalArgumentException( "dst_position was greater than
dst array size. Tried to write starting at position " + dst_position + " but
the array length is " + dst.length );
- if (dst_position + length > dst.length)
- throw new IllegalArgumentException("dst_position + length would
overrun the dst array. Expected end at " + (dst_position + length) + " actual
end at " + dst.length);
+@Internal
+public final class ArrayUtil {
- System.arraycopy( src, src_position, dst, dst_position, length);
- }
+ 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
@@ -60,7 +38,7 @@ public class ArrayUtil
// 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");
@@ -74,11 +52,11 @@ public class ArrayUtil
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
+
+ // Grab the bit to move
Object[] toMove = new Object[numToMove];
System.arraycopy(array, moveFrom, toMove, 0, numToMove);
-
+
// Grab the bit to be shifted
Object[] toShift;
int shiftTo;
@@ -95,14 +73,14 @@ public class ArrayUtil
System.arraycopy(array, moveFrom+numToMove, toShift, 0,
toShift.length);
shiftTo = moveFrom;
}
-
+
// 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);
-
-
+
+
// We're done - array will now have everything moved as required
}
Modified: poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java?rev=1876205&r1=1876204&r2=1876205&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java Mon Apr 6
20:43:16 2020
@@ -30,22 +30,6 @@ import org.junit.Test;
*/
public class TestArrayUtil {
/**
- * Test to ensure that our own arraycopy behaves as it should do
- */
- @Test
- public void testarraycopy() {
- byte[] bytes = new byte[] { 0x01, 0x02, 0x03, 0x04 };
-
- // Test copy whole thing
- byte[] dest = new byte[4];
- ArrayUtil.arraycopy(bytes, 0, dest, 0, 4);
-
- assertArrayEquals(dest, bytes);
- // ToDo - test exceptions are as expected
- }
-
-
- /**
* Helper for testArrayMoveWithin
*/
private Integer[] getIntsList() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]