Package org.glassfish.grizzly.streams
Class BufferedOutput
- java.lang.Object
-
- org.glassfish.grizzly.streams.BufferedOutput
-
- All Implemented Interfaces:
Output
- Direct Known Subclasses:
DefaultStreamWriter.Output,TransformerOutput
public abstract class BufferedOutput extends Object implements Output
- Author:
- oleksiys
-
-
Field Summary
Fields Modifier and Type Field Description protected intbufferSizeprotected AtomicBooleanisClosedprotected CompositeBuffermultiBufferWindowprotected static IntegerZEROprotected static GrizzlyFuture<Integer>ZERO_READY_FUTURE
-
Constructor Summary
Constructors Constructor Description BufferedOutput()BufferedOutput(int bufferSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description GrizzlyFuture<Integer>close(CompletionHandler<Integer> completionHandler)Close theStreamWriterand make sure all data was flushed.voidensureBufferCapacity(int size)GrizzlyFuture<Integer>flush(CompletionHandler<Integer> completionHandler)Make sure that all data that has been written is flushed from the stream to its destination.protected abstract GrizzlyFuture<Integer>flush0(Buffer buffer, CompletionHandler<Integer> completionHandler)BuffergetBuffer()Return the Input'sBuffer.protected intgetBufferedSize()booleanisBuffered()protected abstract BuffernewBuffer(int size)protected abstract voidonClosed()protected abstract BufferreallocateBuffer(Buffer oldBuffer, int size)voidwrite(byte data)voidwrite(Buffer bufferToWrite)
-
-
-
Field Detail
-
ZERO
protected static final Integer ZERO
-
ZERO_READY_FUTURE
protected static final GrizzlyFuture<Integer> ZERO_READY_FUTURE
-
bufferSize
protected final int bufferSize
-
multiBufferWindow
protected CompositeBuffer multiBufferWindow
-
isClosed
protected final AtomicBoolean isClosed
-
-
Method Detail
-
onClosed
protected abstract void onClosed() throws IOException- Throws:
IOException
-
flush0
protected abstract GrizzlyFuture<Integer> flush0(Buffer buffer, CompletionHandler<Integer> completionHandler) throws IOException
- Throws:
IOException
-
newBuffer
protected abstract Buffer newBuffer(int size)
-
write
public void write(byte data) throws IOException- Specified by:
writein interfaceOutput- Throws:
IOException
-
write
public void write(Buffer bufferToWrite) throws IOException
- Specified by:
writein interfaceOutput- Throws:
IOException
-
isBuffered
public boolean isBuffered()
- Specified by:
isBufferedin interfaceOutput
-
getBuffer
public Buffer getBuffer()
Description copied from interface:OutputReturn the Input'sBuffer.
-
ensureBufferCapacity
public void ensureBufferCapacity(int size) throws IOException- Specified by:
ensureBufferCapacityin interfaceOutput- Throws:
IOException
-
flush
public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException
Description copied from interface:OutputMake sure that all data that has been written is flushed from the stream to its destination.- Specified by:
flushin interfaceOutput- Throws:
IOException
-
close
public GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException
Description copied from interface:OutputClose theStreamWriterand make sure all data was flushed.- Specified by:
closein interfaceOutput- Throws:
IOException
-
getBufferedSize
protected int getBufferedSize()
-
-