org.apache.tomcat.core
Class OutputBuffer
java.lang.Object
|
+--java.io.Writer
|
+--org.apache.tomcat.core.OutputBuffer
- All Implemented Interfaces:
- ByteChunk.ByteOutputChannel, CharChunk.CharOutputChannel
- public class OutputBuffer
- extends java.io.Writer
- implements ByteChunk.ByteOutputChannel, CharChunk.CharOutputChannel
The buffer used by tomcat response. It allows writting chars and
bytes. It does the mixing in order to implement ServletOutputStream
( which has both byte and char methods ) and to allow a number of
optimizations (like a jsp pre-computing the byte[], but using char for
non-static content).
- Author:
- Costin Manolache
Fields inherited from class java.io.Writer |
lock |
Method Summary |
void |
close()
|
void |
flush()
|
void |
flushBytes()
Real write - this buffer will be sent to the client |
void |
flushChars()
|
boolean |
flushCharsNeeded()
|
byte[] |
getBuffer()
|
int |
getBufferSize()
|
int |
getByteOff()
Deprecated. Used only in Ajp13Packet for a hack |
int |
getBytesWritten()
|
int |
getCharsWritten()
|
boolean |
isNew()
True if this buffer hasn't been used ( since recycle() ) -
i.e. |
protected void |
log(java.lang.String s)
|
void |
realWriteBytes(byte[] buf,
int off,
int cnt)
Sends the buffer data to the client output, checking the
state of Response and calling the right interceptors. |
void |
realWriteChars(char[] c,
int off,
int len)
Send the bytes ( usually the internal conversion buffer ). |
void |
recycle()
|
void |
reset()
|
void |
setBufferSize(int size)
|
void |
setByteOff(int c)
Deprecated. Used only in Ajp13Packet for a hack |
protected void |
setConverter()
|
void |
setEncoding(java.lang.String s)
|
void |
setResponse(Response resp)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(char[] c)
|
void |
write(char[] c,
int off,
int len)
|
void |
write(int c)
|
void |
write(java.lang.String s)
|
void |
write(java.lang.StringBuffer sb)
|
void |
write(java.lang.String s,
int off,
int len)
Append a string to the buffer |
void |
writeByte(int b)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_ENCODING
public static final java.lang.String DEFAULT_ENCODING
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
INITIAL_STATE
public final int INITIAL_STATE
CHAR_STATE
public final int CHAR_STATE
BYTE_STATE
public final int BYTE_STATE
encoders
protected java.util.Hashtable encoders
conv
protected C2BConverter conv
OutputBuffer
public OutputBuffer()
OutputBuffer
public OutputBuffer(int size)
setResponse
public void setResponse(Response resp)
getBuffer
public byte[] getBuffer()
getByteOff
public int getByteOff()
- Deprecated. Used only in Ajp13Packet for a hack
- Return the first available position in the byte buffer
( or the number of bytes written ).
setByteOff
public void setByteOff(int c)
- Deprecated. Used only in Ajp13Packet for a hack
- Set the write position in the byte buffer
log
protected void log(java.lang.String s)
realWriteBytes
public void realWriteBytes(byte[] buf,
int off,
int cnt)
throws java.io.IOException
- Sends the buffer data to the client output, checking the
state of Response and calling the right interceptors.
- Specified by:
realWriteBytes
in interface ByteChunk.ByteOutputChannel
recycle
public void recycle()
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
writeByte
public void writeByte(int b)
throws java.io.IOException
write
public void write(int c)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
write
public void write(char[] c)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
write
public void write(char[] c,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
write
public void write(java.lang.StringBuffer sb)
throws java.io.IOException
write
public void write(java.lang.String s,
int off,
int len)
throws java.io.IOException
- Append a string to the buffer
- Overrides:
write
in class java.io.Writer
write
public void write(java.lang.String s)
throws java.io.IOException
- Overrides:
write
in class java.io.Writer
flushChars
public void flushChars()
throws java.io.IOException
flushCharsNeeded
public boolean flushCharsNeeded()
close
public void close()
throws java.io.IOException
- Overrides:
close
in class java.io.Writer
flush
public void flush()
throws java.io.IOException
- Overrides:
flush
in class java.io.Writer
setEncoding
public void setEncoding(java.lang.String s)
realWriteChars
public void realWriteChars(char[] c,
int off,
int len)
throws java.io.IOException
- Description copied from interface:
CharChunk.CharOutputChannel
- Send the bytes ( usually the internal conversion buffer ).
Expect 8k output if the buffer is full.
- Specified by:
realWriteChars
in interface CharChunk.CharOutputChannel
setConverter
protected void setConverter()
flushBytes
public void flushBytes()
throws java.io.IOException
- Real write - this buffer will be sent to the client
getBytesWritten
public int getBytesWritten()
getCharsWritten
public int getCharsWritten()
isNew
public boolean isNew()
- True if this buffer hasn't been used ( since recycle() ) -
i.e. no chars or bytes have been added to the buffer.
setBufferSize
public void setBufferSize(int size)
reset
public void reset()
getBufferSize
public int getBufferSize()
Copyright © 2001 Apache Software Foundation. All Rights Reserved.