1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.client.runtime.util;
20
21 import java.math.BigInteger;
22 import java.util.List;
23
24
25
26
27
28
29 public abstract class AbstractPageFetcher<T> {
30
31 protected long maxNumItems;
32
33 protected AbstractPageFetcher(long maxNumItems) {
34 this.maxNumItems = maxNumItems;
35 }
36
37
38
39
40
41
42 protected abstract Page<T> fetchPage(long skipCount);
43
44
45
46
47
48
49 public static class Page<T> {
50 private final List<T> items;
51 private final Long totalNumItems;
52 private final Boolean hasMoreItems;
53
54 public Page(List<T> items, BigInteger totalNumItems, Boolean hasMoreItems) {
55 this.items = items;
56 this.totalNumItems = totalNumItems == null ? null
57 : Long.valueOf(totalNumItems.longValue());
58 this.hasMoreItems = hasMoreItems;
59 }
60
61 public Page(List<T> items, long totalNumItems, boolean hasMoreItems) {
62 this.items = items;
63 this.totalNumItems = Long.valueOf(totalNumItems);
64 this.hasMoreItems = Boolean.valueOf(hasMoreItems);
65 }
66
67 public List<T> getItems() {
68 return items;
69 }
70
71 public Long getTotalNumItems() {
72 return totalNumItems;
73 }
74
75 public Boolean getHasMoreItems() {
76 return hasMoreItems;
77 }
78 }
79
80 public void setMaxNumItems(int maxNumItems) {
81 this.maxNumItems = maxNumItems;
82 }
83
84 }