Package org.dellroad.msrp.msg
Class ByteRange
- java.lang.Object
-
- org.dellroad.msrp.msg.ByteRange
-
public class ByteRange extends Object
MSRPByte-Rangeheader value.Instances are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static ByteRangefromString(String string)Create an instance by parsing aString.longgetEnd()Get the end byte position.longgetStart()Get the start byte position.longgetTotal()Get the total number of bytes.inthashCode()StringtoString()
-
-
-
Constructor Detail
-
ByteRange
public ByteRange(long total)
Constructs an instance indicating the entire content with the specified length. Equivalent toByteRange(1, total, total).- Parameters:
total- total number of bytes, or -1 if unspecified- Throws:
IllegalArgumentException- iftotalis less than -1
-
ByteRange
public ByteRange(long start, long end, long total)Constructor.- Parameters:
start- start byte position (1-based)end- end byte position (1-based), or -1 if unspecifiedtotal- total number of bytes, or -1 if unspecified- Throws:
IllegalArgumentException- ifstartis less than 1IllegalArgumentException- ifendortotalis less than -1IllegalArgumentException- ifendis not -1 andstart - 1is greater thanendIllegalArgumentException- iftotalis not -1 andendis greater thantotal
-
-
Method Detail
-
getStart
public long getStart()
Get the start byte position.- Returns:
- start byte position, at least one
-
getEnd
public long getEnd()
Get the end byte position.- Returns:
- end byte position, or -1 if not specified
-
getTotal
public long getTotal()
Get the total number of bytes.- Returns:
- total number of bytes, or -1 if not specified
-
fromString
public static ByteRange fromString(String string)
Create an instance by parsing aString.- Parameters:
string- byte range expressed as a string- Returns:
- corresponding
ByteRange - Throws:
IllegalArgumentException- ifstringis null or invalid
-
-