1 package org.tigris.scarab.util; 2 3 48 49 import java.util.List ; 50 51 56 public class ScarabPaginatedList 57 { 58 62 private int totalListSize; 63 64 68 private int resultsPerPage; 69 70 73 private int currentPageNumber; 74 75 78 private List window; 79 80 81 84 public ScarabPaginatedList() 85 { 86 window = null; 87 currentPageNumber = 0; 88 resultsPerPage = 0; 89 totalListSize = 0; 90 } 91 92 95 public ScarabPaginatedList(List l, int size, int pageNum, int perPage) 96 { 97 window = l; 98 totalListSize = size; 99 currentPageNumber = pageNum; 100 resultsPerPage = perPage; 101 } 102 103 107 public int getTotalListSize() 108 { 109 return totalListSize; 110 } 111 112 115 public int getNumberOfPages() 116 { 117 int r = 0; 118 119 if (resultsPerPage != 0) 120 { 121 r = (int)Math.ceil((float)totalListSize / resultsPerPage); 122 } 123 124 return r; 125 } 126 127 130 public int getPageNumber() 131 { 132 return currentPageNumber; 133 } 134 135 138 public int getPrevPageNumber() 139 { 140 int r = getPageNumber() - 1; 141 if (r < 0) 142 { 143 r = 0; 144 } 145 return r; 146 } 147 148 151 public int getNextPageNumber() 152 { 153 int r = getPageNumber() + 1; 154 if (r > getNumberOfPages()) 155 { 156 r = 0; 157 } 158 return r; 159 } 160 161 164 public int getResultsPerPage() 165 { 166 return resultsPerPage; 167 } 168 169 173 public List getList() 174 { 175 return window; 176 } 177 178 179 182 public void setTotalListSize(int size) 183 { 184 totalListSize = size; 185 } 186 187 190 public void setCurrentPageNumber(int pageNum) 191 { 192 currentPageNumber = pageNum; 193 } 194 195 198 public void setList(List list) 199 { 200 window = list; 201 } 202 203 204 } 205 | Popular Tags |