Package com.jsgalactic.axiom.http
Record Class ByteRanges
java.lang.Object
java.lang.Record
com.jsgalactic.axiom.http.ByteRanges
- Record Components:
ranges- the ranges to send, in request order; at least one and at most 8
The satisfiable ranges of a
Range: bytes=... header field (RFC 9110 section 14.2), in the
order the client sent them.
Parsing is strict and bounded: only the bytes unit is accepted, a range list holds at
most 8 specifications, every number is ASCII digits, and whitespace is allowed
only around commas. A specification whose first byte is past the end of the representation, or a
suffix of zero, is unsatisfiable and is dropped; if none remain, parsing yields empty. Numbers
too large for a long are clamped rather than overflowing, so they become unsatisfiable
instead of wrapping around. Open-ended ranges are clamped to the representation's length.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMost specifications a parsedRangefield may contain: eight. -
Constructor Summary
ConstructorsConstructorDescriptionByteRanges(List<ByteRange> ranges) Validates the bound and takes an immutable copy. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Optional<ByteRanges> Parses aRangefield against a representation of the given length.ranges()Returns the value of therangesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MAX_RANGES
public static final int MAX_RANGESMost specifications a parsedRangefield may contain: eight.- See Also:
-
-
Constructor Details
-
ByteRanges
Validates the bound and takes an immutable copy.- Throws:
IllegalArgumentException- if there are no ranges or more thanMAX_RANGES
-
-
Method Details
-
parse
Parses aRangefield against a representation of the given length.- Parameters:
header- the completeRangefield value, or null when absentlength- total length of the representation in bytes, positive- Returns:
- the satisfiable ranges, or empty when the header is absent, malformed, has too many specifications, or has no satisfiable range
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 withObjects::equals(Object,Object). -
ranges
Returns the value of therangesrecord component.- Returns:
- the value of the
rangesrecord component
-