01: package com.completex.objective.components.persistency;
02:
03: /**
04: * Records page representation
05: */
06: public class Page {
07: private int number;
08: private int size;
09: private int offset;
10:
11: /**
12: *
13: * @param pageNumber page number starting with 1
14: * @param pageSize page size
15: */
16: public Page(int pageNumber, int pageSize) {
17: this .number = pageNumber;
18: this .size = pageSize;
19: offset(pageNumber, pageSize);
20: }
21:
22: private void offset(int pageNumber, int pageSize) {
23: offset = getOffset(pageNumber, pageSize);
24: }
25:
26: /**
27: * Returns page number starting with 1
28: *
29: * @return page number starting with 1
30: */
31: public int getNumber() {
32: return number;
33: }
34:
35: /**
36: * Returns page size
37: *
38: * @return page size
39: */
40: public int getSize() {
41: return size;
42: }
43:
44: /**
45: * Returns page offset starting with 0
46: *
47: * @return page offset starting with 0
48: */
49: public int getOffset() {
50: return offset;
51: }
52:
53: /**
54: * Returns page offset starting with 0
55: *
56: * @return page offset starting with 0
57: */
58: public static int getOffset(int pageNumber, int pageSize) {
59: return (pageNumber - 1) * pageSize;
60: }
61: }
|