uk.ac.starlink.fits

## Class MultiByteBufferInput

- java.lang.Object
- - uk.ac.starlink.fits.BlockInput
  - - uk.ac.starlink.fits.MultiByteBufferInput

- All Implemented Interfaces:
    BasicInput

      public class MultiByteBufferInput
      extends BlockInput

  Random-access BasicInput implementation based on a supplied array of byte buffers.
  Since:
    19 Mar 2021

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiByteBufferInput(java.nio.ByteBuffer[] bufs)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.nio.ByteBuffer` | `acquireBlock(int iblock)` Obtains a buffer corresponding to a named block of the stream.
    `void` | `close()` Releases resources belonging to this object.
    `long` | `getBlockOffset(int iblock, int offsetInBlock)` Returns the offset into this stream corresponding to a given block index and offset into that block.
    `int[]` | `getBlockPos(long offset)` Returns the block location of a given byte offset.

    - ### Methods inherited from class uk.ac.starlink.fits.BlockInput

      `getBlockCount, getOffset, isRandom, readByte, readBytes, readDouble, readFloat, readInt, readLong, readShort, seek, skip`

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

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

- - ### Constructor Detail

    - #### MultiByteBufferInput

          public MultiByteBufferInput(java.nio.ByteBuffer[] bufs)

      Constructor.
      Parameters:
        `bufs` - byte buffers holding data

  - ### Method Detail

    - #### getBlockPos

          public int[] getBlockPos(long offset)

      Description copied from class: `BlockInput`
      Returns the block location of a given byte offset.

      This does the opposite of `getBlockOffset`.

      Specified by:
        `getBlockPos` in class `BlockInput`
      Parameters:
        `offset` - offset into this input stream
      Returns:
        2-element array giving [blockIndex, offsetInBlock]

    - #### getBlockOffset

          public long getBlockOffset(int iblock,
                                     int offsetInBlock)

      Description copied from class: `BlockInput`
      Returns the offset into this stream corresponding to a given block index and offset into that block.

      This does the opposite of `getBlockPos`.

      Specified by:
        `getBlockOffset` in class `BlockInput`
      Parameters:
        `iblock` - block index
        `offsetInBlock` - offset into that block
      Returns:
        offset into stream

    - #### acquireBlock

          protected java.nio.ByteBuffer acquireBlock(int iblock)

      Description copied from class: `BlockInput`
      Obtains a buffer corresponding to a named block of the stream. The buffer's position must be zero. This method is called whenever a buffer is required which is not the same as the most recently used one.
      Specified by:
        `acquireBlock` in class `BlockInput`
      Parameters:
        `iblock` - block index
      Returns:
        byte buffer for given block, positioned at start

    - #### close

          public void close()

      Description copied from interface: `BasicInput`
      Releases resources belonging to this object. Attempts to use it after a call to this method result in undefined behaviour.
      Specified by:
        `close` in interface `BasicInput`
      Overrides:
        `close` in class `BlockInput`