|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ikrs.httpd.ContentRange
public class ContentRange
This is a wrapper/parser class for the HTTP Content-Range header. Note that the HTTP specs expect the last-byte-position to be inclusive which is pretty unlikely in Java (unsually read limits are specified the exclusive way). Don't get confused with that! Specs: (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) Content-Range = "Content-Range" ":" content-range-spec content-range-spec = byte-content-range-spec byte-content-range-spec = bytes-unit SP byte-range-resp-spec "/" ( instance-length | "*" ) byte-range-resp-spec = (first-byte-pos "-" last-byte-pos) | "*" instance-length = 1*DIGIT Examples: . The first 500 bytes: bytes 0-499/1234 . The second 500 bytes: bytes 500-999/1234 . All except for the first 500 bytes: bytes 500-1233/1234 . The last 500 bytes: bytes 734-1233/1234
Field Summary | |
---|---|
static java.lang.String |
NAME_BYTESUNIT_BYTES
|
Constructor Summary | |
---|---|
ContentRange(java.lang.String bytesUnit,
long firstBytePos,
long lastBytePos,
long instanceLen)
Create a new 'Content-Range' wrapper with the given values. |
Method Summary | |
---|---|
long |
calculateLength()
|
java.lang.String |
getBytesUnit()
Get the 'bytes-unit' value. |
long |
getFirstBytePosition()
Get the 'first-byte-position' value. |
long |
getInstanceLength()
Get the 'instance-length' value; the returned value is larger than or equal to 'last-byte-position' OR it is -1L, which means that the instance-length is currently unknown. |
long |
getLastBytePosition()
Get the 'last-byte-position' value. |
static void |
main(java.lang.String[] argv)
This is just for testing. |
static ContentRange |
parse(java.lang.String headerValue)
This static method parses the given 'Content-Range' header field value. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NAME_BYTESUNIT_BYTES
Constructor Detail |
---|
public ContentRange(java.lang.String bytesUnit, long firstBytePos, long lastBytePos, long instanceLen) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
bytesUnit
- The bytes-unit value (the only sipported value is NAME_BYTESUNIT_BYTES so far).firstBytePos
- The first byte position (absolute abd inclusive).lastBytePos
- The last byte position (absolute and inclusive).instanceLen
- The length of the whole instance.
java.lang.NullPointerException
- If 'bytesUnit' is null.
java.lang.IllegalArgumentException
- If any of the passed arguments is out of range.Method Detail |
---|
public java.lang.String getBytesUnit()
public long getFirstBytePosition()
public long getLastBytePosition()
public long calculateLength()
public long getInstanceLength()
public static ContentRange parse(java.lang.String headerValue) throws java.lang.NullPointerException, MalformedRequestException
java.lang.NullPointerException
MalformedRequestException
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |