Class ChannelHelper

java.lang.Object
com.pnfsoftware.jeb.util.io.ChannelHelper

public class ChannelHelper extends Object
Helper for SeekableByteChannels.

The provided channel is neither closed nor position-verified. Methods of this class are not thread-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a primitive reader helper for a seekable byte channel.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    get()
    Read one byte at the current channel position.
    byte
    get(long channelPosition)
    Read one byte at an absolute channel position.
    int
    Read a 32-bit integer at the current channel position.
    int
    getInt(long channelPosition)
    Read a 32-bit integer at an absolute channel position.
    long
    Read a 64-bit integer at the current channel position.
    long
    getLong(long channelPosition)
    Read a 64-bit integer at an absolute channel position.
    short
    Read a 16-bit integer at the current channel position.
    short
    getShort(long channelPosition)
    Read a 16-bit integer at an absolute channel position.

    Methods inherited from class java.lang.Object

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

    • ChannelHelper

      public ChannelHelper(SeekableByteChannel channel, Endianness endianness)
      Create a primitive reader helper for a seekable byte channel.
      Parameters:
      channel - input channel
      endianness - byte order to use when reading multi-byte values
  • Method Details

    • get

      public byte get() throws IOException
      Read one byte at the current channel position.
      Returns:
      byte value
      Throws:
      IOException - if the byte cannot be read
    • get

      public byte get(long channelPosition) throws IOException
      Read one byte at an absolute channel position.
      Parameters:
      channelPosition - absolute channel position
      Returns:
      byte value
      Throws:
      IOException - if the byte cannot be read
    • getShort

      public short getShort() throws IOException
      Read a 16-bit integer at the current channel position.
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read
    • getShort

      public short getShort(long channelPosition) throws IOException
      Read a 16-bit integer at an absolute channel position.
      Parameters:
      channelPosition - absolute channel position
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read
    • getInt

      public int getInt() throws IOException
      Read a 32-bit integer at the current channel position.
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read
    • getInt

      public int getInt(long channelPosition) throws IOException
      Read a 32-bit integer at an absolute channel position.
      Parameters:
      channelPosition - absolute channel position
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read
    • getLong

      public long getLong() throws IOException
      Read a 64-bit integer at the current channel position.
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read
    • getLong

      public long getLong(long channelPosition) throws IOException
      Read a 64-bit integer at an absolute channel position.
      Parameters:
      channelPosition - absolute channel position
      Returns:
      decoded value
      Throws:
      IOException - if the value cannot be read