org.apache.coyote.tomcat5

Class InputBuffer

Implemented Interfaces:
ByteChunk.ByteInputChannel, CharChunk.CharInputChannel, CharChunk.CharOutputChannel

public class InputBuffer
extends Reader
implements ByteChunk.ByteInputChannel, CharChunk.CharInputChannel, CharChunk.CharOutputChannel

The buffer used by Tomcat request. This is a derivative of the Tomcat 3.3 OutputBuffer, adapted to handle input instead of output. This allows complete recycling of the facade objects (the ServletInputStream and the BufferedReader).

Author:
Remy Maucherat

Field Summary

int
BYTE_STATE
int
CHAR_STATE
static int
DEFAULT_BUFFER_SIZE
static String
DEFAULT_ENCODING
int
INITIAL_STATE
protected B2CConverter
conv
Current byte to char converter.
protected HashMap
encoders
List of encoders.

Constructor Summary

InputBuffer()
Default constructor.
InputBuffer(int size)
Alternate constructor which allows specifying the initial buffer size.

Method Summary

int
available()
void
checkConverter()
void
close()
Close the input buffer.
Request
getRequest()
Get associated Coyote request.
protected void
log(String s)
void
mark(int readAheadLimit)
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
int
read(char[] cbuf)
int
read(char[] cbuf, int off, int len)
int
readByte()
boolean
ready()
int
realReadBytes(cbuf[] , int off, int len)
Reads new bytes in the byte chunk.
int
realReadChars(cbuf[] , int off, int len)
void
realWriteChars(c[] , int off, int len)
Since the converter will use append, it is possible to get chars to be removed from the buffer for "writing".
void
recycle()
Recycle the output buffer.
void
reset()
protected void
setConverter()
void
setEncoding(String s)
void
setRequest(Request coyoteRequest)
Associated Coyote request.
long
skip(long n)

Field Details

BYTE_STATE

public final int BYTE_STATE


CHAR_STATE

public final int CHAR_STATE


DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE

Field Value:
8192


DEFAULT_ENCODING

public static final String DEFAULT_ENCODING


INITIAL_STATE

public final int INITIAL_STATE


conv

protected B2CConverter conv
Current byte to char converter.


encoders

protected HashMap encoders
List of encoders.

Constructor Details

InputBuffer

public InputBuffer()
Default constructor. Allocate the buffer with the default buffer size.


InputBuffer

public InputBuffer(int size)
Alternate constructor which allows specifying the initial buffer size.

Parameters:
size - Buffer size to use

Method Details

available

public int available()
            throws IOException


checkConverter

public void checkConverter()
            throws IOException


close

public void close()
            throws IOException
Close the input buffer.


getRequest

public Request getRequest()
Get associated Coyote request.

Returns:
the associated Coyote request


log

protected void log(String s)


mark

public void mark(int readAheadLimit)
            throws IOException


markSupported

public boolean markSupported()


read

public int read()
            throws IOException


read

public int read(byte[] b,
                int off,
                int len)
            throws IOException


read

public int read(char[] cbuf)
            throws IOException


read

public int read(char[] cbuf,
                int off,
                int len)
            throws IOException


readByte

public int readByte()
            throws IOException


ready

public boolean ready()
            throws IOException


realReadBytes

public int realReadBytes(cbuf[] ,
                         int off,
                         int len)
            throws IOException
Reads new bytes in the byte chunk.
Specified by:
realReadBytes in interface ByteChunk.ByteInputChannel

Parameters:
off - Offset


realReadChars

public int realReadChars(cbuf[] ,
                         int off,
                         int len)
            throws IOException
Specified by:
realReadChars in interface CharChunk.CharInputChannel


realWriteChars

public void realWriteChars(c[] ,
                           int off,
                           int len)
            throws IOException
Since the converter will use append, it is possible to get chars to be removed from the buffer for "writing". Since the chars have already been read before, they are ignored. If a mark was set, then the mark is lost.


recycle

public void recycle()
Recycle the output buffer.


reset

public void reset()
            throws IOException


setConverter

protected void setConverter()
            throws IOException


setEncoding

public void setEncoding(String s)


setRequest

public void setRequest(Request coyoteRequest)
Associated Coyote request.

Parameters:
coyoteRequest - Associated Coyote request


skip

public long skip(long n)
            throws IOException


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.