Class ByteArrayServletOutputStream
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.apache.catalina.ssi.ByteArrayServletOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Class that extends ServletOutputStream, used as a wrapper from within
SsiInclude- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ByteArrayOutputStreamOur buffer to hold the stream. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisReady()Returnstrueif it is allowable to call any method that may write data (e.g.voidsetWriteListener(WriteListener listener) Sets theWriteListenerfor thisServletOutputStreamand thereby switches to non-blocking IO.byte[]Returns the underlying byte array.voidwrite(int b) Write to our buffer.Methods inherited from class ServletOutputStream
close, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, writeMethods inherited from class OutputStream
flush, nullOutputStream, write, write
-
Field Details
-
buf
Our buffer to hold the stream.
-
-
Constructor Details
-
ByteArrayServletOutputStream
public ByteArrayServletOutputStream()Construct a new ServletOutputStream.
-
-
Method Details
-
toByteArray
public byte[] toByteArray()Returns the underlying byte array.- Returns:
- the byte array
-
write
public void write(int b) Write to our buffer.- Specified by:
writein classOutputStream- Parameters:
b- The parameter to write
-
isReady
public boolean isReady()Description copied from class:jakarta.servlet.ServletOutputStreamReturnstrueif it is allowable to call any method that may write data (e.g.write(),print()orflush). In blocking mode, this method will always returntrue, but a subsequent call to a method that writes data may block. In non-blocking mode this method may returnfalse, in which case it is illegal to call a method that writes data and anIllegalStateExceptionMUST be thrown. WhenWriteListener.onWritePossible()is called, a call to this method that returnedtrueis implicit.If this method returns
falseand aWriteListenerhas been set viaServletOutputStream.setWriteListener(WriteListener), then container will subsequently invokeWriteListener.onWritePossible()once a write operation becomes possible without blocking. Other than the initial call,WriteListener.onWritePossible()will only be called if and only if this method is called and returns false.- Specified by:
isReadyin classServletOutputStream- Returns:
trueif data can be written without blocking, otherwise returnsfalse.
-
setWriteListener
Description copied from class:jakarta.servlet.ServletOutputStreamSets theWriteListenerfor thisServletOutputStreamand thereby switches to non-blocking IO. It is only valid to switch to non-blocking IO within async processing or HTTP upgrade processing.- Specified by:
setWriteListenerin classServletOutputStream- Parameters:
listener- The non-blocking IO write listener
-