Package org.apache.commons.io.channels

# Class FilterChannel<C extends Channel>

java.lang.Object
org.apache.commons.io.channels.FilterChannel<C>

Type Parameters:
  `C` - the `Channel` type.

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Channel`

Direct Known Subclasses:
  `FilterByteChannel`, `FilterReadableByteChannel`, `FilterWritableByteChannel`

public class FilterChannel<C extends Channel> extends Object implements Channel
A `Channel` filter which delegates to the wrapped `Channel`.

A `FilterChannel` wraps some other channel, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality. The class `FilterChannel` itself simply overrides methods of `Channel` with versions that pass all requests to the wrapped channel. Subclasses of `FilterChannel` may of course override any methods declared or inherited by `FilterChannel`, and may also provide additional fields and methods.

You construct s simple instance with the `channel constructor` and more advanced instances through the `FilterChannel.Builder`.

Since:
  2.22.0
See Also:
  - `FilterInputStream`
  - `FilterOutputStream`
  - `FilterReader`
  - `FilterWritableByteChannel`
  - `ProxyInputStream`
  - `ProxyOutputStream`
  - `ProxyReader`
  - `ProxyWriter`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `FilterChannel.AbstractBuilder<F extends FilterChannel<C>,C extends Channel,B extends FilterChannel.AbstractBuilder<F,C,B>>`
  Builds instances of `FilterChannel` for subclasses.
  `static class`
  `FilterChannel.Builder`
  Builds instances of `FilterChannel`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FilterChannel(C channel)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `static FilterChannel.Builder`
  `forChannel()`
  Creates a new `FilterChannel.Builder`.
  `boolean`
  `isOpen()`
  `C`
  `unwrap()`
  Unwraps this instance by returning the underlying `Channel` of type `C`.

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

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

- ## Constructor Details

  - ### FilterChannel

    public FilterChannel(C channel)
    Constructs a new instance.
    Parameters:
      `channel` - The channel to wrap.

- ## Method Details

  - ### forChannel

    public static FilterChannel.Builder forChannel()
    Creates a new `FilterChannel.Builder`.
    Returns:
      a new `FilterChannel.Builder`.

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Channel`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException`

  - ### isOpen

    public boolean isOpen()
    Specified by:
      `isOpen` in interface `Channel`

  - ### unwrap

    public C unwrap()
    Unwraps this instance by returning the underlying `Channel` of type `C`.

    Use with caution.

    Returns:
      the underlying channel of type `C`.