org.zodiac.netty.http.headers.Range Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
/**
* A range, used in Range and Content-Range headers.
*
*/
public interface Range {
/**
* Get the starting value of the range, given the passed total
* number of bytes that could be served; returns -1 if the result
* is an invalid range given that number of bytes.
* @param max The total bytes available to serve
* @return The start point
*/
long start(long max);
/**
* Get the ending value of the range, given the passed total
* number of bytes that could be served; returns -1 if the result
* is an invalid range given that number of bytes.
* @param max The total bytes available to serve
* @return The start point
*/
long end(long max);
/**
* Convert this range to a bounded range suitable for use in a
* Content-Range header.
* @param max The number of bytes that could be served
* @return A bounded range
*/
BoundedRangeNetty toBoundedRange(long max);
default long length(long max) {
return (end(max) + 1) - start(max);
}
}