Interface PositionedByteRange

    • Method Detail

      • getPosition

        int getPosition()
        The current position marker. This valuae is 0-indexed, relative to the beginning of the range.
      • setPosition

        PositionedByteRange setPosition​(int position)
        Update the position index. May not be greater than length.
        Parameters:
        position - the new position in this range.
        Returns:
        this.
      • getRemaining

        int getRemaining()
        The number of bytes remaining between position and the end of the range.
      • peek

        byte peek()
        Retrieve the next byte from this range without incrementing position.
      • get

        byte get()
        Retrieve the next byte from this range.
      • getShort

        short getShort()
        Retrieve the next short value from this range.
      • getInt

        int getInt()
        Retrieve the next int value from this range.
      • getLong

        long getLong()
        Retrieve the next long value from this range.
      • getVLong

        long getVLong()
        Retrieve the next long value, which is stored as VLong, from this range
        Returns:
        the long value which is stored as VLong
      • get

        PositionedByteRange get​(byte[] dst)
        Fill dst with bytes from the range, starting from position. This range's position is incremented by the length of dst, the number of bytes copied.
        Parameters:
        dst - the destination of the copy.
        Returns:
        this.
      • get

        PositionedByteRange get​(byte[] dst,
                                int offset,
                                int length)
        Fill dst with bytes from the range, starting from the current position. length bytes are copied into dst, starting at offset. This range's position is incremented by the number of bytes copied.
        Parameters:
        dst - the destination of the copy.
        offset - the offset into dst to start the copy.
        length - the number of bytes to copy into dst.
        Returns:
        this.
      • put

        PositionedByteRange put​(byte val)
        Store val at the next position in this range.
        Parameters:
        val - the new value.
        Returns:
        this.
      • putShort

        PositionedByteRange putShort​(short val)
        Store short val at the next position in this range.
        Parameters:
        val - the new value.
        Returns:
        this.
      • putInt

        PositionedByteRange putInt​(int val)
        Store int val at the next position in this range.
        Parameters:
        val - the new value.
        Returns:
        this.
      • putLong

        PositionedByteRange putLong​(long val)
        Store long val at the next position in this range.
        Parameters:
        val - the new value.
        Returns:
        this.
      • putVLong

        int putVLong​(long val)
        Store the long val at the next position as a VLong
        Parameters:
        val - the value to store
        Returns:
        number of bytes written
      • put

        PositionedByteRange put​(byte[] val)
        Store the content of val in this range, starting at the next position.
        Parameters:
        val - the new value.
        Returns:
        this.
      • put

        PositionedByteRange put​(byte[] val,
                                int offset,
                                int length)
        Store length bytes from val into this range. Bytes from val are copied starting at offset into the range, starting at the current position.
        Parameters:
        val - the new value.
        offset - the offset in val from which to start copying.
        length - the number of bytes to copy from val.
        Returns:
        this.
      • setLimit

        PositionedByteRange setLimit​(int limit)
        Limits the byte range upto a specified value. Limit cannot be greater than capacity
        Parameters:
        limit -
        Returns:
        PositionedByteRange
      • getLimit

        int getLimit()
        Return the current limit
        Returns:
        limit
      • unset

        PositionedByteRange unset()
        Description copied from interface: ByteRange
        Nullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.
        Specified by:
        unset in interface ByteRange
        Returns:
        this
      • set

        PositionedByteRange set​(int capacity)
        Description copied from interface: ByteRange
        Reuse this ByteRange over a new byte[]. offset is set to 0 and length is set to capacity.
        Specified by:
        set in interface ByteRange
        Parameters:
        capacity - the size of a new byte[].
        Returns:
        this
      • set

        PositionedByteRange set​(byte[] bytes)
        Description copied from interface: ByteRange
        Reuse this ByteRange over a new byte[]. offset is set to 0 and length is set to bytes.length. A null bytes IS supported, in which case this method will behave equivalently to ByteRange.unset().
        Specified by:
        set in interface ByteRange
        Parameters:
        bytes - the array to wrap.
        Returns:
        this
      • set

        PositionedByteRange set​(byte[] bytes,
                                int offset,
                                int length)
        Description copied from interface: ByteRange
        Reuse this ByteRange over a new byte[]. A null bytes IS supported, in which case this method will behave equivalently to ByteRange.unset(), regardless of the values of offset and length.
        Specified by:
        set in interface ByteRange
        Parameters:
        bytes - The array to wrap.
        offset - The offset into bytes considered the beginning of this range.
        length - The length of this range.
        Returns:
        this.
      • setOffset

        PositionedByteRange setOffset​(int offset)
        Description copied from interface: ByteRange
        Update the beginning of this range. offset + length may not be greater than bytes.length.
        Specified by:
        setOffset in interface ByteRange
        Parameters:
        offset - the new start of this range.
        Returns:
        this.
      • setLength

        PositionedByteRange setLength​(int length)
        Description copied from interface: ByteRange
        Update the length of this range. offset + length should not be greater than bytes.length.
        Specified by:
        setLength in interface ByteRange
        Parameters:
        length - The new length of this range.
        Returns:
        this.
      • get

        PositionedByteRange get​(int index,
                                byte[] dst)
        Description copied from interface: ByteRange
        Fill dst with bytes from the range, starting from index.
        Specified by:
        get in interface ByteRange
        Parameters:
        index - zero-based index into this range.
        dst - the destination of the copy.
        Returns:
        this.
      • get

        PositionedByteRange get​(int index,
                                byte[] dst,
                                int offset,
                                int length)
        Description copied from interface: ByteRange
        Fill dst with bytes from the range, starting from index. length bytes are copied into dst, starting at offset.
        Specified by:
        get in interface ByteRange
        Parameters:
        index - zero-based index into this range.
        dst - the destination of the copy.
        offset - the offset into dst to start the copy.
        length - the number of bytes to copy into dst.
        Returns:
        this.
      • put

        PositionedByteRange put​(int index,
                                byte val)
        Description copied from interface: ByteRange
        Store val at index.
        Specified by:
        put in interface ByteRange
        Parameters:
        index - the index in the range where val is stored.
        val - the value to store.
        Returns:
        this.
      • putShort

        PositionedByteRange putShort​(int index,
                                     short val)
        Description copied from interface: ByteRange
        Store the short value at index
        Specified by:
        putShort in interface ByteRange
        Parameters:
        index - the index in the range where val is stored
        val - the value to store
        Returns:
        this
      • putInt

        PositionedByteRange putInt​(int index,
                                   int val)
        Description copied from interface: ByteRange
        Store the int value at index
        Specified by:
        putInt in interface ByteRange
        Parameters:
        index - the index in the range where val is stored
        val - the value to store
        Returns:
        this
      • putLong

        PositionedByteRange putLong​(int index,
                                    long val)
        Description copied from interface: ByteRange
        Store the long value at index
        Specified by:
        putLong in interface ByteRange
        Parameters:
        index - the index in the range where val is stored
        val - the value to store
        Returns:
        this
      • put

        PositionedByteRange put​(int index,
                                byte[] val)
        Description copied from interface: ByteRange
        Store val at index.
        Specified by:
        put in interface ByteRange
        Parameters:
        index - the index in the range where val is stored.
        val - the value to store.
        Returns:
        this.
      • put

        PositionedByteRange put​(int index,
                                byte[] val,
                                int offset,
                                int length)
        Description copied from interface: ByteRange
        Store length bytes from val into this range, starting at index. Bytes from val are copied starting at offset into the range.
        Specified by:
        put in interface ByteRange
        Parameters:
        index - position in this range to start the copy.
        val - the value to store.
        offset - the offset in val from which to start copying.
        length - the number of bytes to copy from val.
        Returns:
        this.
      • deepCopy

        PositionedByteRange deepCopy()
        Description copied from interface: ByteRange
        Create a new ByteRange with new backing byte[] containing a copy of the content from this range's window.
        Specified by:
        deepCopy in interface ByteRange
        Returns:
        Deep copy
      • shallowCopy

        PositionedByteRange shallowCopy()
        Description copied from interface: ByteRange
        Create a new ByteRange that points at this range's byte[]. Modifying the shallowCopy will modify the bytes in this range's array. Pass over the hash code if it is already cached.
        Specified by:
        shallowCopy in interface ByteRange
        Returns:
        new ByteRange object referencing this range's byte[].
      • shallowCopySubRange

        PositionedByteRange shallowCopySubRange​(int innerOffset,
                                                int copyLength)
        Description copied from interface: ByteRange
        Create a new ByteRange that points at this range's byte[]. The new range can have different values for offset and length, but modifying the shallowCopy will modify the bytes in this range's array. Pass over the hash code if it is already cached.
        Specified by:
        shallowCopySubRange in interface ByteRange
        Parameters:
        innerOffset - First byte of clone will be this.offset + copyOffset.
        copyLength - Number of bytes in the clone.
        Returns:
        new ByteRange object referencing this range's byte[].