|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.abstracthorizon.danube.http.util.Ranges
public class Ranges
Class keeping from and to pointers in a file
Nested Class Summary | |
---|---|
static class |
Ranges.Range
Single range definition |
Field Summary | |
---|---|
protected List<Ranges.Range> |
ranges
List of ranges for multi-range |
protected Ranges.Range |
singleRange
If this is a single range then it is stored here |
protected long |
size
Size of the resource or -1 if unkonwn |
Constructor Summary | |
---|---|
Ranges()
Constructor |
Method Summary | |
---|---|
void |
addRange(long from,
long to)
Adds next range |
protected boolean |
combine(Ranges.Range range1,
Ranges.Range range2)
Tries to combine two ranges. |
String |
format()
Formats value of this ranges object as specified in "Content-Range" |
List<Ranges.Range> |
getRanges()
Returns list of ranges |
Ranges.Range |
getSingleRange()
Returns single range or null |
long |
getSize()
Returns size or -1 if size is unknown |
boolean |
isMultiRange()
Returns true if this is multi-range |
protected void |
makeCanonic()
Makes this ranges in canonic form (as long as they are sorted |
static Ranges |
parseContentRange(String ranges)
Parses input string for ranges format |
protected static long |
parseLong(String input,
int from,
int to)
Parses input string from given index |
protected static boolean |
parseOneRange(String input,
int from,
int to,
Ranges result)
Parses one range in format of "xxx-yyy", "xxx-" or "-yyy" |
static Ranges |
parseRange(String ranges)
Parses input string for ranges format |
void |
setSize(long size)
Sets size |
String |
toString()
Returns string representation |
protected void |
updateSize(Ranges.Range range)
Updates size to prefix and suffix ranges |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Ranges.Range singleRange
protected List<Ranges.Range> ranges
protected long size
Constructor Detail |
---|
public Ranges()
Method Detail |
---|
public boolean isMultiRange()
true
if this is multi-range
true
if this is multi-rangepublic void setSize(long size)
size
- sizepublic long getSize()
public List<Ranges.Range> getRanges()
public Ranges.Range getSingleRange()
null
null
protected void updateSize(Ranges.Range range)
range
- range to be updatedpublic void addRange(long from, long to)
from
- fromto
- toprotected boolean combine(Ranges.Range range1, Ranges.Range range2)
true
. Otherwise result is
false
and ranges are unchanged.
range1
- range one and result in case of successrange2
- range two
true
if two ranges can be combinedprotected void makeCanonic()
public static Ranges parseRange(String ranges)
ranges
- input string
null
if incorrect formatpublic static Ranges parseContentRange(String ranges)
ranges
- input string
null
if incorrect formatprotected static boolean parseOneRange(String input, int from, int to, Ranges result)
input
- input stringfrom
- form indexto
- to indexresult
- result object to be populated with newly recognised range
true
if format is recognised, false
otherwiseprotected static long parseLong(String input, int from, int to)
input
- input stringfrom
- index to start parsing from
true
if there is at least one digitpublic String toString()
toString
in class Object
public String format()
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |