Class BufferPoolServerOutputStream<B>
java.lang.Object
java.io.OutputStream
net.officefloor.server.stream.ServerOutputStream
net.officefloor.server.stream.impl.BufferPoolServerOutputStream<B>
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionBufferPoolServerOutputStream(StreamBufferPool<B> bufferPool) Instantiate.BufferPoolServerOutputStream(StreamBufferPool<B> bufferPool, CloseHandler closeHandler) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears thisOutputStreamand releases theStreamBufferinstances.voidclose()voidflush()Obtains the headStreamBufferinstances used by thisServerOutputStream.longObtains the content length of output data.getServerWriter(Charset charset) Obtains theServerWriter.voidwrite(byte[] bytes, int off, int len) voidwrite(int b) voidwrite(ByteBuffer buffer) Writes aByteBuffer.voidwrite(FileChannel file, long position, long count, FileCompleteCallback callback) Writes part of theFileChannelcontents.voidwrite(FileChannel file, FileCompleteCallback callback) Writes the entireFileChannelcontents.Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
BufferPoolServerOutputStream
Instantiate.- Parameters:
bufferPool-StreamBufferPool.closeHandler-CloseHandler.
-
BufferPoolServerOutputStream
Instantiate.- Parameters:
bufferPool-StreamBufferPool.
-
-
Method Details
-
getServerWriter
Obtains theServerWriter.- Parameters:
charset-Charsetfor writing outStringdata.- Returns:
ServerWriter.- Throws:
IOException- ShouldServerOutputStreambe closed.
-
getContentLength
public long getContentLength()Obtains the content length of output data.- Returns:
- Content length of output data.
-
getBuffers
Obtains the headStreamBufferinstances used by thisServerOutputStream.- Returns:
StreamBufferinstances used by thisServerOutputStream.
-
clear
Clears thisOutputStreamand releases theStreamBufferinstances.- Throws:
IOException- If failure in clearingOutputStream.
-
write
Description copied from class:ServerOutputStreamWrites a
ByteBuffer.This is to enable efficient I/O of writing content (typically cached).
- Specified by:
writein classServerOutputStream- Parameters:
buffer-ByteBufferthat should never change its content.- Throws:
IOException- If fails to write theByteBuffer.
-
write
public void write(FileChannel file, long position, long count, FileCompleteCallback callback) throws IOException Description copied from class:ServerOutputStreamWrites part of the
FileChannelcontents.This is to enable efficient I/O (ie DMA) of writing
FileChannelcontent.To write the entire
FileChannelcontents, invokewrite(file, 0, -1).Note that the underlying implementation will need to support
FileChannelefficiencies.- Specified by:
writein classServerOutputStream- Parameters:
file-FileChannel.position- Position within theFileChannelto start writing content. Must be non-negative number.count- Count of bytes to write from theFileChannel. A negative value (typically-1) indicates to write the remainingFileChannelcontent from position.callback- OptionalFileCompleteCallback. May benull.- Throws:
IOException- If fails to write theFileChannelcontent.
-
write
Description copied from class:ServerOutputStreamWrites the entire
FileChannelcontents.This is a convenience method for
write(file, 0, -1).- Specified by:
writein classServerOutputStream- Parameters:
file-FileChannel.callback- OptionalFileCompleteCallback. May benull.- Throws:
IOException- If fails to write theFileChannelcontent.
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-