Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.streams

public abstract Class AbstractStreamWriter

extends Object
implements StreamWriter
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.streams.StreamWriter, org.glassfish.grizzly.streams.Stream, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.glassfish.grizzly.streams.TransformerStreamWriter, org.glassfish.grizzly.nio.transport.DefaultStreamWriter
Imports
java.io.IOException, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicBoolean, java.util.logging.Logger, org.glassfish.grizzly.Buffer, .CompletionHandler, .Connection, .Grizzly, .GrizzlyFuture, .TransformationException, .TransformationResult, .TransformationResult.Status, .Transformer, org.glassfish.grizzly.impl.ReadyFutureImpl, org.glassfish.grizzly.memory.Buffers

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.
Author
Ken Cavanaugh

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final Connection<L>
private final AtomicBoolean
protected final boolean
protected static final Logger
protected final Output
private long
protected static final Integer
protected static final GrizzlyFuture<Integer>

Constructor Summary

AccessConstructor and Description
protected
AbstractStreamWriter(final Connection<L> connection, Output streamOutput)

Create a new ByteBufferWriter.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

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

Implements org.glassfish.grizzly.streams.StreamWriter.close.

Close the StreamWriter and make sure all data was flushed.

public <E> GrizzlyFuture<Stream>
public <E> GrizzlyFuture<Stream>
public GrizzlyFuture<Integer>
flush()

Implements org.glassfish.grizzly.streams.StreamWriter.flush.

Cause the overflow handler to be called even if buffer is not full.

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

Implements org.glassfish.grizzly.streams.StreamWriter.flush.

Cause the overflow handler to be called even if buffer is not full.

public Connection<L>
getConnection()

Implements org.glassfish.grizzly.streams.StreamWriter.getConnection.

Get the Connection this StreamWriter belongs to.

public long
getTimeout(TimeUnit timeunit)

Implements org.glassfish.grizzly.streams.StreamWriter.getTimeout.

Get the timeout for StreamWriter I/O operations.

public boolean
isClosed()

Implements org.glassfish.grizzly.streams.StreamWriter.isClosed.

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

public void
setTimeout(long timeout, TimeUnit timeunit)

Implements org.glassfish.grizzly.streams.StreamWriter.setTimeout.

Set the timeout for StreamWriter I/O operations.

