Package com.xpn.xwiki.criteria.impl
Class Range
- java.lang.Object
-
- com.xpn.xwiki.criteria.impl.Range
-
public class Range extends Object
Immutable continuous integer range. It can be used for pagination
-
-
Constructor Summary
Constructors Constructor Description Range(int start, int size)
Creates a new interval having the specified start and size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAbsoluteSize()
int
getAbsoluteStart()
int
getSize()
int
getStart()
List<String>
subList(List<String> list)
Copy the given list and return a (smart) subList corresponding to this range.
-
-
-
Method Detail
-
getStart
public int getStart()
- See Also:
start
-
getAbsoluteStart
public int getAbsoluteStart()
- Returns:
- The absolute value (nonnegative) of this interval's start
-
getSize
public int getSize()
- See Also:
size
-
getAbsoluteSize
public int getAbsoluteSize()
- Returns:
- The absolute value (nonnegative) of this interval's size
-
subList
public List<String> subList(List<String> list)
Copy the given list and return a (smart) subList corresponding to this range. If the absolute size of this range is 0 (ALL) it returns an unmodified copy.Considering this 9 elements list : [0, 1, 2, 3, 4, 5, 6, 7, 8]
- Range 0 / 4 : will return [0, 1, 2, 3]
- Range -2 / 4 : will return [7, 8] (not enough elements for the given size)
- Range -2 / -4 : will return [3, 4, 5, 6]
- Range 2 / -4 : will return [0, 1] (not enough elements for the given size)
- Range 0 / -4 : will return [5, 6, 7, 8]
- Parameters:
list
- the list from which the sublist will be extracted- Returns:
- a sublist of the given list computed from this range
-
-