TMI-CORE: Code clean-up.

This commit is contained in:
Harald Kuhr 2013-11-25 17:18:18 +01:00
parent cc5f763503
commit 791e1b2d56
2 changed files with 12 additions and 13 deletions

View File

@ -1,12 +1,12 @@
package com.twelvemonkeys.imageio.stream;
import com.twelvemonkeys.lang.Validate;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageInputStreamImpl;
import java.io.IOException;
import java.nio.ByteBuffer;
import static com.twelvemonkeys.lang.Validate.notNull;
/**
* A buffered {@code ImageInputStream}.
* Experimental - seems to be effective for {@link javax.imageio.stream.FileImageInputStream}
@ -32,9 +32,7 @@ public final class BufferedImageInputStream extends ImageInputStreamImpl impleme
}
private BufferedImageInputStream(final ImageInputStream pStream, final int pBufferSize) throws IOException {
Validate.notNull(pStream, "stream");
stream = pStream;
stream = notNull(pStream, "stream");
streamPos = pStream.getStreamPosition();
buffer = ByteBuffer.allocate(pBufferSize);
buffer.limit(0);

View File

@ -1,10 +1,11 @@
package com.twelvemonkeys.imageio.stream;
import com.twelvemonkeys.lang.Validate;
import javax.imageio.stream.ImageInputStreamImpl;
import java.io.IOException;
import static com.twelvemonkeys.lang.Validate.isTrue;
import static com.twelvemonkeys.lang.Validate.notNull;
/**
* Experimental
*
@ -22,13 +23,13 @@ public final class ByteArrayImageInputStream extends ImageInputStreamImpl {
}
public ByteArrayImageInputStream(final byte[] pData, int offset, int length) {
Validate.notNull(pData, "data");
Validate.isTrue(offset >= 0 && offset <= pData.length, offset, "offset out of range: %d");
Validate.isTrue(length >= 0 && length <= pData.length - offset, length, "length out of range: %d");
data = notNull(pData, "data");
dataOffset = isBetween(0, pData.length, offset, "offset");
dataLength = isBetween(0, pData.length - offset, length, "length");
}
data = pData;
dataOffset = offset;
dataLength = length;
private static int isBetween(final int low, final int high, final int value, final String name) {
return isTrue(value >= low && value <= high, value, String.format("%s out of range [%d, %d]: %d", name, low, high, value));
}
public int read() throws IOException {