Class ChannelDataInput.ArrayReader

java.lang.Object
org.apache.sis.internal.storage.io.ChannelDataInput.ArrayReader
All Implemented Interfaces:
DataTransfer
Direct Known Subclasses:
ChannelDataInput.BytesReader, ChannelDataInput.CharsReader, ChannelDataInput.DoublesReader, ChannelDataInput.FloatsReader, ChannelDataInput.IntsReader, ChannelDataInput.LongsReader, ChannelDataInput.ShortsReader
Enclosing class:
ChannelDataInput

abstract class ChannelDataInput.ArrayReader extends Object implements DataTransfer
Helper class for the readFully(…) methods, in order to avoid duplicating almost identical code many times.
  • Constructor Details

    • ArrayReader

      ArrayReader()
      For subclass constructors only.
  • Method Details

    • filename

      public final String filename()
      Returns a file identifier for error messages or debugging purpose.
      Specified by:
      filename in interface DataTransfer
    • transfer

      abstract void transfer(int offset, int n)
      Transfers the data from the buffer created by DataTransfer.createView() to array of primitive Java type known by the subclass. This method may be invoked an arbitrary number of time.
    • skipInBuffer

      private void skipInBuffer(int n)
      Skips the given amount of bytes in the buffer. It is caller responsibility to ensure that there is enough bytes remaining in the buffer.
    • seek

      public final void seek(long n) throws IOException
      Moves to the given position in the stream.
      Specified by:
      seek in interface DataTransfer
      Parameters:
      n - the position where to move.
      Throws:
      IOException - if the stream cannot be moved to the given position.
    • readFully

      public void readFully(Buffer view, int offset, int length) throws IOException
      Reads length values from the stream, and stores them into the array known to subclass, starting at index offset.

      If a non-null Buffer is given in argument to this method, then it must be a view over the full content of ChannelData.buffer (i.e. the view element at index 0 shall be defined by the buffer elements starting at index 0).

      Specified by:
      readFully in interface DataTransfer
      Parameters:
      view - existing buffer to use as a view over ChannelData.buffer, or null.
      offset - the starting position within dest to write.
      length - the number of values to read.
      Throws:
      IOException - if an error (including EOF) occurred while reading the stream.