mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 12:35:29 -04:00
TMI-CORE: Code clean-up.
This commit is contained in:
parent
cc5f763503
commit
791e1b2d56
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user