1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.calendar.service;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22
23
24
25
26 public class EventPageList<T> extends JCRPageList<T> {
27
28 private List<T> eventList_ = null;
29
30 public EventPageList(List<T> eventList, long pageSize) throws Exception {
31 super(pageSize);
32 eventList_ = eventList;
33 setAvailablePage(eventList_.size());
34 }
35
36 protected void populateCurrentPage(long page, String username) throws Exception {
37 setAvailablePage(eventList_.size());
38 long pageSize = getPageSize();
39 long position = 0;
40 if (page == 1)
41 position = 0;
42 else {
43 position = (page - 1) * pageSize;
44 }
45 currentListPage_ = new ArrayList<T>();
46 Long objPos = position;
47 if (position + pageSize > eventList_.size()) {
48 currentListPage_ = eventList_.subList(objPos.intValue(), eventList_.size());
49 } else {
50 Long objPageSize = pageSize;
51 currentListPage_ = eventList_.subList(objPos.intValue(), objPos.intValue() + objPageSize.intValue());
52 }
53 }
54
55 @Override
56 public List<T> getAll() throws Exception {
57 return eventList_;
58 }
59
60 }