Class ByteRange

java.lang.Object
com.google.appengine.api.blobstore.ByteRange

public class ByteRange extends Object
A byte range as parsed from a request Range header. Format produced by this class is also compatible with the X-AppEngine-BlobRange header, used for serving sub-ranges of blobs.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteRange(long start)
    Constructor.
    ByteRange(long start, long end)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(@Nullable Object object)
    Two ByteRange objects are considered equal if they have the same start and end.
    long
    Get end index of byte range.
    long
    Get start index of byte range.
    boolean
    Indicates whether or not this byte range indicates an end.
    int
     
    static ByteRange
    parse(String byteRange)
    Parse byte range from header.
    static ByteRange
    parseContentRange(String contentRange)
    Parse content range from header for byte-range only.
    Format byte range for use in header.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteRange

      public ByteRange(long start)
      Constructor.
      Parameters:
      start - Start index of blob range to serve. If negative, serve the last abs(start) bytes of the blob.
    • ByteRange

      public ByteRange(long start, long end)
      Constructor.
      Parameters:
      start - Start index of blob range to serve. May not be negative.
      end - End index of blob range to serve. Index is inclusive, meaning the byte indicated by end is included in the response.
  • Method Details

    • hasEnd

      public boolean hasEnd()
      Indicates whether or not this byte range indicates an end.
      Returns:
      true if byte range has an end.
    • getStart

      public long getStart()
      Get start index of byte range.
      Returns:
      Start index of byte range.
    • getEnd

      public long getEnd()
      Get end index of byte range.
      Returns:
      End index of byte range.
      Throws:
      IllegalStateException - if byte range does not have an end range.
    • toString

      public String toString()
      Format byte range for use in header.
      Overrides:
      toString in class Object
    • parse

      public static ByteRange parse(String byteRange)
      Parse byte range from header.
      Parameters:
      byteRange - Byte range string as received from header.
      Returns:
      ByteRange object set to byte range as parsed from string.
      Throws:
      RangeFormatException - Unable to parse header because of invalid format.
      UnsupportedRangeFormatException - Header is a valid HTTP range header, the specific form is not supported by app engine. This includes unit types other than "bytes" and multiple ranges.
    • parseContentRange

      public static ByteRange parseContentRange(String contentRange)
      Parse content range from header for byte-range only.
      Parameters:
      contentRange - Content range string as received from header.
      Returns:
      ByteRange object set to byte range as parsed from string, but does not include the size information.
      Throws:
      RangeFormatException - Unable to parse header because of invalid format.
    • hashCode

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

      public boolean equals(@Nullable Object object)
      Two ByteRange objects are considered equal if they have the same start and end.
      Overrides:
      equals in class Object