Class BasicSliceInput

All Implemented Interfaces:
Closeable, DataInput, AutoCloseable

public final class BasicSliceInput extends FixedLengthSliceInput
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of bytes that can be read without blocking.
    long
    Approximate number of bytes retained by this instance.
    boolean
    Returns true if and only if available() is greater than 0.
    long
    Gets the total size of this input stream.
    long
    Returns the position of this buffer.
    int
     
    int
    read(byte[] destination, int destinationIndex, int length)
     
    boolean
    Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
    byte
    Gets a byte at the current position and increases the position by 1 in this buffer.
    void
    readBytes(byte[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
    void
    readBytes(Slice destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
    void
    readBytes(OutputStream out, int length)
    Transfers this buffer's data to the specified stream starting at the current position.
    double
    Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
    float
    Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
    int
    Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
    long
    Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
    short
    Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
    readSlice(int length)
    Returned slice is a view over slice
    int
    Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
    int
    Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
    void
    setPosition(long position)
    Sets the position of this buffer.
    long
    skip(long length)
     
    int
    skipBytes(int length)
     
    Returns a slice of this buffer's readable bytes.
     
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.

    Methods inherited from class io.airlift.slice.FixedLengthSliceInput

    remaining

    Methods inherited from class java.lang.Object

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

    • BasicSliceInput

      public BasicSliceInput(Slice slice)
  • Method Details

    • length

      public long length()
      Description copied from class: FixedLengthSliceInput
      Gets the total size of this input stream.
      Specified by:
      length in class FixedLengthSliceInput
    • position

      public long position()
      Description copied from class: SliceInput
      Returns the position of this buffer.
      Specified by:
      position in class SliceInput
    • setPosition

      public void setPosition(long position)
      Description copied from class: SliceInput
      Sets the position of this buffer.
      Specified by:
      setPosition in class SliceInput
    • isReadable

      public boolean isReadable()
      Description copied from class: SliceInput
      Returns true if and only if available() is greater than 0.
      Specified by:
      isReadable in class SliceInput
    • available

      public int available()
      Description copied from class: SliceInput
      Returns the number of bytes that can be read without blocking.
      Specified by:
      available in class SliceInput
    • readBoolean

      public boolean readBoolean()
      Description copied from class: SliceInput
      Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
      Specified by:
      readBoolean in interface DataInput
      Specified by:
      readBoolean in class SliceInput
    • read

      public int read()
      Specified by:
      read in class SliceInput
    • readByte

      public byte readByte()
      Description copied from class: SliceInput
      Gets a byte at the current position and increases the position by 1 in this buffer.
      Specified by:
      readByte in interface DataInput
      Specified by:
      readByte in class SliceInput
    • readUnsignedByte

      public int readUnsignedByte()
      Description copied from class: SliceInput
      Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
      Specified by:
      readUnsignedByte in interface DataInput
      Specified by:
      readUnsignedByte in class SliceInput
    • readShort

      public short readShort()
      Description copied from class: SliceInput
      Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
      Specified by:
      readShort in interface DataInput
      Specified by:
      readShort in class SliceInput
    • readUnsignedShort

      public int readUnsignedShort()
      Description copied from class: SliceInput
      Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
      Specified by:
      readUnsignedShort in interface DataInput
      Specified by:
      readUnsignedShort in class SliceInput
    • readInt

      public int readInt()
      Description copied from class: SliceInput
      Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
      Specified by:
      readInt in interface DataInput
      Specified by:
      readInt in class SliceInput
    • readLong

      public long readLong()
      Description copied from class: SliceInput
      Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
      Specified by:
      readLong in interface DataInput
      Specified by:
      readLong in class SliceInput
    • readFloat

      public float readFloat()
      Description copied from class: SliceInput
      Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
      Specified by:
      readFloat in interface DataInput
      Specified by:
      readFloat in class SliceInput
    • readDouble

      public double readDouble()
      Description copied from class: SliceInput
      Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
      Specified by:
      readDouble in interface DataInput
      Specified by:
      readDouble in class SliceInput
    • readSlice

      public Slice readSlice(int length)
      Returned slice is a view over slice
      Specified by:
      readSlice in class SliceInput
      Parameters:
      length - the size of the new slice
      Returns:
      the newly created slice
    • read

      public int read(byte[] destination, int destinationIndex, int length)
      Specified by:
      read in class SliceInput
    • readBytes

      public void readBytes(byte[] destination, int destinationIndex, int length)
      Description copied from class: SliceInput
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      Specified by:
      readBytes in class SliceInput
      destinationIndex - the first index of the destination
      length - the number of bytes to transfer
    • readBytes

      public void readBytes(Slice destination, int destinationIndex, int length)
      Description copied from class: SliceInput
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      Specified by:
      readBytes in class SliceInput
      destinationIndex - the first index of the destination
      length - the number of bytes to transfer
    • readBytes

      public void readBytes(OutputStream out, int length) throws IOException
      Description copied from class: SliceInput
      Transfers this buffer's data to the specified stream starting at the current position.
      Specified by:
      readBytes in class SliceInput
      length - the number of bytes to transfer
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • skip

      public long skip(long length)
      Specified by:
      skip in class SliceInput
    • skipBytes

      public int skipBytes(int length)
      Specified by:
      skipBytes in interface DataInput
      Specified by:
      skipBytes in class SliceInput
    • getRetainedSize

      public long getRetainedSize()
      Description copied from class: SliceInput
      Approximate number of bytes retained by this instance.
      Specified by:
      getRetainedSize in class SliceInput
    • slice

      public Slice slice()
      Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(buf.position(), buf.available()()). This method does not modify position or writerIndex of this buffer.
    • toString

      public String toString(Charset charset)
      Decodes this buffer's readable bytes into a string with the specified character set name. This method is identical to buf.toString(buf.position(), buf.available()(), charsetName). This method does not modify position or writerIndex of this buffer.
    • toString

      public String toString()
      Overrides:
      toString in class Object