Removed unused ChunkedInput.hasNextChunk()

This commit is contained in:
Trustin Lee 2011-03-03 01:56:08 +09:00
parent 98b2b6d8dc
commit 0382538548
6 changed files with 15 additions and 48 deletions

View File

@ -867,11 +867,6 @@ public class HttpPostRequestEncoder implements ChunkedInput {
//NO since the user can want to reuse (broadcast for instance) cleanFiles();
}
@Override
public boolean hasNextChunk() throws Exception {
return !isLastChunkSent;
}
/**
* Returns the next available HttpChunk. The caller is responsible to test if this chunk is the
* last one (isLast()), in order to stop calling this method.
@ -949,10 +944,10 @@ public class HttpPostRequestEncoder implements ChunkedInput {
return new DefaultHttpChunk(buffer);
}
@Override
@Override
public boolean isEndOfInput() throws Exception {
return isLastChunkSent;
}
return isLastChunkSent;
}
/**
* Exception when an error occurs while encoding

View File

@ -131,14 +131,9 @@ public class ChunkedFile implements ChunkedInput {
return offset;
}
@Override
public boolean hasNextChunk() throws Exception {
return offset < endOffset && file.getChannel().isOpen();
}
@Override
public boolean isEndOfInput() throws Exception {
return !hasNextChunk();
return !(offset < endOffset && file.getChannel().isOpen());
}
@Override

View File

@ -28,14 +28,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
*/
public interface ChunkedInput {
/**
* Returns {@code true} if and only if there is any data left in the
* stream. Please note that {@code false} does not necessarily mean that
* the stream has reached at its end. In a slow stream, the next chunk
* might be unavailable just momentarily.
*/
boolean hasNextChunk() throws Exception;
/**
* Fetches a chunked data from the stream. The returned chunk is usually
* a {@link ChannelBuffer}, but you could extend an existing implementation

View File

@ -137,14 +137,9 @@ public class ChunkedNioFile implements ChunkedInput {
return offset;
}
@Override
public boolean hasNextChunk() throws Exception {
return offset < endOffset && in.isOpen();
}
@Override
public boolean isEndOfInput() throws Exception {
return !hasNextChunk();
return !(offset < endOffset && in.isOpen());
}
@Override

View File

@ -79,27 +79,22 @@ public class ChunkedNioStream implements ChunkedInput {
}
@Override
public boolean hasNextChunk() throws Exception {
public boolean isEndOfInput() throws Exception {
if (byteBuffer.position() > 0) {
// A previous read was not over, so there is a next chunk in the buffer at least
return true;
return false;
}
if (in.isOpen()) {
// Try to read a new part, and keep this part (no rewind)
int b = in.read(byteBuffer);
if (b < 0) {
return false;
return true;
} else {
offset += b;
return true;
return false;
}
}
return false;
}
@Override
public boolean isEndOfInput() throws Exception {
return !hasNextChunk();
return true;
}
@Override
@ -109,7 +104,7 @@ public class ChunkedNioStream implements ChunkedInput {
@Override
public Object nextChunk() throws Exception {
if (!hasNextChunk()) {
if (isEndOfInput()) {
return null;
}
// buffer cannot be not be empty from there

View File

@ -75,21 +75,16 @@ public class ChunkedStream implements ChunkedInput {
}
@Override
public boolean hasNextChunk() throws Exception {
public boolean isEndOfInput() throws Exception {
int b = in.read();
if (b < 0) {
return false;
return true;
} else {
in.unread(b);
return true;
return false;
}
}
@Override
public boolean isEndOfInput() throws Exception {
return !hasNextChunk();
}
@Override
public void close() throws Exception {
in.close();
@ -97,7 +92,7 @@ public class ChunkedStream implements ChunkedInput {
@Override
public Object nextChunk() throws Exception {
if (!hasNextChunk()) {
if (isEndOfInput()) {
return null;
}