io.undertow.conduits

## Class AbstractFramedStreamSinkConduit

- java.lang.Object
- - org.xnio.conduits.AbstractConduit<D>
  - - org.xnio.conduits.AbstractSinkConduit<D>
    - - org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
      - - io.undertow.conduits.AbstractFramedStreamSinkConduit

All Implemented Interfaces:
  org.xnio.conduits.Conduit, org.xnio.conduits.SinkConduit, org.xnio.conduits.StreamSinkConduit

    public class AbstractFramedStreamSinkConduit
    extends org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>

Utility class to ease the implementation of framed protocols. This call provides a queue of frames, and a callback that can be invoked when a frame event occurs.

When a write takes place all frames are attempted to be written out at once via a gathering write. Frames can be queued via `queueFrame(io.undertow.conduits.AbstractFramedStreamSinkConduit.FrameCallBack, java.nio.ByteBuffer...)`.

Author:
  Stuart Douglas

### Nested Class Summary

Nested Classes
`static interface` `AbstractFramedStreamSinkConduit.FrameCallBack` Interface that is called when a frame event takes place.
`protected static class` `AbstractFramedStreamSinkConduit.PooledBufferFrameCallback`
`protected static class` `AbstractFramedStreamSinkConduit.PooledBuffersFrameCallback`

### Field Summary

### Fields inherited from class org.xnio.conduits.AbstractConduit

`next`

### Constructor Summary

Constructors
`protected` `AbstractFramedStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next)` Construct a new instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `doTerminateWrites()`
`protected void` `finished()`
`protected boolean` `flushQueuedData()`
`protected boolean` `isWritesTerminated()`
`protected void` `queueCloseFrames()`
`protected long` `queuedDataLength()`
`protected void` `queueFrame(AbstractFramedStreamSinkConduit.FrameCallBack callback, ByteBuffer... data)` Queues a frame for sending.
`void` `terminateWrites()`
`long` `transferFrom(FileChannel src, long position, long count)`
`long` `transferFrom(org.xnio.channels.StreamSourceChannel source, long count, ByteBuffer throughBuffer)`
`void` `truncateWrites()`
`int` `write(ByteBuffer src)`
`long` `write(ByteBuffer[] srcs, int offs, int len)`
`int` `writeFinal(ByteBuffer src)`
`long` `writeFinal(ByteBuffer[] srcs, int offs, int len)`

### Methods inherited from class org.xnio.conduits.AbstractSinkConduit

`awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, wakeupWrites`

### Methods inherited from class org.xnio.conduits.AbstractConduit

`getWorker`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.xnio.conduits.SinkConduit

`awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, wakeupWrites`

### Methods inherited from interface org.xnio.conduits.Conduit

`getWorker`

### Constructor Detail

#### AbstractFramedStreamSinkConduit

    protected AbstractFramedStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next)

Construct a new instance.

Parameters:
  `next` - the delegate conduit to set

### Method Detail

#### queueFrame

    protected void queueFrame(AbstractFramedStreamSinkConduit.FrameCallBack callback,
                              ByteBuffer... data)

Queues a frame for sending.

Parameters:
  `callback` -
  `data` -

#### transferFrom

    public long transferFrom(FileChannel src,
                             long position,
                             long count)
                      throws IOException

Specified by:
  `transferFrom` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `transferFrom` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### transferFrom

    public long transferFrom(org.xnio.channels.StreamSourceChannel source,
                             long count,
                             ByteBuffer throughBuffer)
                      throws IOException

Specified by:
  `transferFrom` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `transferFrom` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### write

    public int write(ByteBuffer src)
              throws IOException

Specified by:
  `write` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `write` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### write

    public long write(ByteBuffer[] srcs,
                      int offs,
                      int len)
               throws IOException

Specified by:
  `write` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `write` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### writeFinal

    public int writeFinal(ByteBuffer src)
                   throws IOException

Specified by:
  `writeFinal` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `writeFinal` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### writeFinal

    public long writeFinal(ByteBuffer[] srcs,
                           int offs,
                           int len)
                    throws IOException

Specified by:
  `writeFinal` in interface `org.xnio.conduits.StreamSinkConduit`
Overrides:
  `writeFinal` in class `org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### queuedDataLength

    protected long queuedDataLength()

#### terminateWrites

    public void terminateWrites()
                         throws IOException

Specified by:
  `terminateWrites` in interface `org.xnio.conduits.SinkConduit`
Overrides:
  `terminateWrites` in class `org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### doTerminateWrites

    protected void doTerminateWrites()
                              throws IOException

Throws:
  `IOException`

#### flushQueuedData

    protected boolean flushQueuedData()
                               throws IOException

Throws:
  `IOException`

#### truncateWrites

    public void truncateWrites()
                        throws IOException

Specified by:
  `truncateWrites` in interface `org.xnio.conduits.SinkConduit`
Overrides:
  `truncateWrites` in class `org.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>`
Throws:
  `IOException`

#### isWritesTerminated

    protected boolean isWritesTerminated()

#### queueCloseFrames

    protected void queueCloseFrames()

#### finished

    protected void finished()