Package org.apache.juneau.http.header
Class Range.Builder
java.lang.Object
org.apache.juneau.http.header.Range.Builder
- Enclosing class:
- Range
Fluent builder for assembling an HTTP Range header value.
Composes the range unit (default range(long, long), an open-ended range (from(long), and a
suffix range (suffix(long) — and spec(String) is a generic escape hatch.
Example:
String
See Also:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the renderedRange header value.from(long startValue) Adds an open-ended byte-range spec of the formstart- (from the position to the end).range(long startValue, long endValue) Adds a closed byte-range spec of the formstart-end .Generic escape hatch for adding any range spec verbatim.suffix(long length) Adds a suffix byte-range spec of the form-length (the finallengthbytes).toHeader()Builds aRangeheader bean directly from this builder.toString()Sets the range unit (defaultbytes ).
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
unit
Sets the range unit (defaultbytes ).- Parameters:
value- The range unit. Must not benull or blank.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifvalueisnull or blank.
-
range
Adds a closed byte-range spec of the formstart-end .- Parameters:
startValue- The first byte position (inclusive). Must be non-negative.endValue- The last byte position (inclusive). Must be greater than or equal tostartValue.- Returns:
- This object.
- Throws:
IllegalArgumentException- If the positions are negative or out of order.
-
from
Adds an open-ended byte-range spec of the formstart- (from the position to the end).- Parameters:
startValue- The first byte position (inclusive). Must be non-negative.- Returns:
- This object.
- Throws:
IllegalArgumentException- IfstartValueis negative.
-
suffix
Adds a suffix byte-range spec of the form-length (the finallengthbytes).- Parameters:
length- The number of trailing bytes. Must be non-negative.- Returns:
- This object.
- Throws:
IllegalArgumentException- Iflengthis negative.
-
spec
Generic escape hatch for adding any range spec verbatim.- Parameters:
value- The range spec (e.g."0-499" ). Must not benull or blank.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifvalueisnull or blank.
-
build
Builds the renderedRange header value.Returns an empty string when no range specs have been registered.
- Returns:
- The header value. Never
null .
-
toHeader
Builds aRangeheader bean directly from this builder. -
toString
-