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 int
bufferSize
protected AtomicBoolean
isClosed
protected CompositeBuffer
multiBufferWindow
protected static Integer
ZERO
protected 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 theStreamWriter
and make sure all data was flushed.void
ensureBufferCapacity(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)
Buffer
getBuffer()
Return the Input'sBuffer
.protected int
getBufferedSize()
boolean
isBuffered()
protected abstract Buffer
newBuffer(int size)
protected abstract void
onClosed()
protected abstract Buffer
reallocateBuffer(Buffer oldBuffer, int size)
void
write(byte data)
void
write(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:
write
in interfaceOutput
- Throws:
IOException
-
write
public void write(Buffer bufferToWrite) throws IOException
- Specified by:
write
in interfaceOutput
- Throws:
IOException
-
isBuffered
public boolean isBuffered()
- Specified by:
isBuffered
in interfaceOutput
-
getBuffer
public Buffer getBuffer()
Description copied from interface:Output
Return the Input'sBuffer
.
-
ensureBufferCapacity
public void ensureBufferCapacity(int size) throws IOException
- Specified by:
ensureBufferCapacity
in interfaceOutput
- Throws:
IOException
-
flush
public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException
Description copied from interface:Output
Make sure that all data that has been written is flushed from the stream to its destination.- Specified by:
flush
in interfaceOutput
- Throws:
IOException
-
close
public GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException
Description copied from interface:Output
Close theStreamWriter
and make sure all data was flushed.- Specified by:
close
in interfaceOutput
- Throws:
IOException
-
getBufferedSize
protected int getBufferedSize()
-
-