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;
|
package com.twelvemonkeys.imageio.stream;
|
||||||
|
|
||||||
import com.twelvemonkeys.lang.Validate;
|
|
||||||
|
|
||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import javax.imageio.stream.ImageInputStreamImpl;
|
import javax.imageio.stream.ImageInputStreamImpl;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import static com.twelvemonkeys.lang.Validate.notNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A buffered {@code ImageInputStream}.
|
* A buffered {@code ImageInputStream}.
|
||||||
* Experimental - seems to be effective for {@link javax.imageio.stream.FileImageInputStream}
|
* 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 {
|
private BufferedImageInputStream(final ImageInputStream pStream, final int pBufferSize) throws IOException {
|
||||||
Validate.notNull(pStream, "stream");
|
stream = notNull(pStream, "stream");
|
||||||
|
|
||||||
stream = pStream;
|
|
||||||
streamPos = pStream.getStreamPosition();
|
streamPos = pStream.getStreamPosition();
|
||||||
buffer = ByteBuffer.allocate(pBufferSize);
|
buffer = ByteBuffer.allocate(pBufferSize);
|
||||||
buffer.limit(0);
|
buffer.limit(0);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package com.twelvemonkeys.imageio.stream;
|
package com.twelvemonkeys.imageio.stream;
|
||||||
|
|
||||||
import com.twelvemonkeys.lang.Validate;
|
|
||||||
|
|
||||||
import javax.imageio.stream.ImageInputStreamImpl;
|
import javax.imageio.stream.ImageInputStreamImpl;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.twelvemonkeys.lang.Validate.isTrue;
|
||||||
|
import static com.twelvemonkeys.lang.Validate.notNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Experimental
|
* Experimental
|
||||||
*
|
*
|
||||||
@ -22,13 +23,13 @@ public final class ByteArrayImageInputStream extends ImageInputStreamImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ByteArrayImageInputStream(final byte[] pData, int offset, int length) {
|
public ByteArrayImageInputStream(final byte[] pData, int offset, int length) {
|
||||||
Validate.notNull(pData, "data");
|
data = notNull(pData, "data");
|
||||||
Validate.isTrue(offset >= 0 && offset <= pData.length, offset, "offset out of range: %d");
|
dataOffset = isBetween(0, pData.length, offset, "offset");
|
||||||
Validate.isTrue(length >= 0 && length <= pData.length - offset, length, "length out of range: %d");
|
dataLength = isBetween(0, pData.length - offset, length, "length");
|
||||||
|
}
|
||||||
|
|
||||||
data = pData;
|
private static int isBetween(final int low, final int high, final int value, final String name) {
|
||||||
dataOffset = offset;
|
return isTrue(value >= low && value <= high, value, String.format("%s out of range [%d, %d]: %d", name, low, high, value));
|
||||||
dataLength = length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user