Class ChannelDataInput.BytesReader

java.lang.Object
org.apache.sis.internal.storage.io.ChannelDataInput.ArrayReader
org.apache.sis.internal.storage.io.ChannelDataInput.BytesReader
All Implemented Interfaces:
DataTransfer
Enclosing class:
ChannelDataInput

final class ChannelDataInput.BytesReader extends ChannelDataInput.ArrayReader
Reads bytes from the enclosing stream and stores them into the given destination array. This implementation actually redirects the reading process to ChannelDataInput.readFully(byte[], int, int) because this specialization does not need a view. This implementation is useless for ChannelDataInput, but avoid the need to implement special cases in other classes like HyperRectangleReader.
  • Field Details

    • dest

      private byte[] dest
      The array where to store the values.
  • Constructor Details

    • BytesReader

      BytesReader(byte[] dest)
  • Method Details

    • dataSizeShift

      public int dataSizeShift()
      Description copied from interface: DataTransfer
      Returns the size of the Java primitive type which is the element of the array. The size is expressed as the number of bits to shift: java dataSize = 1 << dataSizeShift;
    • dataArray

      public Object dataArray()
      Description copied from interface: DataTransfer
      Returns the data as a char[], short[], int[], long[], float[] or double[] array. This is either the array given in argument to the subclass constructor, or the array created by DataTransfer.createDataArray(int).
    • dataArrayAsBuffer

      public Buffer dataArrayAsBuffer()
      Description copied from interface: DataTransfer
      Returns DataTransfer.dataArray() wrapped in a buffer.
    • view

      public Buffer view()
      Description copied from interface: DataTransfer
      Returns the view created by the last call to DataTransfer.createView(), or null if none.
    • createView

      public Buffer createView()
      Description copied from interface: DataTransfer
      Creates a new buffer of the type required by the array to fill. This method is guaranteed to be invoked exactly once, after the ChannelData.buffer contains enough data.
    • createDataArray

      public void createDataArray(int n)
      Description copied from interface: DataTransfer
      Creates a destination array of the given length.
    • transfer

      void transfer(int p, int n)
      Description copied from class: ChannelDataInput.ArrayReader
      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.
      Specified by:
      transfer in class ChannelDataInput.ArrayReader
    • setDest

      public void setDest(Object array)
      Description copied from interface: DataTransfer
      Sets the destination to the given data array, which may be null.
    • readFully

      public void readFully(Buffer view, int offset, int length) throws IOException
      Description copied from class: ChannelDataInput.ArrayReader
      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
      Overrides:
      readFully in class ChannelDataInput.ArrayReader
      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.