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 |
Range(int start,
int size)
Creates a new interval having the specified start and size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Range
public Range(int start,
int size)
- Creates a new interval having the specified start and size.
- Parameters:
start
- The start of the intervalsize
- The size of the interval
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
Copyright © 2004-2013 XWiki. All Rights Reserved.