Class ByteRange


  • public abstract class ByteRange
    extends java.lang.Object
    Represents a byte range for performing ranged get requests.
    • Method Detail

      • fromOffsetRange

        @Deprecated
        public static ByteRange fromOffsetRange​(long startOffset,
                                                long endOffset)
        Deprecated.
        Construct a range from a start offset to an end offset.
        Parameters:
        startOffset - the (inclusive) start byte offset.
        endOffset - the (inclusive) end byte offset.
        Returns:
        A ByteRange with the specified offsets.
        Throws:
        java.lang.IllegalArgumentException - if the start offset is less than 0, or the end offset is less than the start.
      • fromStartOffset

        @Deprecated
        public static ByteRange fromStartOffset​(long startOffset)
        Deprecated.
        Construct a range from a start offset to the end of an object.
        Parameters:
        startOffset - The (inclusive) start byte offset.
        Returns:
        A ByteRange with the specified start offset.
        Throws:
        java.lang.IllegalArgumentException - if the start offset is less than 0
      • fromLastNBytes

        @Deprecated
        public static ByteRange fromLastNBytes​(long lastNBytes)
        Deprecated.
        Construct a range that represents the last N bytes of an object.
        Parameters:
        lastNBytes - the number of bytes to read from the end of an object.
        Returns:
        A ByteRange representing the last N bytes of an objects.
        Throws:
        java.lang.IllegalArgumentException - if the number of bytes to read is less than or equal to 0.
      • getEndOffset

        public long getEndOffset()
        Returns:
        The inclusive end offset for this range.
        Throws:
        java.lang.UnsupportedOperationException - if the range does not have a defined start offset (i.e. not of the type ByteRange.ByteRangeType.OFFSET_RANGE)
      • getLastNBytes

        public long getLastNBytes()
        Returns:
        The number of bytes to read from the end of the object.
        Throws:
        java.lang.UnsupportedOperationException - if the range is not of the type ByteRange.ByteRangeType.LAST_N_BYTES)
      • toResolvedByteRange

        public ByteRange toResolvedByteRange​(long totalSize)
        Given the total size of a blob, generate a new ByteRange of type ByteRange.ByteRangeType.OFFSET_RANGE with defined start and end offsets that are verified to be within the supplied total blob size.
        Parameters:
        totalSize - the total size of the blob that this range corresponds to.
        Returns:
        the ByteRange with start and end offsets
        Throws:
        java.lang.IllegalArgumentException - if the byte range starts past the end of the blob.
      • toResolvedByteRange

        public abstract ByteRange toResolvedByteRange​(long totalSize,
                                                      boolean resolveRangeOnEmptyBlob)
        Given the total size of a blob, generate a new ByteRange of type ByteRange.ByteRangeType.OFFSET_RANGE with defined start and end offsets that are verified to be within the supplied total blob size.
        Parameters:
        totalSize - the total size of the blob that this range corresponds to.
        resolveRangeOnEmptyBlob - true to force range resolution to succeed if the blob is empty. In other words, return an empty range if totalSize == 0.
        Returns:
        the ByteRange with start and end offsets
        Throws:
        java.lang.IllegalArgumentException - if the byte range starts past the end of the blob.
      • toString

        public abstract java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public abstract boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object