public abstract class AbstractStreamWriter extends Object implements StreamWriter
Modifier and Type | Class and Description |
---|---|
static class |
AbstractStreamWriter.DisposeBufferCompletionHandler |
Modifier and Type | Field and Description |
---|---|
protected boolean |
isOutputBuffered |
protected static Logger |
logger |
protected Output |
output |
protected static Integer |
ZERO |
protected static GrizzlyFuture<Integer> |
ZERO_READY_FUTURE |
Modifier | Constructor and Description |
---|---|
protected |
AbstractStreamWriter(Connection connection,
Output streamOutput)
Create a new ByteBufferWriter.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
GrizzlyFuture<Integer> |
close(CompletionHandler<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<Integer> |
flush()
Cause the overflow handler to be called even if buffer is not full.
|
GrizzlyFuture<Integer> |
flush(CompletionHandler<Integer> completionHandler)
Cause the overflow handler to be called even if buffer is not full.
|
Connection |
getConnection()
Get the
Connection this StreamWriter belongs to. |
long |
getTimeout(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,
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. |
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.
|
protected static final Logger logger
protected static final Integer ZERO
protected static final GrizzlyFuture<Integer> ZERO_READY_FUTURE
protected final boolean isOutputBuffered
protected final Output output
protected AbstractStreamWriter(Connection connection, Output streamOutput)
public GrizzlyFuture<Integer> flush() throws IOException
flush
in interface StreamWriter
IOException
public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException
flush
in interface StreamWriter
IOException
public boolean isClosed()
isClosed
in interface StreamWriter
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException
StreamWriter
and make sure all data was flushed.close
in interface StreamWriter
IOException
public void writeBuffer(Buffer b) throws IOException
Buffer
to the StreamWriter.writeBuffer
in interface StreamWriter
b
- Buffer
.IOException
public void writeBoolean(boolean data) throws IOException
writeBoolean
in interface StreamWriter
data
- boolean value.IOException
public void writeByte(byte data) throws IOException
writeByte
in interface StreamWriter
data
- byte value.IOException
public void writeChar(char data) throws IOException
writeChar
in interface StreamWriter
data
- char value.IOException
public void writeShort(short data) throws IOException
writeShort
in interface StreamWriter
data
- short value.IOException
public void writeInt(int data) throws IOException
StreamWriter
writeInt
in interface StreamWriter
data
- int value.IOException
public void writeLong(long data) throws IOException
writeLong
in interface StreamWriter
data
- long value.IOException
public void writeFloat(float data) throws IOException
writeFloat
in interface StreamWriter
data
- float value.IOException
public void writeDouble(double data) throws IOException
writeDouble
in interface StreamWriter
data
- double value.IOException
public void writeBooleanArray(boolean[] data) throws IOException
writeBooleanArray
in interface StreamWriter
data
- array of boolean values.IOException
public void writeByteArray(byte[] data) throws IOException
writeByteArray
in interface StreamWriter
data
- array of byte values.IOException
public void writeByteArray(byte[] data, int offset, int length) throws IOException
writeByteArray
in interface StreamWriter
data
- 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 StreamWriter
data
- array of char values.IOException
public void writeShortArray(short[] data) throws IOException
writeShortArray
in interface StreamWriter
data
- array of short values.IOException
public void writeIntArray(int[] data) throws IOException
writeIntArray
in interface StreamWriter
data
- array of int values.IOException
public void writeLongArray(long[] data) throws IOException
writeLongArray
in interface StreamWriter
data
- array of long values.IOException
public void writeFloatArray(float[] data) throws IOException
writeFloatArray
in interface StreamWriter
data
- array of float values.IOException
public void writeDoubleArray(double[] data) throws IOException
writeDoubleArray
in interface StreamWriter
data
- array of double values.IOException
public <E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder, E object) throws IOException
encode
in interface StreamWriter
IOException
public <E> GrizzlyFuture<Stream> encode(Transformer<E,Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) throws IOException
encode
in interface StreamWriter
IOException
public Connection getConnection()
Connection
this StreamWriter belongs to.getConnection
in interface Stream
getConnection
in interface StreamWriter
Connection
this StreamWriter belongs to.public long getTimeout(TimeUnit timeunit)
getTimeout
in interface StreamWriter
timeunit
- timeout unit TimeUnit
.public void setTimeout(long timeout, TimeUnit timeunit)
setTimeout
in interface StreamWriter
timeout
- the timeout for StreamWriter I/O operations.timeunit
- timeout unit TimeUnit
.Copyright © 2017–2019 Oracle Corporation. All rights reserved.