org.apache.catalina.connector

Class InputBuffer

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
intBYTE_STATE
protected B2CConverterconv
Current byte to char converter.
intCHAR_STATE
static intDEFAULT_BUFFER_SIZE
static StringDEFAULT_ENCODING
protected HashMapencoders
List of encoders.
intINITIAL_STATE
protected static StringManagersm
The string manager for this package.
Constructor Summary
InputBuffer()
Default constructor.
InputBuffer(int size)
Alternate constructor which allows specifying the initial buffer size.
Method Summary
intavailable()
voidcheckConverter()
voidclearEncoders()
Clear cached encoders (to save memory for Comet requests).
voidclose()
Close the input buffer.
RequestgetRequest()
Get associated Coyote request.
voidmark(int readAheadLimit)
booleanmarkSupported()
intread(byte[] b, int off, int len)
intread()
intread(char[] cbuf)
intread(char[] cbuf, int off, int len)
intreadByte()
booleanready()
intrealReadBytes(byte[] cbuf, int off, int len)
Reads new bytes in the byte chunk.
intrealReadChars(char[] cbuf, int off, int len)
voidrealWriteChars(char[] 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".
voidrecycle()
Recycle the output buffer.
voidreset()
protected voidsetConverter()
voidsetEncoding(String s)
voidsetRequest(Request coyoteRequest)
Associated Coyote request.
longskip(long n)

Field Detail

BYTE_STATE

public final int BYTE_STATE

conv

protected B2CConverter conv
Current byte to char converter.

CHAR_STATE

public final int CHAR_STATE

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING

encoders

protected HashMap encoders
List of encoders.

INITIAL_STATE

public final int INITIAL_STATE

sm

protected static StringManager sm
The string manager for this package.

Constructor Detail

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 Detail

available

public int available()

checkConverter

public void checkConverter()

clearEncoders

public void clearEncoders()
Clear cached encoders (to save memory for Comet requests).

close

public void close()
Close the input buffer.

Throws: IOException An underlying IOException occurred

getRequest

public Request getRequest()
Get associated Coyote request.

Returns: the associated Coyote request

mark

public void mark(int readAheadLimit)

markSupported

public boolean markSupported()

read

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

read

public int read()

read

public int read(char[] cbuf)

read

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

readByte

public int readByte()

ready

public boolean ready()

realReadBytes

public int realReadBytes(byte[] cbuf, int off, int len)
Reads new bytes in the byte chunk.

Parameters: cbuf Byte buffer to be written to the response off Offset len Length

Throws: IOException An underlying IOException occurred

realReadChars

public int realReadChars(char[] cbuf, int off, int len)

realWriteChars

public void realWriteChars(char[] 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". 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()

setConverter

protected void setConverter()

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)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.