Top Description Methods
org.glassfish.grizzly.streams

public Interface StreamWriter

extends Stream
Known Direct Implementers
org.glassfish.grizzly.streams.AbstractStreamWriter
Imports
java.io.IOException, java.util.concurrent.TimeUnit, org.glassfish.grizzly.Buffer, .CompletionHandler, .Connection, .GrizzlyFuture, .Transformer

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.
Authors
Ken Cavanaugh, Alexey Stashok

Method Summary

Modifier and TypeMethod and Description
public GrizzlyFuture<Integer>
close(CompletionHandler<Integer> completionHandler)

Close the StreamWriter and make sure all data was flushed.

public <E> GrizzlyFuture<Stream>
encode(Transformer<E, Buffer> encoder, E object)

public <E> GrizzlyFuture<Stream>
encode(Transformer<E, Buffer> encoder, E object, CompletionHandler<Stream> completionHandler)

public GrizzlyFuture<Integer>
flush()

Make sure that all data that has been written is flushed from the stream to its destination.

public GrizzlyFuture<Integer>
flush(CompletionHandler<Integer> completionHandler)

Make sure that all data that has been written is flushed from the stream to its destination.

public Connection<L>

Returns:

the Connection this StreamWriter belongs to.
getConnection
()

Redeclares org.glassfish.grizzly.streams.Stream.getConnection.

Get the Connection this StreamWriter belongs to.

public long

Returns:

the timeout for StreamWriter I/O operations.
getTimeout
(TimeUnit
timeout unit TimeUnit.
timeunit
)

Get the timeout for StreamWriter I/O operations.

public boolean

Returns:

true, if StreamReader has been closed, or false otherwise.
isClosed
()

Returns true, if StreamReader has been closed, or false otherwise.

public void
setTimeout(long
the timeout for StreamWriter I/O operations.
timeout
,
TimeUnit
timeout unit TimeUnit.
timeunit
)

Set the timeout for StreamWriter I/O operations.

public void
writeBoolean(boolean
boolean value.
data
)

Write the boolean value to the StreamWriter.

public void
writeBooleanArray(final boolean[]
array of boolean values.
data
)

Write the array of boolean values to the StreamWriter.

public void
writeBuffer(Buffer buffer)

Write the Buffer to the StreamWriter.

public void
writeByte(byte
byte value.
data
)

Write the byte value to the StreamWriter.

public void
writeByteArray(final byte[]
array of byte values.
data
)

Write the array of byte values to the StreamWriter.

public void
writeByteArray(final byte[]
array of byte values.
data
,
int
array offset to start from.
offset
,
int
number of bytes to write.
length
)

Write the part of array of byte values to the StreamWriter, using specific offset and length values.

public void
writeChar(char
char value.
data
)

Write the char value to the StreamWriter.

public void
writeCharArray(final char[]
array of char values.
data
)

Write the array of char values to the StreamWriter.

public void
writeDouble(double
double value.
data
)

Write the double value to the StreamWriter.

public void
writeDoubleArray(double[]
array of double values.
data
)

Write the array of double values to the StreamWriter.

public void
writeFloat(float
float value.
data
)

Write the float value to the StreamWriter.

public void
writeFloatArray(float[]
array of float values.
data
)

Write the array of float values to the StreamWriter.

public void
writeInt(int
int value.
data
)

Write the int value to the StreamWriter.

public void
writeIntArray(int[]
array of int values.
data
)

Write the array of int values to the StreamWriter.

public void
writeLong(long
long value.
data
)

Write the long value to the StreamWriter.

public void
writeLongArray(long[]
array of long values.
data
)

Write the array of long values to the StreamWriter.

public void
writeShort(short
short value.
data
)

Write the short value to the StreamWriter.

public void
writeShortArray(short[]
array of short values.
data
)

Write the array of short values to the StreamWriter.

Method Detail

closeback to summary
public GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException

Close the StreamWriter and make sure all data was flushed.

encodeback to summary
public <E> GrizzlyFuture<Stream> encode(Transformer<E, Buffer> encoder, E object) throws IOException
encodeback to summary
public <E> GrizzlyFuture<Stream> encode(Transformer<E, Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) throws IOException
flushback to summary
public GrizzlyFuture<Integer> flush() throws IOException

