Page Control

xiaoxiao2021-03-06  101

Package vincent.util;

public class PageControl {public int totalRowsAmount; // total rows public boolean rowsAmountSet; // whether the totalRowsAmout has been reset public int pageSize = 5; // the rows in one page default to 1 public int currentPage = 1; // the current page number public int nextPage; public int previousPage; public int totalPages; // total pages number public boolean hasNext; // whether it has next page public boolean hasPrevious; // whether it has previous page public String description; int pageStartRow; int pageEndRow ; / ** * the constructor * @param totalRows * / public PageControl (int totalRows) {setTotalRowsAmount (totalRows);} public PageControl () {} / ** * set the total rows amount * @param totalRows * / public void setTotalRowsAmount (int totalRows) {if (this.rowsAmountSet!) {totalRowsAmount = totalRows; // introduce "divide" to make the even out int divide = totalRowsAmount / pageSize; if (totalRowsAmount == divide * pageSize) {totalPages = divide;} Else {Totalpages = Divide 1;} setCurrentPage (1); this.rowsAmountSet = true;}} / ** * set the current page to the specified number * @param pageNumber * / public void setCurrentPage (int pageNumber) {currentPage = pageNumber; nextPage = currentPage 1; previousPage = currentPage-1; // Count the start row and the end row if (currentPage * pageSize

0) {HaspRevious = false;} else {HaspRevious = true;}; system.out.println (this.description ());} / ** * get the current page * @return * / public int getCurrentPage () {Return currentPage;} / ** * whether it has next page * @return * / public boolean isHasNext () {return hasNext;} / ** * whether it has previous page * @return * / public boolean isHasPrevious () {return hasPrevious; } // a bunch of get public int getNextPage () {return nextPage;} public int getPageSize () {return pageSize;} public int getPreviousPage () {return previousPage;} public int getTotalPages () {return totalPages;} public int getTotalRowsAmount () {return totalRowsAmount;} public void setHasNext (boolean b) {hasNext = b;} public void setHasPrevious (boolean b) {hasPrevious = b;} public void setNextPage (int i) {nextPage = i;} public void setPageSize ( INT i) {pagesize = i;} public void setpreviouspage (INT i) {previouspage = i;} public void settotalpages (int i) {totalpages = i;} public int getPageEndRow () {return pageEndRow;} public int getPageStartRow () {return pageStartRow;} public String getDescription () {String description = "Total:" this.getTotalRowsAmount () "items" this.getTotalPages () "pages"; // this.currentpage "previous" this.hasprevious // "Next:" this.hasnext // "Start Row:" this.pagestRow // "End Row:" THIS .pageendrow; return description;} public string description () {string description = "Total:" this.gettotalrowsamount () "items" THITTOTATIONOTALPAGES () "

pages, Current page: " this.currentPage " Previous " this.hasPrevious " Next: " this.hasNext " start row: " this.pageStartRow " end row: " this.pageEndRow; return description;}}

转载请注明原文地址:https://www.9cbs.com/read-123648.html

New Post(0)