Package org.apache.catalina.ssi
Class ByteArrayServletOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- jakarta.servlet.ServletOutputStream
-
- org.apache.catalina.ssi.ByteArrayServletOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ByteArrayServletOutputStream extends ServletOutputStream
Class that extends ServletOutputStream, used as a wrapper from withinSsiInclude- See Also:
and ByteArrayOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.ByteArrayOutputStreambufOur buffer to hold the stream.
-
Constructor Summary
Constructors Constructor Description ByteArrayServletOutputStream()Construct a new ServletOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisReady()Checks if a non-blocking write will succeed.voidsetWriteListener(WriteListener listener)Sets theWriteListenerfor thisServletOutputStreamand thereby switches to non-blocking IO.byte[]toByteArray()Returns the underlying byte array.voidwrite(int b)Write to our buffer.
-
-
-
Method Detail
-
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 classjava.io.OutputStream- Parameters:
b- The parameter to write
-
isReady
public boolean isReady()
Description copied from class:jakarta.servlet.ServletOutputStreamChecks if a non-blocking write will succeed. If this returnsfalse, it will cause a callback toWriteListener.onWritePossible()when the buffer has emptied. If this method returnsfalseno further data must be written until the container callsWriteListener.onWritePossible().- Specified by:
isReadyin classServletOutputStream- Returns:
trueif data can be written, elsefalse
-
setWriteListener
public void setWriteListener(WriteListener listener)
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
-
-