From 0382538548eaddf53b2556600e53c88fed7b19a9 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 3 Mar 2011 01:56:08 +0900 Subject: [PATCH] Removed unused ChunkedInput.hasNextChunk() --- .../codec/http/HttpPostRequestEncoder.java | 11 +++-------- .../jboss/netty/handler/stream/ChunkedFile.java | 7 +------ .../netty/handler/stream/ChunkedInput.java | 8 -------- .../netty/handler/stream/ChunkedNioFile.java | 7 +------ .../netty/handler/stream/ChunkedNioStream.java | 17 ++++++----------- .../netty/handler/stream/ChunkedStream.java | 13 ++++--------- 6 files changed, 15 insertions(+), 48 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpPostRequestEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpPostRequestEncoder.java index f0176be199..22a9c64abf 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpPostRequestEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpPostRequestEncoder.java @@ -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 diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java index d046222984..cd754e2550 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java @@ -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 diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java index 21baf5ac67..fe6f072b85 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java @@ -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 diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java index 9896aa3cbb..b5387a0e91 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioFile.java @@ -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 diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java index e302ff4b97..c07a90cb4a 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedNioStream.java @@ -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 diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java index 4d9c21c13f..007acd387a 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java @@ -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; }