1 /* 2 * Copyright 2009 Red Hat, Inc. 3 * 4 * Red Hat licenses this file to you under the Apache License, version 2.0 5 * (the "License"); you may not use this file except in compliance with the 6 * License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package org.jboss.netty.handler.stream; 17 18 import org.jboss.netty.buffer.ChannelBuffer; 19 20 /** 21 * A large data stream which is consumed by {@link ChunkedWriteHandler}. 22 * 23 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a> 24 * @author <a href="http://gleamynode.net/">Trustin Lee</a> 25 * @version $Rev: 2166 $, $Date: 2010-02-18 13:24:41 +0900 (Thu, 18 Feb 2010) $ 26 * 27 * @apiviz.landmark 28 */ 29 public interface ChunkedInput { 30 31 /** 32 * Returns {@code true} if and only if there is any data left in the 33 * stream. Please note that {@code false} does not necessarily mean that 34 * the stream has reached at its end. In a slow stream, the next chunk 35 * might be unavailable just momentarily. 36 */ 37 boolean hasNextChunk() throws Exception; 38 39 /** 40 * Fetches a chunked data from the stream. The returned chunk is usually 41 * a {@link ChannelBuffer}, but you could extend an existing implementation 42 * to convert the {@link ChannelBuffer} into a different type that your 43 * handler or encoder understands. 44 * 45 * @return the fetched chunk, which is usually {@link ChannelBuffer}. 46 * {@code null} if there is no data left in the stream. 47 * Please note that {@code null} does not necessarily mean that the 48 * stream has reached at its end. In a slow stream, the next chunk 49 * might be unavailable just momentarily. 50 */ 51 Object nextChunk() throws Exception; 52 53 /** 54 * Return {@code true} if and only if there is no data left in the stream 55 * and the stream has reached at its end. 56 */ 57 boolean isEndOfInput() throws Exception; 58 59 /** 60 * Releases the resources associated with the stream. 61 */ 62 void close() throws Exception; 63 }