Class BinaryAbstractInputStream

    • Field Detail

      • len

        protected int len
        Length of data inside array.
    • Constructor Detail

      • BinaryAbstractInputStream

        public BinaryAbstractInputStream()
    • Method Detail

      • readByte

        public byte readByte()
        Read byte value.
        Specified by:
        readByte in interface BinaryInputStream
        Returns:
        Byte value.
      • readByteArray

        public byte[] readByteArray​(int cnt)
        Read byte array.
        Specified by:
        readByteArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Byte array.
      • readBoolean

        public boolean readBoolean()
        Read boolean value.
        Specified by:
        readBoolean in interface BinaryInputStream
        Returns:
        Boolean value.
      • readBooleanArray

        public boolean[] readBooleanArray​(int cnt)
        Read boolean array.
        Specified by:
        readBooleanArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Boolean array.
      • readShort

        public short readShort()
        Read short value.
        Specified by:
        readShort in interface BinaryInputStream
        Returns:
        Short value.
      • readShortArray

        public short[] readShortArray​(int cnt)
        Read short array.
        Specified by:
        readShortArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Short array.
      • readChar

        public char readChar()
        Read char value.
        Specified by:
        readChar in interface BinaryInputStream
        Returns:
        Char value.
      • readCharArray

        public char[] readCharArray​(int cnt)
        Read char array.
        Specified by:
        readCharArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Char array.
      • readInt

        public int readInt()
        Read int value.
        Specified by:
        readInt in interface BinaryInputStream
        Returns:
        Int value.
      • readIntArray

        public int[] readIntArray​(int cnt)
        Read int array.
        Specified by:
        readIntArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Int array.
      • readBytePositioned

        public byte readBytePositioned​(int pos)
        Read byte at the given position.
        Specified by:
        readBytePositioned in interface BinaryPositionReadable
        Parameters:
        pos - Position.
        Returns:
        Value.
      • readShortPositioned

        public short readShortPositioned​(int pos)
        Read short at the given position.
        Specified by:
        readShortPositioned in interface BinaryPositionReadable
        Parameters:
        pos - Position.
        Returns:
        Value.
      • readIntPositioned

        public int readIntPositioned​(int pos)
        Read integer at the given position.
        Specified by:
        readIntPositioned in interface BinaryPositionReadable
        Parameters:
        pos - Position.
        Returns:
        Value.
      • readFloat

        public float readFloat()
        Read float value.
        Specified by:
        readFloat in interface BinaryInputStream
        Returns:
        Float value.
      • readFloatArray

        public float[] readFloatArray​(int cnt)
        Read float array.
        Specified by:
        readFloatArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Float array.
      • readLong

        public long readLong()
        Read long value.
        Specified by:
        readLong in interface BinaryInputStream
        Returns:
        Long value.
      • readLongArray

        public long[] readLongArray​(int cnt)
        Read long array.
        Specified by:
        readLongArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Long array.
      • readDouble

        public double readDouble()
        Read double value.
        Specified by:
        readDouble in interface BinaryInputStream
        Returns:
        Double value.
      • readDoubleArray

        public double[] readDoubleArray​(int cnt)
        Read double array.
        Specified by:
        readDoubleArray in interface BinaryInputStream
        Parameters:
        cnt - Expected item count.
        Returns:
        Double array.
      • read

        public int read​(byte[] arr,
                        int off,
                        int len)
        Reads cnt of bytes into byte array.
        Specified by:
        read in interface BinaryInputStream
        Parameters:
        arr - Expected item count.
        off - offset
        len - number of bytes to read.
        Returns:
        actual length read.
      • position

        public void position​(int pos)
        Specified by:
        position in interface BinaryStream
        Parameters:
        pos - Position.
      • offheapPointer

        public long offheapPointer()
        Specified by:
        offheapPointer in interface BinaryStream
        Returns:
        Offheap pointer if stream is offheap based and "forceHeap" flag is not set; otherwise 0.
      • rawOffheapPointer

        public long rawOffheapPointer()
        Specified by:
        rawOffheapPointer in interface BinaryStream
        Returns:
        Offheap pointer if stream is offheap based; otherwise 0.
      • ensureEnoughData

        protected void ensureEnoughData​(int cnt)
        Ensure that there is enough data.
        Parameters:
        cnt - Length.
      • readByteAndShift

        protected abstract byte readByteAndShift()
        Read next byte from the stream and perform shift.
        Returns:
        Next byte.
      • copyAndShift

        protected abstract void copyAndShift​(Object target,
                                             long off,
                                             int len)
        Copy data to target object shift position afterwards.
        Parameters:
        target - Target.
        off - Offset.
        len - Length.
      • readShortFast

        protected abstract short readShortFast()
        Read short value (fast path).
        Returns:
        Short value.
      • readCharFast

        protected abstract char readCharFast()
        Read char value (fast path).
        Returns:
        Char value.
      • readIntFast

        protected abstract int readIntFast()
        Read int value (fast path).
        Returns:
        Int value.
      • readLongFast

        protected abstract long readLongFast()
        Read long value (fast path).
        Returns:
        Long value.
      • readBytePositioned0

        protected abstract byte readBytePositioned0​(int pos)
        Internal routine for positioned byte value read.
        Parameters:
        pos - Position.
        Returns:
        Int value.
      • readShortPositioned0

        protected abstract short readShortPositioned0​(int pos)
        Internal routine for positioned short value read.
        Parameters:
        pos - Position.
        Returns:
        Int value.
      • readIntPositioned0

        protected abstract int readIntPositioned0​(int pos)
        Internal routine for positioned int value read.
        Parameters:
        pos - Position.
        Returns:
        Int value.