Class FilterChannel<C extends java.nio.channels.Channel>

  • Type Parameters:
    C - the Channel type.
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel
    Direct Known Subclasses:
    FilterByteChannel, FilterReadableByteChannel, FilterWritableByteChannel

    public class FilterChannel<C extends java.nio.channels.Channel>
    extends java.lang.Object
    implements java.nio.channels.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
    • Constructor Detail

      • FilterChannel

        public FilterChannel​(C channel)
        Constructs a new instance.
        Parameters:
        channel - The channel to wrap.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.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.