|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.streams.AbstractStreamWriter
public abstract class AbstractStreamWriter
Write the primitive Java type to the current ByteBuffer. If it doesn't fit, call the BufferHandler, and write to the result, which becomes the new current ByteBuffer. Arrays will be written across multiple ByteBuffers if necessary, but all primitives will be written to a single ByteBuffer.
| Nested Class Summary | |
|---|---|
static class |
AbstractStreamWriter.DisposeBufferCompletionHandler
|
| Field Summary | |
|---|---|
protected Buffer |
buffer
|
protected int |
bufferSize
|
protected static Integer |
ZERO
|
protected static Future<Integer> |
ZERO_READY_FUTURE
|
| Constructor Summary | |
|---|---|
protected |
AbstractStreamWriter()
|
protected |
AbstractStreamWriter(Connection connection)
Create a new ByteBufferWriter. |
| Method Summary | |
|---|---|
void |
close()
|
Future<Integer> |
close(CompletionHandler<Integer> completionHandler)
Close the StreamWriter and make sure all data was flushed. |
protected abstract Future<Integer> |
close0(CompletionHandler<Integer> completionHandler)
|
void |
ensure(int size)
Ensure that the requested amount of space is available |
Future<Integer> |
flush()
Cause the overflow handler to be called even if buffer is not full. |
Future<Integer> |
flush(CompletionHandler<Integer> completionHandler)
Cause the overflow handler to be called even if buffer is not full. |
protected abstract Future<Integer> |
flush0(Buffer buffer,
CompletionHandler<Integer> completionHandler)
|
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. |
protected Buffer |
newBuffer(int size)
|
protected Future<Integer> |
overflow()
|
protected Future<Integer> |
overflow(CompletionHandler<Integer> completionHandler)
|
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 |
setConnection(Connection connection)
|
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 b)
Write the Buffer to the StreamWriter. |
protected void |
writeBuffer(Buffer b,
CompletionHandler completionHandler)
|
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 streamReader)
Puts StreamReader available data to this StreamWriter
This method will make possible direct writing from StreamReader,
avoiding Buffer copying. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Integer ZERO
protected static final Future<Integer> ZERO_READY_FUTURE
protected int bufferSize
protected Buffer buffer
| Constructor Detail |
|---|
protected AbstractStreamWriter()
protected AbstractStreamWriter(Connection connection)
| Method Detail |
|---|
public boolean isBlocking()
StreamReader mode.
true, if StreamReader is operating in blocking mode, or
false otherwise.
isBlocking in interface StreamWriterStreamReader mode.public void setBlocking(boolean isBlocking)
StreamReader mode.
setBlocking in interface StreamWriterisBlocking - true, if StreamReader is operating in
blocking mode, or false otherwise.
protected Future<Integer> overflow()
throws IOException
IOException
protected Future<Integer> overflow(CompletionHandler<Integer> completionHandler)
throws IOException
IOException
public Future<Integer> flush()
throws IOException
flush in interface StreamWriterIOException
public Future<Integer> flush(CompletionHandler<Integer> completionHandler)
throws IOException
flush in interface StreamWriterIOException
public void close()
throws IOException
close in interface CloseableIOException
public Future<Integer> close(CompletionHandler<Integer> completionHandler)
throws IOException
StreamWriter and make sure all data was flushed.
close in interface StreamWriterIOException
public void ensure(int size)
throws IOException
IOException
public void writeBuffer(Buffer b)
throws IOException
Buffer to the StreamWriter.
writeBuffer in interface StreamWriterb - Buffer.
IOException
protected void writeBuffer(Buffer b,
CompletionHandler completionHandler)
throws IOException
IOException
public void writeStream(StreamReader streamReader)
throws IOException
StreamReader available data to this StreamWriter
This method will make possible direct writing from StreamReader,
avoiding Buffer copying.
writeStream in interface StreamWriterstreamReader - StreamReader
IOException
public void writeBoolean(boolean data)
throws IOException
writeBoolean in interface StreamWriterdata - boolean value.
IOException
public void writeByte(byte data)
throws IOException
writeByte in interface StreamWriterdata - byte value.
IOException
public void writeChar(char data)
throws IOException
writeChar in interface StreamWriterdata - char value.
IOException
public void writeShort(short data)
throws IOException
writeShort in interface StreamWriterdata - short value.
IOException
public void writeInt(int data)
throws IOException
StreamWriter
writeInt in interface StreamWriterdata - int value.
IOException
public void writeLong(long data)
throws IOException
writeLong in interface StreamWriterdata - long value.
IOException
public void writeFloat(float data)
throws IOException
writeFloat in interface StreamWriterdata - float value.
IOException
public void writeDouble(double data)
throws IOException
writeDouble in interface StreamWriterdata - double value.
IOException
public void writeBooleanArray(boolean[] data)
throws IOException
writeBooleanArray in interface StreamWriterdata - array of boolean values.
IOException
public void writeByteArray(byte[] data)
throws IOException
writeByteArray in interface StreamWriterdata - array of byte values.
IOException
public void writeByteArray(byte[] data,
int offset,
int length)
throws IOException
writeByteArray in interface StreamWriterdata - array of byte values.offset - array offset to start from.length - number of bytes to write.
IOException
public void writeCharArray(char[] data)
throws IOException
writeCharArray in interface StreamWriterdata - array of char values.
IOException
public void writeShortArray(short[] data)
throws IOException
writeShortArray in interface StreamWriterdata - array of short values.
IOException
public void writeIntArray(int[] data)
throws IOException
writeIntArray in interface StreamWriterdata - array of int values.
IOException
public void writeLongArray(long[] data)
throws IOException
writeLongArray in interface StreamWriterdata - array of long values.
IOException
public void writeFloatArray(float[] data)
throws IOException
writeFloatArray in interface StreamWriterdata - array of float values.
IOException
public void writeDoubleArray(double[] data)
throws IOException
writeDoubleArray in interface StreamWriterdata - array of double values.
IOExceptionpublic Connection getConnection()
Connection this StreamWriter belongs to.
getConnection in interface StreamWriterConnection this StreamWriter belongs to.public void setConnection(Connection connection)
public Buffer getBuffer()
Buffer, where the StreamWriter buffers
output.
getBuffer in interface StreamWriterBuffer, where the StreamWriter buffers
output.protected Buffer newBuffer(int size)
public int getBufferSize()
Buffer size to be used for StreamWriter
write operations.
getBufferSize in interface StreamWriterBuffer size to be used for StreamWriter
write operations.public void setBufferSize(int size)
Buffer size to be used for StreamWriter
write operations.
setBufferSize in interface StreamWritersize - the preferred Buffer size to be used for
StreamWriter write operations.public long getTimeout(TimeUnit timeunit)
getTimeout in interface StreamWritertimeunit - timeout unit TimeUnit.
public void setTimeout(long timeout,
TimeUnit timeunit)
setTimeout in interface StreamWritertimeout - the timeout for StreamWriter I/O operations.timeunit - timeout unit TimeUnit.
protected abstract Future<Integer> flush0(Buffer buffer,
CompletionHandler<Integer> completionHandler)
throws IOException
IOException
protected abstract Future<Integer> close0(CompletionHandler<Integer> completionHandler)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||