Record Class ByteRange
java.lang.Object
java.lang.Record
org.eclipse.jetty.http.ByteRange
-
Constructor Summary
ConstructorsConstructorDescriptionByteRange(long first, long last) Creates an instance of aByteRangerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.longfirst()Returns the value of thefirstrecord component.longGet the length of this byte range.final inthashCode()Returns a hash code value for this object.longlast()Returns the value of thelastrecord component.Parses theRangeheader values such asbyte=10-20to obtain a list ofByteRanges.toHeaderValue(long length) Returns the value for theContent-Rangeresponse header corresponding to this byte range.static StringtoNonSatisfiableHeaderValue(long length) Returns the value for theContent-Rangeresponse header when the range is non satisfiable and therefore the response status code isHttpStatus.RANGE_NOT_SATISFIABLE_416.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ByteRange
public ByteRange(long first, long last) Creates an instance of aByteRangerecord class.- Parameters:
first- the value for thefirstrecord componentlast- the value for thelastrecord component
-
-
Method Details
-
getLength
public long getLength()Get the length of this byte range.- Returns:
- the length of this byte range
-
toHeaderValue
Returns the value for the
Content-Rangeresponse header corresponding to this byte range.- Parameters:
length- the content length- Returns:
- the value for the
Content-Rangeresponse header for this byte range
-
parse
Parses the
Rangeheader values such asbyte=10-20to obtain a list ofByteRanges.Returns an empty list if the parsing fails.
- Parameters:
headers- a list of range valueslength- the length of the resource for which ranges are requested- Returns:
- a list of
ByteRanges
-
toNonSatisfiableHeaderValue
Returns the value for the
Content-Rangeresponse header when the range is non satisfiable and therefore the response status code isHttpStatus.RANGE_NOT_SATISFIABLE_416.- Parameters:
length- the content length in bytes- Returns:
- the non satisfiable value for the
Content-Rangeresponse header
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
first
public long first()Returns the value of thefirstrecord component.- Returns:
- the value of the
firstrecord component
-
last
public long last()Returns the value of thelastrecord component.- Returns:
- the value of the
lastrecord component
-