public abstract class HttpRange
extends java.lang.Object
"Range"
header.HttpHeaders.setRange(List)
,
HttpHeaders.getRange()
Modifier and Type | Class and Description |
---|---|
private static class |
HttpRange.ByteRange
Represents an HTTP/1.1 byte range, with a first and optional last position.
|
private static class |
HttpRange.SuffixByteRange
Represents an HTTP/1.1 suffix byte range, with a number of suffix bytes.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BYTE_RANGE_PREFIX |
Constructor and Description |
---|
HttpRange() |
Modifier and Type | Method and Description |
---|---|
static HttpRange |
createByteRange(long firstBytePos)
Create an
HttpRange from the given position to the end. |
static HttpRange |
createByteRange(long firstBytePos,
long lastBytePos)
Create a
HttpRange from the given fist to last position. |
static HttpRange |
createSuffixRange(long suffixLength)
Create an
HttpRange that ranges over the last given number of bytes. |
abstract long |
getRangeEnd(long length)
Return the end of the range (inclusive) given the total length of a representation.
|
abstract long |
getRangeStart(long length)
Return the start of the range given the total length of a representation.
|
private static HttpRange |
parseRange(java.lang.String range) |
static java.util.List<HttpRange> |
parseRanges(java.lang.String ranges)
Parse the given, comma-separated string into a list of
HttpRange objects. |
ResourceRegion |
toResourceRegion(Resource resource)
Turn a
Resource into a ResourceRegion using the range
information contained in the current HttpRange . |
static java.util.List<ResourceRegion> |
toResourceRegions(java.util.List<HttpRange> ranges,
Resource resource)
Convert each
HttpRange into a ResourceRegion , selecting the
appropriate segment of the given Resource using HTTP Range information. |
static java.lang.String |
toString(java.util.Collection<HttpRange> ranges)
Return a string representation of the given list of
HttpRange objects. |
private static final java.lang.String BYTE_RANGE_PREFIX
public ResourceRegion toResourceRegion(Resource resource)
Resource
into a ResourceRegion
using the range
information contained in the current HttpRange
.resource
- the Resource
to select the region fromResource
public abstract long getRangeStart(long length)
length
- the length of the representationpublic abstract long getRangeEnd(long length)
length
- the length of the representationpublic static HttpRange createByteRange(long firstBytePos)
HttpRange
from the given position to the end.firstBytePos
- the first byte positionfirstPos
till the endpublic static HttpRange createByteRange(long firstBytePos, long lastBytePos)
HttpRange
from the given fist to last position.firstBytePos
- the first byte positionlastBytePos
- the last byte positionfirstPos
till lastPos
public static HttpRange createSuffixRange(long suffixLength)
HttpRange
that ranges over the last given number of bytes.suffixLength
- the number of bytes for the rangesuffixLength
number of bytespublic static java.util.List<HttpRange> parseRanges(java.lang.String ranges)
HttpRange
objects.
This method can be used to parse an Range
header.
ranges
- the string to parsejava.lang.IllegalArgumentException
- if the string cannot be parsedprivate static HttpRange parseRange(java.lang.String range)
public static java.util.List<ResourceRegion> toResourceRegions(java.util.List<HttpRange> ranges, Resource resource)
HttpRange
into a ResourceRegion
, selecting the
appropriate segment of the given Resource
using HTTP Range information.ranges
- the list of rangesresource
- the resource to select the regions frompublic static java.lang.String toString(java.util.Collection<HttpRange> ranges)
HttpRange
objects.
This method can be used to for an Range
header.
ranges
- the ranges to create a string of