Class ProcessAwareServerWriter
- java.lang.Object
-
- java.io.Writer
-
- net.officefloor.server.stream.ServerWriter
-
- net.officefloor.server.stream.impl.ProcessAwareServerWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class ProcessAwareServerWriter extends ServerWriter
ProcessState
aware writingServerWriter
.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description ProcessAwareServerWriter(ServerWriter unsafeServerWriter, ManagedObjectContext context)
Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.Writer
append(char c)
java.io.Writer
append(java.lang.CharSequence csq)
java.io.Writer
append(java.lang.CharSequence csq, int start, int end)
void
close()
void
flush()
void
write(byte[] encodedBytes)
Enables writing encoded bytes.void
write(char[] cbuf)
void
write(char[] cbuf, int off, int len)
void
write(int c)
void
write(java.lang.String str)
void
write(java.lang.String str, int off, int len)
void
write(java.nio.ByteBuffer encodedBytes)
Enables writing encoded bytes.void
write(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)
Writes part of theFileChannel
contents.void
write(java.nio.channels.FileChannel file, FileCompleteCallback callback)
Writes the entireFileChannel
contents.
-
-
-
Constructor Detail
-
ProcessAwareServerWriter
public ProcessAwareServerWriter(ServerWriter unsafeServerWriter, ManagedObjectContext context)
Instantiate.- Parameters:
unsafeServerWriter
- UnsafeServerWriter
.context
-ManagedObjectContext
.
-
-
Method Detail
-
write
public void write(byte[] encodedBytes) throws java.io.IOException
Description copied from class:ServerWriter
Enables writing encoded bytes.
Caution should also be taken to ensure that previous written content is not waiting for further surrogate characters.
- Specified by:
write
in classServerWriter
- Parameters:
encodedBytes
- Encoded bytes.- Throws:
java.io.IOException
- If fails to write the bytes.
-
write
public void write(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback) throws java.io.IOException
Description copied from class:ServerWriter
Writes part of the
FileChannel
contents.This is to enable efficient I/O (ie DMA) of writing
FileChannel
content.To write the entire
FileChannel
contents, invokewrite(file, 0, -1)
.Note that the underlying implementation will need to support
FileChannel
efficiencies.Caution should also be taken to ensure that previous written content is not waiting for further surrogate characters.
- Specified by:
write
in classServerWriter
- Parameters:
file
-FileChannel
.position
- Position within theFileChannel
to 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 remainingFileChannel
content from position.callback
- OptionalFileCompleteCallback
. May benull
.- Throws:
java.io.IOException
- If fails to write theFileChannel
content.
-
write
public void write(java.nio.channels.FileChannel file, FileCompleteCallback callback) throws java.io.IOException
Description copied from class:ServerWriter
Writes the entire
FileChannel
contents.This is a convenience method for
write(file, 0, -1)
.Caution should also be taken to ensure that previous written content is not waiting for further surrogate characters.
- Specified by:
write
in classServerWriter
- Parameters:
file
-FileChannel
.callback
- OptionalFileCompleteCallback
. May benull
.- Throws:
java.io.IOException
- If fails to write theFileChannel
content.
-
write
public void write(java.nio.ByteBuffer encodedBytes) throws java.io.IOException
Description copied from class:ServerWriter
Enables writing encoded bytes.
Caution should also be taken to ensure that previous written content is not waiting for further surrogate characters.
- Specified by:
write
in classServerWriter
- Parameters:
encodedBytes
-ByteBuffer
containing the encoded bytes.- Throws:
java.io.IOException
- If fails to write the bytes.
-
write
public void write(int c) throws java.io.IOException
- Overrides:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public void write(char[] cbuf) throws java.io.IOException
- Overrides:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public void write(char[] cbuf, int off, int len) throws java.io.IOException
- Specified by:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public void write(java.lang.String str) throws java.io.IOException
- Overrides:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public void write(java.lang.String str, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
append
public java.io.Writer append(java.lang.CharSequence csq) throws java.io.IOException
- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Throws:
java.io.IOException
-
append
public java.io.Writer append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Throws:
java.io.IOException
-
append
public java.io.Writer append(char c) throws java.io.IOException
- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classjava.io.Writer
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Writer
- Throws:
java.io.IOException
-
-