org.glassfish.grizzly.streams
Interface StreamWriter

All Superinterfaces:
Closeable
All Known Subinterfaces:
AddressableStreamWriter<A>
All Known Implementing Classes:
AbstractStreamWriter, SSLStreamWriter, StreamWriterDecorator, TCPNIOStreamWriter, UDPNIOStreamWriter

public interface StreamWriter
extends Closeable

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
 Future<Integer> close(CompletionHandler<Integer> completionHandler)
          Close the StreamWriter and make sure all data was flushed.
 Future<Integer> flush()
          Make sure that all data that has been written is flushed from the stream to its destination.
 Future<Integer> flush(CompletionHandler<Integer> completionHandler)
          Make sure that all data that has been written is flushed from the stream to its destination.
 Buffer getBuffer()
          Get the current Buffer, where the StreamWriter buffers output.
 int getBufferSize()
          Get the preferred Buffer size to be used for StreamWriter write operations.
 Connection getConnection()
          Get the Connection this StreamWriter belongs to.
 long getTimeout(TimeUnit timeunit)
          Get the timeout for StreamWriter I/O operations.
 boolean isBlocking()
          Returns the StreamReader mode.
 void setBlocking(boolean isBlocking)
          Sets the StreamReader mode.
 void setBufferSize(int size)
          Set the preferred Buffer size to be used for StreamWriter write operations.
 void setTimeout(long timeout, 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.
 void writeStream(StreamReader stream)
          Puts StreamReader available data to this StreamWriter This method will make possible direct writing from StreamReader, avoiding Buffer copying.
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

isBlocking

boolean isBlocking()
Returns the StreamReader mode. true, if StreamReader is operating in blocking mode, or false otherwise.

Returns:
the StreamReader mode.

setBlocking

void setBlocking(boolean isBlocking)
Sets the StreamReader mode.

Parameters:
isBlocking - true, if StreamReader is operating in blocking mode, or false otherwise.

flush

Future<Integer> flush()
                      throws IOException
Make sure that all data that has been written is flushed from the stream to its destination.

Throws:
IOException

flush

Future<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

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

Throws:
IOException

writeBoolean

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

Parameters:
data - boolean value.
Throws:
IOException

writeByte

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

Parameters:
data - byte value.
Throws:
IOException

writeChar

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

Parameters:
data - char value.
Throws:
IOException

writeShort

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

Parameters:
data - short value.
Throws:
IOException

writeInt

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

Parameters:
data - int value.
Throws:
IOException

writeLong

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

Parameters:
data - long value.
Throws:
IOException

writeFloat

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

Parameters:
data - float value.
Throws:
IOException

writeDouble

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

Parameters:
data - double value.
Throws:
IOException

writeBooleanArray

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

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

writeByteArray

void writeByteArray(byte[] data)
                    throws IOException
Write 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 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:
IOException

writeCharArray

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

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

writeShortArray

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

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

writeIntArray

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

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

writeLongArray

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

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

writeFloatArray

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

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

writeDoubleArray

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

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

writeBuffer

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

Parameters:
buffer - Buffer.
Throws:
IOException

writeStream

void writeStream(StreamReader stream)
                 throws IOException
Puts StreamReader available data to this StreamWriter This method will make possible direct writing from StreamReader, avoiding Buffer copying.

Parameters:
stream - StreamReader
Throws:
IOException

getConnection

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

Returns:
the Connection this StreamWriter belongs to.

getBuffer

Buffer getBuffer()
Get the current Buffer, where the StreamWriter buffers output.

Returns:
the current Buffer, where the StreamWriter buffers output.

getBufferSize

int getBufferSize()
Get the preferred Buffer size to be used for StreamWriter write operations.

Returns:
the preferred Buffer size to be used for StreamWriter write operations.

setBufferSize

void setBufferSize(int size)
Set the preferred Buffer size to be used for StreamWriter write operations.

Parameters:
size - the preferred Buffer size to be used for StreamWriter write operations.

getTimeout

long getTimeout(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,
                TimeUnit timeunit)
Set the timeout for StreamWriter I/O operations.

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


Copyright © 2009 SUN Microsystems. All Rights Reserved.