Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Pagination |
|
| 1.0;1 |
1 | 0 | package pt.digitalis.dif.utils; |
2 | ||
3 | /** | |
4 | * Abstracts the various implementations of pagination | |
5 | * | |
6 | * @author Fábio Souto <a href="mailto:fsouto@digitalis.pt">fsouto@digitalis.pt</a><br/> | |
7 | * @created 9 de Nov de 2011 | |
8 | */ | |
9 | public class Pagination { | |
10 | ||
11 | /** The page to be presented */ | |
12 | 0 | private int page = 0; |
13 | /** The limit of results per page */ | |
14 | 0 | private int rowsPerPage = 0; |
15 | ||
16 | /** | |
17 | * Instantiates a new pagination object. The limit is always required, and at least one of the two parameters (page | |
18 | * or start) | |
19 | * | |
20 | * @param page | |
21 | * The page to be presented or null (start required) | |
22 | * @param rowsPerPage | |
23 | * The limit of results per page | |
24 | */ | |
25 | 0 | public Pagination(Integer page, Integer rowsPerPage) |
26 | { | |
27 | 0 | this.page = page; |
28 | 0 | this.rowsPerPage = rowsPerPage; |
29 | 0 | } |
30 | ||
31 | /** | |
32 | * Get the end row | |
33 | * | |
34 | * @return the end row | |
35 | */ | |
36 | public int getEndRow() | |
37 | { | |
38 | 0 | return this.page * this.rowsPerPage; |
39 | } | |
40 | ||
41 | /** | |
42 | * Get the page to be fetched | |
43 | * | |
44 | * @return The page to be fetched | |
45 | */ | |
46 | public int getPage() | |
47 | { | |
48 | 0 | return this.page; |
49 | } | |
50 | ||
51 | /** | |
52 | * Get the limit of results per page | |
53 | * | |
54 | * @return The limit of results per page | |
55 | */ | |
56 | public int getRowsPerPage() | |
57 | { | |
58 | 0 | return this.rowsPerPage; |
59 | } | |
60 | ||
61 | /** | |
62 | * Get the start row | |
63 | * | |
64 | * @return the start row | |
65 | */ | |
66 | public int getStartRow() | |
67 | { | |
68 | 0 | return (this.page - 1) * this.rowsPerPage; |
69 | } | |
70 | ||
71 | } |