org.glassfish.grizzly.streams
Interface StreamWriter

All Superinterfaces:
java.io.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
 GrizzlyFuture<java.lang.Integer> close(CompletionHandler<java.lang.Integer> completionHandler)
          Close the StreamWriter and 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<java.lang.Integer> flush()
          Make sure that all data that has been written is flushed from the stream to its destination.
 GrizzlyFuture<java.lang.Integer> flush(CompletionHandler<java.lang.Integer> completionHandler)
          Make sure that all data that has been written is flushed from the stream to its destination.
 Connection getConnection()
          Get the Connection this StreamWriter belongs to.
 long getTimeout(java.util.concurrent.TimeUnit timeunit)
          Get the timeout for StreamWriter I/O operations.
 boolean isClosed()
          Returns true, if StreamReader has been closed, or false otherwise.
 void setTimeout(long timeout, java.util.concurrent.TimeUnit timeunit)
          Set the timeout for StreamWriter I/O operations.
 void writeBoolean(boolean data)
          Write the boolean value to the StreamWriter.
 void writeBooleanArray(boolean[] data)
          Write the array of boolean values to the StreamWriter.
 void writeBuffer(Buffer buffer)
          Write the Buffer to the StreamWriter.
 void writeByte(byte data)
          Write the byte value to the StreamWriter.
 void writeByteArray(byte[] data)
          Write the array of byte values to the StreamWriter.
 void writeByteArray(byte[] data, int offset, int length)
          Write the part of array of byte values to the StreamWriter, using specific offset and length values.
 void writeChar(char data)
          Write the char value to the StreamWriter.
 void writeCharArray(char[] data)
          Write the array of char values to the StreamWriter.
 void writeDouble(double data)
          Write the double value to the StreamWriter.
 void writeDoubleArray(double[] data)
          Write the array of double values to the StreamWriter.
 void writeFloat(float data)
          Write the float value to the StreamWriter.
 void writeFloatArray(float[] data)
          Write the array of float values to the StreamWriter.
 void writeInt(int data)
          Write the int value to the StreamWriter.
 void writeIntArray(int[] data)
          Write the array of int values to the StreamWriter.
 void writeLong(long data)
          Write the long value to the StreamWriter.
 void writeLongArray(long[] data)
          Write the array of long values to the StreamWriter.
 void writeShort(short data)
          Write the short value to the StreamWriter.
 void writeShortArray(short[] data)
          Write the array of short values to the StreamWriter.
 
Methods inherited from interface java.io.Closeable
close
 

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<java.lang.Integer> flush()
                                       throws java.io.IOException
Make sure that all data that has been written is flushed from the stream to its destination.

Throws:
java.io.IOException

flush

GrizzlyFuture<java.lang.Integer> flush(CompletionHandler<java.lang.Integer> completionHandler)
                                       throws java.io.IOException
Make sure that all data that has been written is flushed from the stream to its destination.

Throws:
java.io.IOException

close

GrizzlyFuture<java.lang.Integer> close(CompletionHandler<java.lang.Integer> completionHandler)
                                       throws java.io.IOException
Close the StreamWriter and make sure all data was flushed.

Throws:
java.io.IOException

writeBoolean

void writeBoolean(boolean data)
                  throws java.io.IOException
Write the boolean value to the StreamWriter.

Parameters:
data - boolean value.
Throws:
java.io.IOException

writeByte

void writeByte(byte data)
               throws java.io.IOException
Write the byte value to the StreamWriter.

Parameters:
data - byte value.
Throws:
java.io.IOException

writeChar

void writeChar(char data)
               throws java.io.IOException
Write the char value to the StreamWriter.

Parameters:
data - char value.
Throws:
java.io.IOException

writeShort

void writeShort(short data)
                throws java.io.IOException
Write the short value to the StreamWriter.

Parameters:
data - short value.
Throws:
java.io.IOException

writeInt

void writeInt(int data)
              throws java.io.IOException
Write the int value to the StreamWriter.

Parameters:
data - int value.
Throws:
java.io.IOException

writeLong

void writeLong(long data)
               throws java.io.IOException
Write the long value to the StreamWriter.

Parameters:
data - long value.
Throws:
java.io.IOException

writeFloat

void writeFloat(float data)
                throws java.io.IOException
Write the float value to the StreamWriter.

Parameters:
data - float value.
Throws:
java.io.IOException

writeDouble

void writeDouble(double data)
                 throws java.io.IOException
Write the double value to the StreamWriter.

Parameters:
data - double value.
Throws:
java.io.IOException

writeBooleanArray

void writeBooleanArray(boolean[] data)
                       throws java.io.IOException
Write the array of boolean values to the StreamWriter.

Parameters:
data - array of boolean values.
Throws:
java.io.IOException

writeByteArray

void writeByteArray(byte[] data)
                    throws java.io.IOException
Write the array of byte values to the StreamWriter.

Parameters:
data - array of byte values.
Throws:
java.io.IOException

writeByteArray

void writeByteArray(byte[] data,
                    int offset,
                    int length)
                    throws java.io.IOException
Write 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:
java.io.IOException

writeCharArray

void writeCharArray(char[] data)
                    throws java.io.IOException
Write the array of char values to the StreamWriter.

Parameters:
data - array of char values.
Throws:
java.io.IOException

writeShortArray

void writeShortArray(short[] data)
                     throws java.io.IOException
Write the array of short values to the StreamWriter.

Parameters:
data - array of short values.
Throws:
java.io.IOException

writeIntArray

void writeIntArray(int[] data)
                   throws java.io.IOException
Write the array of int values to the StreamWriter.

Parameters:
data - array of int values.
Throws:
java.io.IOException

writeLongArray

void writeLongArray(long[] data)
                    throws java.io.IOException
Write the array of long values to the StreamWriter.

Parameters:
data - array of long values.
Throws:
java.io.IOException

writeFloatArray

void writeFloatArray(float[] data)
                     throws java.io.IOException
Write the array of float values to the StreamWriter.

Parameters:
data - array of float values.
Throws:
java.io.IOException

writeDoubleArray

void writeDoubleArray(double[] data)
                      throws java.io.IOException
Write the array of double values to the StreamWriter.

Parameters:
data - array of double values.
Throws:
java.io.IOException

writeBuffer

void writeBuffer(Buffer buffer)
                 throws java.io.IOException
Write the Buffer to the StreamWriter.

Parameters:
buffer - Buffer.
Throws:
java.io.IOException

encode

<E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder,
                                 E object)
                             throws java.io.IOException
Throws:
java.io.IOException

encode

<E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder,
                                 E object,
                                 CompletionHandler<Stream> completionHandler)
                             throws java.io.IOException
Throws:
java.io.IOException

getConnection

Connection getConnection()
Get the Connection this StreamWriter belongs to.

Specified by:
getConnection in interface Stream
Returns:
the Connection this StreamWriter belongs to.

getTimeout

long getTimeout(java.util.concurrent.TimeUnit timeunit)
Get the timeout for StreamWriter I/O operations.

Parameters:
timeunit - timeout unit TimeUnit.
Returns:
the timeout for StreamWriter I/O operations.

setTimeout

void setTimeout(long timeout,
                java.util.concurrent.TimeUnit timeunit)
Set the timeout for StreamWriter I/O operations.

Parameters:
timeout - the timeout for StreamWriter I/O operations.
timeunit - timeout unit TimeUnit.


Copyright © 2011 Oracle Corpration. All Rights Reserved.