org.apache.mina.core.filterchain

## Class DefaultIoFilterChainBuilder

- java.lang.Object
- - org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder

- All Implemented Interfaces:
    IoFilterChainBuilder

      public class DefaultIoFilterChainBuilder
      extends Object
      implements IoFilterChainBuilder

  The default implementation of `IoFilterChainBuilder` which is useful in most cases. `DefaultIoFilterChainBuilder` has an identical interface with `IoFilter`; it contains a list of `IoFilter`s that you can modify. The `IoFilter`s which are added to this builder will be appended to the `IoFilterChain` when `buildFilterChain(IoFilterChain)` is invoked.

  However, the identical interface doesn't mean that it behaves in an exactly same way with `IoFilterChain`. `DefaultIoFilterChainBuilder` doesn't manage the life cycle of the `IoFilter`s at all, and the existing `IoSession`s won't get affected by the changes in this builder. `IoFilterChainBuilder`s affect only newly created `IoSession`s.

       IoAcceptor acceptor = ...;
       DefaultIoFilterChainBuilder builder = acceptor.getFilterChain();
       builder.addLast( "myFilter", new MyFilter() );
       ...

  Author:
    Apache MINA Project

- - ### Field Summary

    - ### Fields inherited from interface org.apache.mina.core.filterchain.IoFilterChainBuilder

      `NOOP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultIoFilterChainBuilder()` Creates a new instance with an empty filter list.
    `DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)` Creates a new copy of the specified `DefaultIoFilterChainBuilder`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAfter(String baseName, String name, IoFilter filter)`
    `void` | `addBefore(String baseName, String name, IoFilter filter)`
    `void` | `addFirst(String name, IoFilter filter)`
    `void` | `addLast(String name, IoFilter filter)`
    `void` | `buildFilterChain(IoFilterChain chain)` Modifies the specified `chain`.
    `void` | `clear()`
    `boolean` | `contains(Class<? extends IoFilter> filterType)`
    `boolean` | `contains(IoFilter filter)`
    `boolean` | `contains(String name)`
    `IoFilter` | `get(Class<? extends IoFilter> filterType)`
    `IoFilter` | `get(String name)`
    `List<IoFilterChain.Entry>` | `getAll()`
    `List<IoFilterChain.Entry>` | `getAllReversed()`
    `IoFilterChain.Entry` | `getEntry(Class<? extends IoFilter> filterType)`
    `IoFilterChain.Entry` | `getEntry(IoFilter filter)`
    `IoFilterChain.Entry` | `getEntry(String name)`
    `IoFilter` | `remove(Class<? extends IoFilter> filterType)`
    `IoFilter` | `remove(IoFilter filter)`
    `IoFilter` | `remove(String name)`
    `void` | `replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)`
    `void` | `replace(IoFilter oldFilter, IoFilter newFilter)`
    `IoFilter` | `replace(String name, IoFilter newFilter)`
    `void` | `setFilters(Map<String,? extends IoFilter> filters)` Clears the current list of filters and adds the specified filter mapping to this builder.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### DefaultIoFilterChainBuilder

          public DefaultIoFilterChainBuilder()

      Creates a new instance with an empty filter list.

    - #### DefaultIoFilterChainBuilder

          public DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)

      Creates a new copy of the specified `DefaultIoFilterChainBuilder`.

  - ### Method Detail

    - #### getEntry

          public IoFilterChain.Entry getEntry(String name)

      See Also:
        `IoFilterChain.getEntry(String)`

    - #### getEntry

          public IoFilterChain.Entry getEntry(IoFilter filter)

      See Also:
        `IoFilterChain.getEntry(IoFilter)`

    - #### getEntry

          public IoFilterChain.Entry getEntry(Class<? extends IoFilter> filterType)

      See Also:
        `IoFilterChain.getEntry(Class)`

    - #### get

          public IoFilter get(String name)

      See Also:
        `IoFilterChain.get(String)`

    - #### get

          public IoFilter get(Class<? extends IoFilter> filterType)

      See Also:
        `IoFilterChain.get(Class)`

    - #### getAll

          public List<IoFilterChain.Entry> getAll()

      See Also:
        `IoFilterChain.getAll()`

    - #### getAllReversed

          public List<IoFilterChain.Entry> getAllReversed()

      See Also:
        `IoFilterChain.getAllReversed()`

    - #### contains

          public boolean contains(String name)

      See Also:
        `IoFilterChain.contains(String)`

    - #### contains

          public boolean contains(IoFilter filter)

      See Also:
        `IoFilterChain.contains(IoFilter)`

    - #### contains

          public boolean contains(Class<? extends IoFilter> filterType)

      See Also:
        `IoFilterChain.contains(Class)`

    - #### addFirst

          public void addFirst(String name,
                      IoFilter filter)

      See Also:
        `IoFilterChain.addFirst(String, IoFilter)`

    - #### addLast

          public void addLast(String name,
                     IoFilter filter)

      See Also:
        `IoFilterChain.addLast(String, IoFilter)`

    - #### addBefore

          public void addBefore(String baseName,
                       String name,
                       IoFilter filter)

      See Also:
        `IoFilterChain.addBefore(String, String, IoFilter)`

    - #### addAfter

          public void addAfter(String baseName,
                      String name,
                      IoFilter filter)

      See Also:
        `IoFilterChain.addAfter(String, String, IoFilter)`

    - #### remove

          public IoFilter remove(String name)

      See Also:
        `IoFilterChain.remove(String)`

    - #### remove

          public IoFilter remove(IoFilter filter)

      See Also:
        `IoFilterChain.remove(IoFilter)`

    - #### remove

          public IoFilter remove(Class<? extends IoFilter> filterType)

      See Also:
        `IoFilterChain.remove(Class)`

    - #### replace

          public IoFilter replace(String name,
                         IoFilter newFilter)

    - #### replace

          public void replace(IoFilter oldFilter,
                     IoFilter newFilter)

    - #### replace

          public void replace(Class<? extends IoFilter> oldFilterType,
                     IoFilter newFilter)

    - #### clear

          public void clear()

      See Also:
        `IoFilterChain.clear()`

    - #### setFilters

          public void setFilters(Map<String,? extends IoFilter> filters)

      Clears the current list of filters and adds the specified filter mapping to this builder. Please note that you must specify a `Map` implementation that iterates the filter mapping in the order of insertion such as `LinkedHashMap`. Otherwise, it will throw an `IllegalArgumentException`.

    - #### buildFilterChain

          public void buildFilterChain(IoFilterChain chain)
                                throws Exception

      Description copied from interface: `IoFilterChainBuilder`
      Modifies the specified `chain`.
      Specified by:
        `buildFilterChain` in interface `IoFilterChainBuilder`
      Throws:
        `Exception`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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