Make sure that all data that has been written is flushed from the stream to its destination.

flushback to summary
public 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.

getConnectionback to summary
public Connection<L> getConnection()

Redeclares org.glassfish.grizzly.streams.Stream.getConnection.

Get the Connection this StreamWriter belongs to.

Returns:Connection<L>

the Connection this StreamWriter belongs to.

Annotations
@Override
getTimeoutback to summary
public long getTimeout(TimeUnit timeunit)

Get the timeout for StreamWriter I/O operations.

Parameters
timeunit:TimeUnit

timeout unit TimeUnit.

Returns:long

the timeout for StreamWriter I/O operations.

isClosedback to summary
public boolean isClosed()

Returns true, if StreamReader has been closed, or false otherwise.

Returns:boolean

true, if StreamReader has been closed, or false otherwise.

setTimeoutback to summary
public void setTimeout(long timeout, TimeUnit timeunit)

Set the timeout for StreamWriter I/O operations.

Parameters
timeout:long

the timeout for StreamWriter I/O operations.

timeunit:TimeUnit

timeout unit TimeUnit.

writeBooleanback to summary
public void writeBoolean(boolean data) throws IOException

Write the boolean value to the StreamWriter.

Parameters
data:boolean

boolean value.

writeBooleanArrayback to summary
public void writeBooleanArray(final boolean[] data) throws IOException

Write the array of boolean values to the StreamWriter.

Parameters
data:boolean[]

array of boolean values.

writeBufferback to summary
public void writeBuffer(Buffer buffer) throws IOException

Write the Buffer to the StreamWriter.

Parameters
buffer:Buffer

Buffer.

writeByteback to summary
public void writeByte(byte data) throws IOException

Write the byte value to the StreamWriter.

Parameters
data:byte

byte value.

writeByteArrayback to summary
public void writeByteArray(final byte[] data) throws IOException

Write the array of byte values to the StreamWriter.

Parameters
data:byte[]

array of byte values.

writeByteArrayback to summary
public void writeByteArray(final byte[] data, int offset, int length) throws IOException

Write the part of array of byte values to the StreamWriter, using specific offset and length values.

Parameters
data:byte[]

array of byte values.

offset:int

array offset to start from.

length:int

number of bytes to write.

writeCharback to summary
public void writeChar(char data) throws IOException

Write the char value to the StreamWriter.

Parameters
data:char

char value.

writeCharArrayback to summary
public void writeCharArray(final char[] data) throws IOException

Write the array of char values to the StreamWriter.

Parameters
data:char[]

array of char values.

writeDoubleback to summary
public void writeDouble(double data) throws IOException

Write the double value to the StreamWriter.

Parameters
data:double

double value.

writeDoubleArrayback to summary
public void writeDoubleArray(double[] data) throws IOException

Write the array of double values to the StreamWriter.

Parameters
data:double[]

array of double values.

writeFloatback to summary
public void writeFloat(float data) throws IOException

Write the float value to the StreamWriter.

Parameters
data:float

float value.

writeFloatArrayback to summary
public void writeFloatArray(float[] data) throws IOException

Write the array of float values to the StreamWriter.

Parameters
data:float[]

array of float values.

writeIntback to summary
public void writeInt(int data) throws IOException

Write the int value to the StreamWriter.

Parameters
data:int

int value.

writeIntArrayback to summary
public void writeIntArray(int[] data) throws IOException

Write the array of int values to the StreamWriter.

Parameters
data:int[]

array of int values.

writeLongback to summary
public void writeLong(long data) throws IOException

Write the long value to the StreamWriter.

Parameters
data:long

long value.

writeLongArrayback to summary
public void writeLongArray(long[] data) throws IOException

Write the array of long values to the StreamWriter.

Parameters
data:long[]

array of long values.

writeShortback to summary
public void writeShort(short data) throws IOException

Write the short value to the StreamWriter.

Parameters
data:short

short value.

writeShortArrayback to summary
public void writeShortArray(short[] data) throws IOException

Write the array of short values to the StreamWriter.

Parameters
data:short[]

array of short values.