public void
writeBoolean(final boolean data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeBoolean.

Write the boolean value to the StreamWriter.

public void
writeBooleanArray(final boolean[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeBooleanArray.

Write the array of boolean values to the StreamWriter.

public void
public void
writeByte(final byte data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeByte.

Write the byte value to the StreamWriter.

public void
writeByteArray(final byte[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

Write the array of byte values to the StreamWriter.

public void
writeByteArray(byte[] data, int offset, int length)

Implements org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

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

public void
writeChar(final char data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeChar.

Write the char value to the StreamWriter.

public void
writeCharArray(final char[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeCharArray.

Write the array of char values to the StreamWriter.

public void
writeDouble(final double data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeDouble.

Write the double value to the StreamWriter.

public void
writeDoubleArray(final double[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeDoubleArray.

Write the array of double values to the StreamWriter.

public void
writeFloat(final float data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeFloat.

Write the float value to the StreamWriter.

public void
writeFloatArray(final float[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeFloatArray.

Write the array of float values to the StreamWriter.

public void
writeInt(final int data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeInt.

Write the int value to the StreamWriter.

public void
writeIntArray(final int[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeIntArray.

Write the array of int values to the StreamWriter.

public void
writeLong(final long data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeLong.

Write the long value to the StreamWriter.

public void
writeLongArray(final long[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeLongArray.

Write the array of long values to the StreamWriter.

public void
writeShort(final short data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeShort.

Write the short value to the StreamWriter.

public void
writeShortArray(final short[] data)

Implements org.glassfish.grizzly.streams.StreamWriter.writeShortArray.

Write the array of short values to the StreamWriter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
private final Connection<L> connection
isClosedback to summary
private final AtomicBoolean isClosed
isOutputBufferedback to summary
protected final boolean isOutputBuffered
loggerback to summary
protected static final Logger logger
outputback to summary
protected final Output output
timeoutMillisback to summary
private long timeoutMillis
ZEROback to summary
protected static final Integer ZERO
ZERO_READY_FUTUREback to summary
protected static final GrizzlyFuture<Integer> ZERO_READY_FUTURE

Constructor Detail

AbstractStreamWriterback to summary
protected AbstractStreamWriter(final Connection<L> connection, Output streamOutput)

Create a new ByteBufferWriter. An instance maintains a current buffer for use in writing. Whenever the current buffer is insufficient to hold the required data, the BufferHandler is called, and the result of the handler is the new current buffer. The handler is responsible for the disposition of the contents of the old buffer.

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
closeback to summary
public GrizzlyFuture<Integer> close(CompletionHandler<Integer> completionHandler) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.close.

Doc from org.glassfish.grizzly.streams.StreamWriter.close.

Close the StreamWriter and make sure all data was flushed.

Annotations
@Override
encodeback to summary
public <E> GrizzlyFuture<Stream> encode(Transformer<E, Buffer> encoder, E object) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.encode.

Annotations
@Override
encodeback to summary
public <E> GrizzlyFuture<Stream> encode(Transformer<E, Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.encode.

Annotations
@Override
flushback to summary
public GrizzlyFuture<Integer> flush() throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.flush.

Cause the overflow handler to be called even if buffer is not full.

Annotations
@Override
flushback to summary
public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.flush.

Cause the overflow handler to be called even if buffer is not full.

Annotations
@Override
getConnectionback to summary
public Connection<L> getConnection()

Implements org.glassfish.grizzly.streams.StreamWriter.getConnection.

Doc from org.glassfish.grizzly.streams.StreamWriter.getConnection.

Get the Connection this StreamWriter belongs to.

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

Implements org.glassfish.grizzly.streams.StreamWriter.getTimeout.

Doc from org.glassfish.grizzly.streams.StreamWriter.getTimeout.

Get the timeout for StreamWriter I/O operations.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements org.glassfish.grizzly.streams.StreamWriter.isClosed.

Doc from org.glassfish.grizzly.streams.StreamWriter.isClosed.

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

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

Implements org.glassfish.grizzly.streams.StreamWriter.setTimeout.

Doc from org.glassfish.grizzly.streams.StreamWriter.setTimeout.

Set the timeout for StreamWriter I/O operations.

Annotations
@Override
writeBooleanback to summary
public void writeBoolean(final boolean data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeBoolean.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeBoolean.

Write the boolean value to the StreamWriter.

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

Implements org.glassfish.grizzly.streams.StreamWriter.writeBooleanArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeBooleanArray.

Write the array of boolean values to the StreamWriter.

Annotations
@Override
writeBufferback to summary
public void writeBuffer(Buffer b) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeBuffer.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeBuffer.

Write the Buffer to the StreamWriter.

Annotations
@Override
writeByteback to summary
public void writeByte(final byte data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeByte.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeByte.

Write the byte value to the StreamWriter.

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

Implements org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

Write the array of byte values to the StreamWriter.

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

Implements org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeByteArray.

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

Annotations
@Override
writeCharback to summary
public void writeChar(final char data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeChar.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeChar.

Write the char value to the StreamWriter.

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

Implements org.glassfish.grizzly.streams.StreamWriter.writeCharArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeCharArray.

Write the array of char values to the StreamWriter.

Annotations
@Override
writeDoubleback to summary
public void writeDouble(final double data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeDouble.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeDouble.

Write the double value to the StreamWriter.

Annotations
@Override
writeDoubleArrayback to summary
public void writeDoubleArray(final double[] data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeDoubleArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeDoubleArray.

Write the array of double values to the StreamWriter.

Annotations
@Override
writeFloatback to summary
public void writeFloat(final float data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeFloat.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeFloat.

Write the float value to the StreamWriter.

Annotations
@Override
writeFloatArrayback to summary
public void writeFloatArray(final float[] data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeFloatArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeFloatArray.

Write the array of float values to the StreamWriter.

Annotations
@Override
writeIntback to summary
public void writeInt(final int data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeInt.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeInt.

Write the int value to the StreamWriter.

Annotations
@Override
writeIntArrayback to summary
public void writeIntArray(final int[] data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeIntArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeIntArray.

Write the array of int values to the StreamWriter.

Annotations
@Override
writeLongback to summary
public void writeLong(final long data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeLong.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeLong.

Write the long value to the StreamWriter.

Annotations
@Override
writeLongArrayback to summary
public void writeLongArray(final long[] data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeLongArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeLongArray.

Write the array of long values to the StreamWriter.

Annotations
@Override
writeShortback to summary
public void writeShort(final short data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeShort.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeShort.

Write the short value to the StreamWriter.

Annotations
@Override
writeShortArrayback to summary
public void writeShortArray(final short[] data) throws IOException

Implements org.glassfish.grizzly.streams.StreamWriter.writeShortArray.

Doc from org.glassfish.grizzly.streams.StreamWriter.writeShortArray.

Write the array of short values to the StreamWriter.

Annotations
@Override
org.glassfish.grizzly.streams back to summary

public Class AbstractStreamWriter.DisposeBufferCompletionHandler

extends Object
implements CompletionHandler
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.streams.AbstractStreamWriter.DisposeBufferCompletionHandler
All Implemented Interfaces
org.glassfish.grizzly.CompletionHandler

Field Summary

Modifier and TypeField and Description
private final Buffer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
cancelled()

Implements org.glassfish.grizzly.CompletionHandler.cancelled.

The operation was cancelled.

public void
completed(Object result)

Implements org.glassfish.grizzly.CompletionHandler.completed.

The operation was completed.

protected void
public void
failed(Throwable throwable)

Implements org.glassfish.grizzly.CompletionHandler.failed.

The operation was failed.

public void
updated(Object result)

Implements org.glassfish.grizzly.CompletionHandler.updated.

The callback method may be called, when there is some progress in operation execution, but it is still not completed

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final Buffer buffer

Constructor Detail

DisposeBufferCompletionHandlerback to summary
public DisposeBufferCompletionHandler(Buffer buffer)

Method Detail

cancelledback to summary
public void cancelled()

Implements org.glassfish.grizzly.CompletionHandler.cancelled.

Doc from org.glassfish.grizzly.CompletionHandler.cancelled.

The operation was cancelled.

Annotations
@Override
completedback to summary
public void completed(Object result)

Implements org.glassfish.grizzly.CompletionHandler.completed.

Doc from org.glassfish.grizzly.CompletionHandler.completed.

The operation was completed.

Annotations
@Override
disposeBufferback to summary
protected void disposeBuffer()
failedback to summary
public void failed(Throwable throwable)

Implements org.glassfish.grizzly.CompletionHandler.failed.

Doc from org.glassfish.grizzly.CompletionHandler.failed.

The operation was failed.

Annotations
@Override
updatedback to summary
public void updated(Object result)

Implements org.glassfish.grizzly.CompletionHandler.updated.

Doc from org.glassfish.grizzly.CompletionHandler.updated.

The callback method may be called, when there is some progress in operation execution, but it is still not completed

Annotations
@Override