Class HttpRange


  • public final class HttpRange
    extends Object
    Represents a range of bytes within an HTTP resource.

    The range starts at the offset inclusively and ends at offset + length exclusively, or offset + length - 1.

    If length is unspecified, null, then the range extends to the end of the HTTP resource.

    • Constructor Detail

      • HttpRange

        public HttpRange​(long offset)
        Creates an instance of HttpRange.

        This creates a range which has an unbounded length starting at the specified offset.

        Parameters:
        offset - The offset to begin the range.
        Throws:
        IllegalArgumentException - If offset is less than 0.
      • HttpRange

        public HttpRange​(long offset,
                         Long length)
        Creates an instance of HttpRange.
        Parameters:
        offset - The offset to begin the range.
        length - The length of the range.
        Throws:
        IllegalArgumentException - If offset is less than 0 or length is non-null and is less than or equal to 0.
    • Method Detail

      • getOffset

        public long getOffset()
        Gets the offset of the range.
        Returns:
        Offset of the range.
      • getLength

        public Long getLength()
        Gets the length of the range.

        If the length is null the range continues to the end of the HTTP resource.

        Returns:
        Length of the range or null if range continues to the end of the HTTP resource.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Gets the string representation of the range.

        If length is null the returned string will be "bytes=<offset>-", if length is not null the returned string will be "bytes=<offset>-<offset + length - 1>".

        Overrides:
        toString in class Object
        Returns:
        The string representation of the range.