| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PagingParameters |
|
| 1.5714285714285714;1.571 |
| 1 | package net.spy.digg; | |
| 2 | ||
| 3 | /** | |
| 4 | * Base class for paging parameters. | |
| 5 | */ | |
| 6 | public abstract class PagingParameters { | |
| 7 | ||
| 8 | /** | |
| 9 | * The minimum value for a count. | |
| 10 | */ | |
| 11 | public static final int MIN_COUNT = 0; | |
| 12 | /** | |
| 13 | * The maximum value for a count. | |
| 14 | */ | |
| 15 | public static final int MAX_COUNT = 100; | |
| 16 | 0 | private String sort = null; |
| 17 | 0 | private Integer count = null; |
| 18 | 0 | private Integer offset = null; |
| 19 | ||
| 20 | public PagingParameters() { | |
| 21 | 0 | super(); |
| 22 | 0 | } |
| 23 | ||
| 24 | public Integer getCount() { | |
| 25 | 0 | return count; |
| 26 | } | |
| 27 | ||
| 28 | /** | |
| 29 | * Set the number of results to return. | |
| 30 | * @param to an integer between MIN_COUNT and MAX_COUNT (inclusive). | |
| 31 | */ | |
| 32 | public void setCount(int to) { | |
| 33 | 0 | if(to < MIN_COUNT || to > MAX_COUNT) { |
| 34 | 0 | throw new IllegalArgumentException("Count out of range."); |
| 35 | } | |
| 36 | 0 | count = to; |
| 37 | 0 | } |
| 38 | ||
| 39 | /** | |
| 40 | * Get the result offset. | |
| 41 | */ | |
| 42 | public Integer getOffset() { | |
| 43 | 0 | return offset; |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Set the result offset. | |
| 48 | * @param to a positive integer | |
| 49 | */ | |
| 50 | public void setOffset(int to) { | |
| 51 | 0 | if(to < 0) { |
| 52 | 0 | throw new IllegalArgumentException("Offset must be positive"); |
| 53 | } | |
| 54 | 0 | offset = to; |
| 55 | 0 | } |
| 56 | ||
| 57 | /** | |
| 58 | * Get the sort type. | |
| 59 | */ | |
| 60 | public String getSort() { | |
| 61 | 0 | return sort; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Set the sort type. | |
| 66 | */ | |
| 67 | public void setSort(String to) { | |
| 68 | 0 | sort = to; |
| 69 | 0 | } |
| 70 | ||
| 71 | } |