Class SimpleByteRange

    • Constructor Detail

      • SimpleByteRange

        public SimpleByteRange()
      • SimpleByteRange

        public SimpleByteRange​(int capacity)
      • SimpleByteRange

        public SimpleByteRange​(byte[] bytes)
        Create a new ByteRange over the provided bytes.
        Parameters:
        bytes - The array to wrap.
      • SimpleByteRange

        public SimpleByteRange​(byte[] bytes,
                               int offset,
                               int length)
        Create a new ByteRange over the provided bytes.
        Parameters:
        bytes - The array to wrap.
        offset - The offset into bytes considered the beginning of this range.
        length - The length of this range.
    • Method Detail

      • unset

        public ByteRange 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
        Specified by:
        unset in class AbstractByteRange
        Returns:
        this
      • set

        public ByteRange 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
        Overrides:
        set in class AbstractByteRange
        Parameters:
        capacity - the size of a new byte[].
        Returns:
        this
      • set

        public ByteRange 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
        Overrides:
        set in class AbstractByteRange
        Parameters:
        bytes - the array to wrap.
        Returns:
        this
      • set

        public ByteRange 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
        Overrides:
        set in class AbstractByteRange
        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.
      • put

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

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

        public ByteRange 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
        Specified by:
        put in class AbstractByteRange
        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.
      • shallowCopy

        public ByteRange 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.
        Returns:
        new ByteRange object referencing this range's byte[].
      • shallowCopySubRange

        public ByteRange 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.
        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[].
      • equals

        public boolean equals​(java.lang.Object thatObject)
        Overrides:
        equals in class java.lang.Object
      • deepCopy

        public ByteRange 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.
        Returns:
        Deep copy
      • putInt

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

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

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

        public int putVLong​(int index,
                            long val)
        Description copied from interface: ByteRange
        Store the long value at index as a VLong
        Specified by:
        putVLong in interface ByteRange
        Specified by:
        putVLong in class AbstractByteRange
        Parameters:
        index - the index in the range where val is stored
        val - the value to store
        Returns:
        number of bytes written