PackageSmn.util; Public classPager {Private intPagenow; Private intPagesize=4; Private intTotalpage;//How many pages are there? Private intTotalSize;//number of records Private BooleanHasfirst;//do you have a home page Private BooleanHaspre;//whether there is a previous page Private BooleanHasnext;//do you have the next page ? Private BooleanHaslast;//do you have the last page PublicPager (intPagenow,inttotalsize) { This. pagenow=Pagenow; This. totalsize=totalsize; } Public intGetpagenow () {returnPagenow; } Public voidSetpagenow (intPagenow) { This. Pagenow =Pagenow; } Public intgetpagesize () {returnpageSize; } Public voidSetPageSize (intpageSize) { This. pageSize =pageSize; } Public intGettotalpage () {//page AlgorithmTotalpage=gettotalsize ()/getpagesize (); if(totalsize%pagesize!=0) {Totalpage++; } returnTotalpage; } Public voidSettotalpage (inttotalpage) { This. Totalpage =Totalpage; } Public intgettotalsize () {returntotalsize; } Public voidSettotalsize (inttotalsize) { This. TotalSize =totalsize; } Public BooleanIshasfirst () {//if the current number of pages is the first page there is no homepage if(pagenow==1){ return false; }Else{ return true; } } Public voidSethasfirst (BooleanHasfirst) { This. Hasfirst =Hasfirst; } Public BooleanIshaspre () {//If there is a homepage there is a previous page if( This. Ishasfirst ()) { return true; }Else{ return false; } } Public voidSethaspre (Booleanhaspre) { This. Haspre =Haspre; } Public BooleanIshasnext () {//If there's a last page, there's the next one . if( This. Ishaslast ()) { return true; }Else{ return false; } } Public voidSethasnext (BooleanHasnext) { This. Hasnext =Hasnext; } Public BooleanIshaslast () {//if it's not the last page, there 's the last. if(pagenow== This. Gettotalpage ()) { return false; }Else{ return true; } } Public voidSethaslast (Booleanhaslast) { This. Haslast =Haslast; } }
Java class for paging functionality