Package org.apache.catalina.connector
Class OutputBuffer
java.lang.Object
java.io.Writer
org.apache.catalina.connector.OutputBuffer
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
The buffer used by Tomcat response. This is a derivative of the Tomcat 3.3 OutputBuffer, with the removal of some of
 the state handling (which in Coyote is mostly the Processor's responsibility).
- Author:
- Costin Manolache, Remy Maucherat
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected C2BConverterCurrent char to byte converter.static final int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidappend(byte[] src, int off, int len) Add data to the buffer.voidappend(char[] src, int off, int len) Add data to the buffer.voidappend(ByteBuffer from) voidvoidvoidclose()Close the output buffer.protected voiddoFlush(boolean realFlush) Flush bytes or chars contained in the buffer.voidflush()Flush bytes or chars contained in the buffer.intlongbooleanbooleanisClosed()Is the response output closed ?booleanisNew()Has this buffer been used at all?booleanisReady()booleanIs the response output suspended ?voidrealWriteBytes(ByteBuffer buf) Sends the buffer data to the client output, checking the state of Response and calling the right interceptors.voidrealWriteChars(CharBuffer from) Convert the chars to bytes, then send the data to the client.voidrecycle()Recycle the output buffer.voidreset()voidreset(boolean resetWriterStreamFlags) voidsetBufferSize(int size) voidsetResponse(Response coyoteResponse) Associated Coyote response.voidsetSuspended(boolean suspended) Set the suspended flag.voidsetWriteListener(WriteListener listener) voidwrite(byte[] b, int off, int len) voidwrite(char[] c) voidwrite(char[] c, int off, int len) voidwrite(int c) voidvoidAppend a string to the buffervoidwrite(ByteBuffer from) voidwriteByte(int b) Methods inherited from class java.io.Writerappend, append, append, nullWriter
- 
Field Details- 
DEFAULT_BUFFER_SIZEpublic static final int DEFAULT_BUFFER_SIZE- See Also:
 
- 
convCurrent char to byte converter.
 
- 
- 
Constructor Details- 
OutputBufferpublic OutputBuffer(int size) Create the buffer with the specified initial size.- Parameters:
- size- Buffer size to use
 
 
- 
- 
Method Details- 
setResponseAssociated Coyote response.- Parameters:
- coyoteResponse- Associated Coyote response
 
- 
isSuspendedpublic boolean isSuspended()Is the response output suspended ?- Returns:
- suspended flag value
 
- 
setSuspendedpublic void setSuspended(boolean suspended) Set the suspended flag.- Parameters:
- suspended- New suspended flag value
 
- 
isClosedpublic boolean isClosed()Is the response output closed ?- Returns:
- closed flag value
 
- 
recyclepublic void recycle()Recycle the output buffer.
- 
closeClose the output buffer. This tries to calculate the response size if the response has not been committed yet.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Writer
- Throws:
- IOException- An underlying IOException occurred
 
- 
flushFlush bytes or chars contained in the buffer.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin class- Writer
- Throws:
- IOException- An underlying IOException occurred
 
- 
doFlushFlush bytes or chars contained in the buffer.- Parameters:
- realFlush-- trueif this should also cause a real network flush
- Throws:
- IOException- An underlying IOException occurred
 
- 
realWriteBytesSends the buffer data to the client output, checking the state of Response and calling the right interceptors.- Parameters:
- buf- the ByteBuffer to be written to the response
- Throws:
- IOException- An underlying IOException occurred
 
- 
write- Throws:
- IOException
 
- 
write- Throws:
- IOException
 
- 
writeByte- Throws:
- IOException
 
- 
realWriteCharsConvert the chars to bytes, then send the data to the client.- Parameters:
- from- Char buffer to be written to the response
- Throws:
- IOException- An underlying IOException occurred
 
- 
write- Overrides:
- writein class- Writer
- Throws:
- IOException
 
- 
write- Overrides:
- writein class- Writer
- Throws:
- IOException
 
- 
write- Specified by:
- writein class- Writer
- Throws:
- IOException
 
- 
writeAppend a string to the buffer- Overrides:
- writein class- Writer
- Throws:
- IOException
 
- 
write- Overrides:
- writein class- Writer
- Throws:
- IOException
 
- 
checkConverter- Throws:
- IOException
 
- 
getContentWrittenpublic long getContentWritten()
- 
isNewpublic boolean isNew()Has this buffer been used at all?- Returns:
- true if no chars or bytes have been added to the buffer since the last call to recycle()
 
- 
setBufferSizepublic void setBufferSize(int size) 
- 
resetpublic void reset()
- 
resetpublic void reset(boolean resetWriterStreamFlags) 
- 
getBufferSizepublic int getBufferSize()
- 
isReadypublic boolean isReady()
- 
setWriteListener
- 
isBlockingpublic boolean isBlocking()
- 
checkRegisterForWritepublic void checkRegisterForWrite()
- 
appendAdd data to the buffer.- Parameters:
- src- Bytes array
- off- Offset
- len- Length
- Throws:
- IOException- Writing overflow data to the output channel failed
 
- 
appendAdd data to the buffer.- Parameters:
- src- Char array
- off- Offset
- len- Length
- Throws:
- IOException- Writing overflow data to the output channel failed
 
- 
append- Throws:
- IOException
 
 
-