written by//13, today (17) Copy to Blog Park
Packagecom.sicdt.sicsign.web.utils;Importjava.io.Serializable;Importjava.util.List;/** * @authorShizhenwei * *@param<T> used to return the list to the front desk*/ Public classPageinfo<t>ImplementsSerializable {Private Static Final LongSerialversionuid = 1L; //the number of records displayed per page PrivateInteger pageSize; //Current Page Count PrivateInteger Pagenum; //Total Record Count PrivateInteger RowCount; //total number of pages PrivateInteger PageCount; //how many records to start with when querying PrivateInteger Rowstart; //How many page numbers are displayed per page PrivateInteger Everypagetabscount; //number of start pages to display per page PrivateInteger Everypagestart; //the number of end pages displayed per page PrivateInteger Everypageend; //do you have a previous page Private BooleanHasprevious =false; //Home Page PrivateInteger Firstpagenum; //Previous Page PrivateInteger Priviouspagenum; //do you have the next page ? Private BooleanHasnext =false; //Next Page PrivateInteger Nextpagenum; //last page PrivateInteger Endpagenum; //The data that is stored in this paging query PrivateList<t>list; /*** The values of other properties are calculated by the constructor *@paramPageSize *@paramPagenum *@paramRowCount*/ PublicPageInfo (Integer pagenum,integer pagesize,integer rowcount,integer everypagetabscount) {//the number of records displayed per page This. pageSize = PageSize = =NULL? 10: pageSize; //Current Page Count This. Pagenum = Pagenum = =NULL? 1: Pagenum; //Total Record Count This. RowCount = RowCount = =NULL? 0: RowCount; //Each page shows how many page numbers default 10, can set This. Everypagetabscount = Everypagetabscount = =NULL? 10: Everypagetabscount; //total number of pages This. PageCount = (int) Math.ceil ( This. RowCount * 1.0/ This. pageSize); //determines whether the current page number is greater than the total number of pages if( This. pagenum > This. PageCount && This. PageCount >= 1) { This. Pagenum = This. PageCount; } //how many records to start with when querying This. Rowstart = ( This. pageNum-1) * This. pageSize; //number of start pages to display per page This. Everypagestart = ( This. Pagenum- This. everypagetabscount/2) > 0? ( This. Pagenum- This. EVERYPAGETABSCOUNT/2): 1; /*** * * will be displayed as a fixed number of pages starting from the first page, when the total number of pages is less than a fixed number of pages * * **/ intCennum = (int) Math.ceil ( This. everypagetabscount/2.0)); if( This. pagecount>= This. Everypagetabscount && This. pagenum<= ( This. EVERYPAGETABSCOUNT/2)){ This. Everypageend = This. Everypagetabscount; }Else if( This. pagecount<= This. Everypagetabscount) { This. Everypageend = This. PageCount; }Else{ //the number of end pages displayed per page This. Everypageend = ( This. Pagenum + cenNum-1) > This. PageCount? This. PageCount: ( This. Pagenum + cenNum-1); } if( This. pagecount>= This. Everypagetabscount && This.pagenum> ( This. pagecount-(cenNum-1))){ This. everypagestart= This. pagecount-( This. everyPageTabsCount-1); } //do you have a previous page if( This. pagenum > 1) { This. hasprevious =true; This. Firstpagenum = 1; This. Priviouspagenum = This. pageNum-1; } //do you have the next page ? if( This. pagenum < This. PageCount) { This. Hasnext =true; This. Nextpagenum = This. pagenum + 1; This. Endpagenum = This. PageCount; } } PublicInteger getpagesize () {returnpageSize; } PublicInteger Getpagenum () {returnPagenum; } PublicInteger GetRowCount () {returnRowCount; } PublicInteger Getpagecount () {returnPageCount; } PublicInteger Getrowstart () {returnRowstart; } PublicInteger Geteverypagestart () {returnEverypagestart; } PublicInteger geteverypageend () {returnEverypageend; } Public Booleanishasprevious () {returnhasprevious; } PublicInteger Getfirstpagenum () {returnFirstpagenum; } PublicInteger Getpriviouspagenum () {returnPriviouspagenum; } Public BooleanIshasnext () {returnHasnext; } PublicInteger Getnextpagenum () {returnNextpagenum; } PublicInteger Getendpagenum () {returnEndpagenum; } PublicList<t>getList () {returnlist; } Public voidSetlist (list<t>list) { This. List =list; } PublicInteger Geteverypagetabscount () {returnEverypagetabscount; } Public voidSeteverypagetabscount (Integer everypagetabscount) { This. Everypagetabscount =Everypagetabscount; }}
Java Paging Tool class