public void lastPage() {
   long pageSize = getPageSize();
   long resultsCount = getResultsCount();
   if (pageSize == 0 || resultsCount < 0) {
     // do nothing
     return;
   }
   if (resultsCount % pageSize == 0) {
     setCurrentPageOffset(resultsCount - pageSize);
   } else {
     setCurrentPageOffset(resultsCount - resultsCount % pageSize);
   }
   pageChanged();
 }
 @Override
 public void setCurrentPageIndex(long currentPageIndex) {
   long pageSize = getPageSize();
   long offset = currentPageIndex * pageSize;
   setCurrentPageOffset(offset);
   pageChanged();
 }
 public void setPageSize(long pageSize) {
   long localPageSize = getPageSize();
   if (localPageSize != pageSize) {
     this.pageSize = pageSize;
     // reset offset too
     setCurrentPageOffset(0);
     refresh();
   }
 }
 public void nextPage() {
   long pageSize = getPageSize();
   if (pageSize == 0) {
     // do nothing
     return;
   }
   long offset = getCurrentPageOffset();
   offset += pageSize;
   setCurrentPageOffset(offset);
   pageChanged();
 }
 public void firstPage() {
   long pageSize = getPageSize();
   if (pageSize == 0) {
     // do nothing
     return;
   }
   long offset = getCurrentPageOffset();
   if (offset != 0) {
     setCurrentPageOffset(0);
     pageChanged();
   }
 }
 public void previousPage() {
   long pageSize = getPageSize();
   if (pageSize == 0) {
     // do nothing
     return;
   }
   long offset = getCurrentPageOffset();
   if (offset >= pageSize) {
     offset -= pageSize;
     setCurrentPageOffset(offset);
     pageChanged();
   }
 }