Adjust comments and IDE warnings, duplicate code reduction
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1835183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2c3c7e004
commit
a4251b706b
@ -369,10 +369,10 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
|
|||||||
* @param nameIndex position of the named range (0-based)
|
* @param nameIndex position of the named range (0-based)
|
||||||
* @return the defined name at the specified index
|
* @return the defined name at the specified index
|
||||||
* @throws IllegalArgumentException if the supplied index is invalid
|
* @throws IllegalArgumentException if the supplied index is invalid
|
||||||
* @deprecated 3.18. New projects should avoid accessing named ranges by index.
|
* @deprecated 4.0.0. New projects should avoid accessing named ranges by index.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Removal(version="3.20")
|
@Removal(version="5.0.0")
|
||||||
Name getNameAt(int nameIndex);
|
Name getNameAt(int nameIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,13 +140,7 @@ public final class IOUtils {
|
|||||||
if (length > (long)Integer.MAX_VALUE) {
|
if (length > (long)Integer.MAX_VALUE) {
|
||||||
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
|
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
|
checkLength(length, maxLength);
|
||||||
if (length > BYTE_ARRAY_MAX_OVERRIDE) {
|
|
||||||
throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
|
|
||||||
}
|
|
||||||
} else if (length > maxLength) {
|
|
||||||
throwRFE(length, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int len = Math.min((int)length, maxLength);
|
final int len = Math.min((int)length, maxLength);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(len == Integer.MAX_VALUE ? 4096 : len);
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(len == Integer.MAX_VALUE ? 4096 : len);
|
||||||
@ -172,6 +166,16 @@ public final class IOUtils {
|
|||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkLength(long length, int maxLength) {
|
||||||
|
if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
|
||||||
|
if (length > BYTE_ARRAY_MAX_OVERRIDE) {
|
||||||
|
throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
|
||||||
|
}
|
||||||
|
} else if (length > maxLength) {
|
||||||
|
throwRFE(length, maxLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array (that shouldn't be written to!) of the
|
* Returns an array (that shouldn't be written to!) of the
|
||||||
@ -540,13 +544,7 @@ public final class IOUtils {
|
|||||||
if (length > (long)Integer.MAX_VALUE) {
|
if (length > (long)Integer.MAX_VALUE) {
|
||||||
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
|
throw new RecordFormatException("Can't allocate an array > "+Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
if (BYTE_ARRAY_MAX_OVERRIDE > 0) {
|
checkLength(length, maxLength);
|
||||||
if (length > BYTE_ARRAY_MAX_OVERRIDE) {
|
|
||||||
throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE);
|
|
||||||
}
|
|
||||||
} else if (length > maxLength) {
|
|
||||||
throwRFE(length, maxLength);
|
|
||||||
}
|
|
||||||
return new byte[(int)length];
|
return new byte[(int)length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public final class TestIOUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDown() throws IOException {
|
public static void tearDown() {
|
||||||
assertTrue(TMP.delete());
|
assertTrue(TMP.delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,13 +99,13 @@ public final class TestIOUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToByteArrayByteBuffer() throws Exception {
|
public void testToByteArrayByteBuffer() {
|
||||||
assertArrayEquals(new byte[] { 1, 2, 3},
|
assertArrayEquals(new byte[] { 1, 2, 3},
|
||||||
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3}), 10));
|
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3}), 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToByteArrayByteBufferToSmall() throws Exception {
|
public void testToByteArrayByteBufferToSmall() {
|
||||||
assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7},
|
assertArrayEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7},
|
||||||
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3, 4, 5, 6, 7}), 3));
|
IOUtils.toByteArray(ByteBuffer.wrap(new byte[]{1, 2, 3, 4, 5, 6, 7}), 3));
|
||||||
}
|
}
|
||||||
@ -210,19 +210,19 @@ public final class TestIOUtils {
|
|||||||
int readCalled;
|
int readCalled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() {
|
||||||
readCalled++;
|
readCalled++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] arr, int offset, int len) throws IOException {
|
public int read(byte[] arr, int offset, int len) {
|
||||||
readCalled++;
|
readCalled++;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long skip(long len) throws IOException {
|
public long skip(long len) {
|
||||||
skipCalled++;
|
skipCalled++;
|
||||||
if (skipCalled == 1) {
|
if (skipCalled == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user