mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-03 03:25:28 -04:00
Minor enhancements to the Decoder API + tests.
This commit is contained in:
parent
a4dfb7a009
commit
9492ed67f1
@ -31,7 +31,7 @@ package com.twelvemonkeys.io.enc;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown by {@code Decoder}s when encoded data can not be decocded.
|
* Thrown by {@code Decoder}s when encoded data can not be decoded.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||||
|
@ -47,13 +47,13 @@ import java.io.IOException;
|
|||||||
public interface Decoder {
|
public interface Decoder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes up to {@code pBuffer.length} bytes from the given inputstream,
|
* Decodes up to {@code pBuffer.length} bytes from the given input stream,
|
||||||
* into the given buffer.
|
* into the given buffer.
|
||||||
*
|
*
|
||||||
* @param pStream the inputstream to decode data from
|
* @param pStream the input stream to decode data from
|
||||||
* @param pBuffer buffer to store the read data
|
* @param pBuffer buffer to store the read data
|
||||||
*
|
*
|
||||||
* @return the total number of bytes read into the buffer, or {@code -1}
|
* @return the total number of bytes read into the buffer, or {@code 0}
|
||||||
* if there is no more data because the end of the stream has been reached.
|
* if there is no more data because the end of the stream has been reached.
|
||||||
*
|
*
|
||||||
* @throws DecodeException if encoded data is corrupt
|
* @throws DecodeException if encoded data is corrupt
|
||||||
|
@ -143,7 +143,7 @@ public final class DecoderStream extends FilterInputStream {
|
|||||||
// Update offset (rest)
|
// Update offset (rest)
|
||||||
off += dstLen;
|
off += dstLen;
|
||||||
|
|
||||||
// Inrease count
|
// Increase count
|
||||||
count += dstLen;
|
count += dstLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ public abstract class DecoderAbstractTestCase extends ObjectAbstractTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testStreams() throws Exception {
|
public final void testStreams() throws Exception {
|
||||||
|
if (createCompatibleEncoder() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 1; i < 100; i++) {
|
for (int i = 1; i < 100; i++) {
|
||||||
try {
|
try {
|
||||||
runStreamTest(i);
|
runStreamTest(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user