Class NullChannel

java.lang.Object
org.apache.sis.internal.storage.io.NullChannel
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ReadableByteChannel

final class NullChannel extends Object implements ReadableByteChannel
A channel which read no values. This class behaves as if the channel already reached the end of file.
Since:
1.3
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Whether this channel has been closed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an initially open channel.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this channel.
    boolean
    Returns whether this channel is still open.
    int
    Pretends to read a sequence of bytes and indicates that the channel reached the end of file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • closed

      private volatile boolean closed
      Whether this channel has been closed.
  • Constructor Details

    • NullChannel

      NullChannel()
      Creates an initially open channel.
  • Method Details

    • read

      public int read(ByteBuffer dst) throws ClosedChannelException
      Pretends to read a sequence of bytes and indicates that the channel reached the end of file. Read-only buffers are accepted (this is required for ChannelImageInputStream).
      Specified by:
      read in interface ReadableByteChannel
      Parameters:
      dst - ignored except for non-null check.
      Returns:
      always -1.
      Throws:
      ClosedChannelException - if this channel has been closed.
    • isOpen

      public boolean isOpen()
      Returns whether this channel is still open.
      Specified by:
      isOpen in interface Channel
    • close

      public void close()
      Closes this channel. If this channel is already closed, then this method does nothing.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable