Package org.springframework.http
Class HttpRange
java.lang.Object
org.springframework.http.HttpRange
Represents an HTTP (byte) range for use with the HTTP 
"Range" header.- Since:
- 4.2
- Author:
- Arjen Poutsma, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic HttpRangecreateByteRange(long firstBytePos) Create anHttpRangefrom the given position to the end.static HttpRangecreateByteRange(long firstBytePos, long lastBytePos) Create aHttpRangefrom the given fist to last position.static HttpRangecreateSuffixRange(long suffixLength) Create anHttpRangethat ranges over the last given number of bytes.abstract longgetRangeEnd(long length) Return the end of the range (inclusive) given the total length of a representation.abstract longgetRangeStart(long length) Return the start of the range given the total length of a representation.parseRanges(String ranges) Parse the given, comma-separated string into a list ofHttpRangeobjects.toResourceRegion(Resource resource) Turn aResourceinto aResourceRegionusing the range information contained in the currentHttpRange.static List<ResourceRegion>toResourceRegions(List<HttpRange> ranges, Resource resource) Convert eachHttpRangeinto aResourceRegion, selecting the appropriate segment of the givenResourceusing HTTP Range information.static StringtoString(Collection<HttpRange> ranges) Return a string representation of the given list ofHttpRangeobjects.
- 
Constructor Details- 
HttpRangepublic HttpRange()
 
- 
- 
Method Details- 
toResourceRegionTurn aResourceinto aResourceRegionusing the range information contained in the currentHttpRange.- Parameters:
- resource- the- Resourceto select the region from
- Returns:
- the selected region of the given Resource
- Since:
- 4.3
 
- 
getRangeStartpublic abstract long getRangeStart(long length) Return the start of the range given the total length of a representation.- Parameters:
- length- the length of the representation
- Returns:
- the start of this range for the representation
 
- 
getRangeEndpublic abstract long getRangeEnd(long length) Return the end of the range (inclusive) given the total length of a representation.- Parameters:
- length- the length of the representation
- Returns:
- the end of the range for the representation
 
- 
createByteRangeCreate anHttpRangefrom the given position to the end.- Parameters:
- firstBytePos- the first byte position
- Returns:
- a byte range that ranges from firstPostill the end
- See Also:
 
- 
createByteRangeCreate aHttpRangefrom the given fist to last position.- Parameters:
- firstBytePos- the first byte position
- lastBytePos- the last byte position
- Returns:
- a byte range that ranges from firstPostilllastPos
- See Also:
 
- 
createSuffixRangeCreate anHttpRangethat ranges over the last given number of bytes.- Parameters:
- suffixLength- the number of bytes for the range
- Returns:
- a byte range that ranges over the last suffixLengthnumber of bytes
- See Also:
 
- 
parseRangesParse the given, comma-separated string into a list ofHttpRangeobjects.This method can be used to parse an Rangeheader.- Parameters:
- ranges- the string to parse
- Returns:
- the list of ranges
- Throws:
- IllegalArgumentException- if the string cannot be parsed or if the number of ranges is greater than 100
 
- 
toResourceRegionsConvert eachHttpRangeinto aResourceRegion, selecting the appropriate segment of the givenResourceusing HTTP Range information.- Parameters:
- ranges- the list of ranges
- resource- the resource to select the regions from
- Returns:
- the list of regions for the given resource
- Throws:
- IllegalArgumentException- if the sum of all ranges exceeds the resource length
- Since:
- 4.3
 
- 
toStringReturn a string representation of the given list ofHttpRangeobjects.This method can be used to for an Rangeheader.- Parameters:
- ranges- the ranges to create a string of
- Returns:
- the string representation
 
 
-