org.apache.mina.filter.stream

## Class AbstractStreamWriteFilter<T>

- java.lang.Object
- - org.apache.mina.core.filterchain.IoFilterAdapter
  - - org.apache.mina.filter.stream.AbstractStreamWriteFilter<T>

- All Implemented Interfaces:
    IoFilter
  Direct Known Subclasses:
    FileRegionWriteFilter, StreamWriteFilter

      public abstract class AbstractStreamWriteFilter<T>
      extends IoFilterAdapter

  TODO Add documentation
  Author:
    Apache MINA Project

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter

      `IoFilter.NextFilter`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AttributeKey` | `CURRENT_STREAM` The attribute name used when binding the streaming object to the session.
    `protected AttributeKey` | `CURRENT_WRITE_REQUEST`
    `static int` | `DEFAULT_STREAM_BUFFER_SIZE` The default buffer size this filter uses for writing.
    `protected AttributeKey` | `WRITE_REQUEST_QUEUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractStreamWriteFilter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)` Filters `IoSession.write(Object)` method invocation.
    `protected abstract Class<T>` | `getMessageClass()`
    `protected abstract IoBuffer` | `getNextBuffer(T message)`
    `int` | `getWriteBufferSize()` Returns the size of the write buffer in bytes.
    `void` | `messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)` Filters `IoHandler.messageSent(IoSession,Object)` event.
    `void` | `onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)` Invoked before this filter is added to the specified `parent`.
    `void` | `setWriteBufferSize(int writeBufferSize)` Sets the size of the write buffer in bytes.

    - ### Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter

      `destroy, exceptionCaught, filterClose, init, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString`

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

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

- - ### Field Detail

    - #### DEFAULT_STREAM_BUFFER_SIZE

          public static final int DEFAULT_STREAM_BUFFER_SIZE

      The default buffer size this filter uses for writing.
      See Also:
        Constant Field Values

    - #### CURRENT_STREAM

          protected final AttributeKey CURRENT_STREAM

      The attribute name used when binding the streaming object to the session.

    - #### WRITE_REQUEST_QUEUE

          protected final AttributeKey WRITE_REQUEST_QUEUE

    - #### CURRENT_WRITE_REQUEST

          protected final AttributeKey CURRENT_WRITE_REQUEST

  - ### Constructor Detail

    - #### AbstractStreamWriteFilter

          public AbstractStreamWriteFilter()

  - ### Method Detail

    - #### onPreAdd

          public void onPreAdd(IoFilterChain parent,
                      String name,
                      IoFilter.NextFilter nextFilter)
                        throws Exception

      Description copied from class: `IoFilterAdapter`
      Invoked before this filter is added to the specified `parent`. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked before `IoFilter.init()` is invoked.
      Specified by:
        `onPreAdd` in interface `IoFilter`
      Overrides:
        `onPreAdd` in class `IoFilterAdapter`
      Parameters:
        `parent` - the parent who called this method
        `name` - the name assigned to this filter
        `nextFilter` - the `IoFilter.NextFilter` for this filter. You can reuse this object until this filter is removed from the chain.
      Throws:
        `Exception`

    - #### filterWrite

          public void filterWrite(IoFilter.NextFilter nextFilter,
                         IoSession session,
                         WriteRequest writeRequest)
                           throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoSession.write(Object)` method invocation.
      Specified by:
        `filterWrite` in interface `IoFilter`
      Overrides:
        `filterWrite` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### getMessageClass

          protected abstract Class<T> getMessageClass()

    - #### messageSent

          public void messageSent(IoFilter.NextFilter nextFilter,
                         IoSession session,
                         WriteRequest writeRequest)
                           throws Exception

      Description copied from class: `IoFilterAdapter`
      Filters `IoHandler.messageSent(IoSession,Object)` event.
      Specified by:
        `messageSent` in interface `IoFilter`
      Overrides:
        `messageSent` in class `IoFilterAdapter`
      Throws:
        `Exception`

    - #### getWriteBufferSize

          public int getWriteBufferSize()

      Returns the size of the write buffer in bytes. Data will be read from the stream in chunks of this size and then written to the next filter.
      Returns:
        the write buffer size.

    - #### setWriteBufferSize

          public void setWriteBufferSize(int writeBufferSize)

      Sets the size of the write buffer in bytes. Data will be read from the stream in chunks of this size and then written to the next filter.
      Throws:
        `IllegalArgumentException` - if the specified size is < 1.

    - #### getNextBuffer

          protected abstract IoBuffer getNextBuffer(T message)
                                             throws IOException

      Throws:
        `IOException`

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.