Class BufferedBodyOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.glassfish.jersey.jdk.connector.internal.BodyOutputStream
-
- org.glassfish.jersey.jdk.connector.internal.BufferedBodyOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
class BufferedBodyOutputStream extends BodyOutputStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BufferedBodyOutputStream.Mode
-
Field Summary
Fields Modifier and Type Field Description private java.io.ByteArrayOutputStream
buffer
private BufferedBodyOutputStream.Mode
mode
-
Constructor Summary
Constructors Constructor Description BufferedBodyOutputStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isReady()
Returns true if data can be written without blocking else returns false.void
setWriteListener(WriteListener writeListener)
Instructs the stream to invoke the providedWriteListener
when it is possible to write.(package private) java.nio.ByteBuffer
toBuffer()
void
write(int b)
-
-
-
Field Detail
-
buffer
private final java.io.ByteArrayOutputStream buffer
-
mode
private volatile BufferedBodyOutputStream.Mode mode
-
-
Method Detail
-
setWriteListener
public void setWriteListener(WriteListener writeListener)
Description copied from class:BodyOutputStream
Instructs the stream to invoke the providedWriteListener
when it is possible to write. If the stream is in UNDECIDED state, invoking this method will commit the stream to ASYNCHRONOUS mode.- Specified by:
setWriteListener
in classBodyOutputStream
- Parameters:
writeListener
- theWriteListener
that should be notified when it's possible to write.
-
isReady
public boolean isReady()
Description copied from class:BodyOutputStream
Returns true if data can be written without blocking else returns false. If the stream is in ASYNCHRONOUS mode and the user attempts to write to it even though this method returns false, anIllegalStateException
is thrown.- Specified by:
isReady
in classBodyOutputStream
- Returns:
true
if data can be obtained without blocking, otherwise returnsfalse
.
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
toBuffer
java.nio.ByteBuffer toBuffer()
-
-