Package org.glassfish.grizzly.streams
Interface StreamWriter
-
- All Superinterfaces:
AutoCloseable,Closeable,Stream
- All Known Implementing Classes:
AbstractStreamWriter,DefaultStreamWriter,SSLStreamWriter,TransformerStreamWriter
public interface StreamWriter extends Stream
Write the primitive Java types and arrays of primitives to some data sink. This may include internal buffering for efficiency reasons. Note, that StreamWriter implementation may not be thread-safe.- Author:
- Ken Cavanaugh, Alexey Stashok
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description GrizzlyFuture<Integer>close(CompletionHandler<Integer> completionHandler)Close theStreamWriterand make sure all data was flushed.<E> GrizzlyFuture<Stream>encode(Transformer<E,Buffer> encoder, E object)<E> GrizzlyFuture<Stream>encode(Transformer<E,Buffer> encoder, E object, CompletionHandler<Stream> completionHandler)GrizzlyFuture<Integer>flush()Make sure that all data that has been written is flushed from the stream to its destination.GrizzlyFuture<Integer>flush(CompletionHandler<Integer> completionHandler)Make sure that all data that has been written is flushed from the stream to its destination.ConnectiongetConnection()Get theConnectionthis StreamWriter belongs to.longgetTimeout(TimeUnit timeunit)Get the timeout for StreamWriter I/O operations.booleanisClosed()Returns true, if StreamReader has been closed, or false otherwise.voidsetTimeout(long timeout, TimeUnit timeunit)Set the timeout for StreamWriter I/O operations.voidwriteBoolean(boolean data)Write the boolean value to the StreamWriter.voidwriteBooleanArray(boolean[] data)Write the array of boolean values to the StreamWriter.voidwriteBuffer(Buffer buffer)Write theBufferto the StreamWriter.voidwriteByte(byte data)Write the byte value to the StreamWriter.voidwriteByteArray(byte[] data)Write the array of byte values to the StreamWriter.voidwriteByteArray(byte[] data, int offset, int length)Write the part of array of byte values to the StreamWriter, using specific offset and length values.voidwriteChar(char data)Write the char value to the StreamWriter.voidwriteCharArray(char[] data)Write the array of char values to the StreamWriter.voidwriteDouble(double data)Write the double value to the StreamWriter.voidwriteDoubleArray(double[] data)Write the array of double values to the StreamWriter.voidwriteFloat(float data)Write the float value to the StreamWriter.voidwriteFloatArray(float[] data)Write the array of float values to the StreamWriter.voidwriteInt(int data)Write the int value to the StreamWriter.voidwriteIntArray(int[] data)Write the array of int values to the StreamWriter.voidwriteLong(long data)Write the long value to the StreamWriter.voidwriteLongArray(long[] data)Write the array of long values to the StreamWriter.voidwriteShort(short data)Write the short value to the StreamWriter.voidwriteShortArray(short[] data)Write the array of short values to the StreamWriter.
-
-
-
Method Detail
-
isClosed
boolean isClosed()
Returns true, if StreamReader has been closed, or false otherwise.- Returns:
- true, if StreamReader has been closed, or false otherwise.
-
flush
GrizzlyFuture<Integer> flush() throws IOException
Make sure that all data that has been written is flushed from the stream to its destination.- Throws:
IOException
-
flush
GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException
Make sure that all data that has been written is flushed from the stream to its destination.- Throws:
IOException
-
close
GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException
Close theStreamWriterand make sure all data was flushed.- Throws:
IOException
-
writeBoolean
void writeBoolean(boolean data) throws IOExceptionWrite the boolean value to the StreamWriter.- Parameters:
data- boolean value.- Throws:
IOException
-
writeByte
void writeByte(byte data) throws IOExceptionWrite the byte value to the StreamWriter.- Parameters:
data- byte value.- Throws:
IOException
-
writeChar
void writeChar(char data) throws IOExceptionWrite the char value to the StreamWriter.- Parameters:
data- char value.- Throws:
IOException
-
writeShort
void writeShort(short data) throws IOExceptionWrite the short value to the StreamWriter.- Parameters:
data- short value.- Throws:
IOException
-
writeInt
void writeInt(int data) throws IOExceptionWrite the int value to the StreamWriter.- Parameters:
data- int value.- Throws:
IOException
-
writeLong
void writeLong(long data) throws IOExceptionWrite the long value to the StreamWriter.- Parameters:
data- long value.- Throws:
IOException
-
writeFloat
void writeFloat(float data) throws IOExceptionWrite the float value to the StreamWriter.- Parameters:
data- float value.- Throws:
IOException
-
writeDouble
void writeDouble(double data) throws IOExceptionWrite the double value to the StreamWriter.- Parameters:
data- double value.- Throws:
IOException
-
writeBooleanArray
void writeBooleanArray(boolean[] data) throws IOExceptionWrite the array of boolean values to the StreamWriter.- Parameters:
data- array of boolean values.- Throws:
IOException
-
writeByteArray
void writeByteArray(byte[] data) throws IOExceptionWrite the array of byte values to the StreamWriter.- Parameters:
data- array of byte values.- Throws:
IOException
-
writeByteArray
void writeByteArray(byte[] data, int offset, int length) throws IOExceptionWrite the part of array of byte values to the StreamWriter, using specific offset and length values.- Parameters:
data- array of byte values.offset- array offset to start from.length- number of bytes to write.- Throws:
IOException
-
writeCharArray
void writeCharArray(char[] data) throws IOExceptionWrite the array of char values to the StreamWriter.- Parameters:
data- array of char values.- Throws:
IOException
-
writeShortArray
void writeShortArray(short[] data) throws IOExceptionWrite the array of short values to the StreamWriter.- Parameters:
data- array of short values.- Throws:
IOException
-
writeIntArray
void writeIntArray(int[] data) throws IOExceptionWrite the array of int values to the StreamWriter.- Parameters:
data- array of int values.- Throws:
IOException
-
writeLongArray
void writeLongArray(long[] data) throws IOExceptionWrite the array of long values to the StreamWriter.- Parameters:
data- array of long values.- Throws:
IOException
-
writeFloatArray
void writeFloatArray(float[] data) throws IOExceptionWrite the array of float values to the StreamWriter.- Parameters:
data- array of float values.- Throws:
IOException
-
writeDoubleArray
void writeDoubleArray(double[] data) throws IOExceptionWrite the array of double values to the StreamWriter.- Parameters:
data- array of double values.- Throws:
IOException
-
writeBuffer
void writeBuffer(Buffer buffer) throws IOException
Write theBufferto the StreamWriter.- Parameters:
buffer-Buffer.- Throws:
IOException
-
encode
<E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder, E object) throws IOException
- Throws:
IOException
-
encode
<E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) throws IOException
- Throws:
IOException
-
getConnection
Connection getConnection()
Get theConnectionthis StreamWriter belongs to.- Specified by:
getConnectionin interfaceStream- Returns:
- the
Connectionthis StreamWriter belongs to.
-
getTimeout
long getTimeout(TimeUnit timeunit)
Get the timeout for StreamWriter I/O operations.- Parameters:
timeunit- timeout unitTimeUnit.- Returns:
- the timeout for StreamWriter I/O operations.
-
-