java实现分页功能的类详解编程语言

package smn.util; 
public class Pager { 
private int pageNow; 
private int pageSize=4; 
private int totalPage;//共有若干页 
private int totalSize;//纪录数 
private boolean hasFirst;//是否有首页 
private boolean hasPre;//是否有前一页 
private boolean hasNext;//是否有下一页 
private boolean hasLast;//是否有末页 
public Pager(int pageNow,int totalSize){ 
this.pageNow=pageNow; 
this.totalSize=totalSize; 
} 
public int getPageNow() { 
return pageNow; 
} 
public void setPageNow(int pageNow) { 
this.pageNow = pageNow; 
} 
public int getPageSize() { 
return pageSize; 
} 
public void setPageSize(int pageSize) { 
this.pageSize = pageSize; 
} 
public int getTotalPage() { 
//页数算法 
totalPage=getTotalSize()/getPageSize(); 
if(totalSize%pageSize!=0){ 
totalPage++; 
} 
return totalPage; 
} 
public void setTotalPage(int totalPage) { 
this.totalPage = totalPage; 
} 
public int getTotalSize() { 
return totalSize; 
} 
public void setTotalSize(int totalSize) { 
this.totalSize = totalSize; 
} 
public boolean isHasFirst() { 
//假如当前页数为第一页就没有首页 
if(pageNow==1){ 
return false; 
}else{ 
return true; 
} 
} 
public void setHasFirst(boolean hasFirst) { 
this.hasFirst = hasFirst; 
} 
public boolean isHasPre() { 
//假如有首页就有前一页 
if(this.isHasFirst()){ 
return true; 
}else{ 
return false; 
} 
} 
public void setHasPre(boolean hasPre) { 
this.hasPre = hasPre; 
} 
public boolean isHasNext() { 
//假如有尾页就有下一页 
if(this.isHasLast()){ 
return true; 
}else{ 
return false; 
} 
} 
public void setHasNext(boolean hasNext) { 
this.hasNext = hasNext; 
} 
public boolean isHasLast() { 
//假如不是最后一页就有尾页 
if(pageNow==this.getTotalPage()){ 
return false; 
}else{ 
return true; 
} 
} 
public void setHasLast(boolean hasLast) { 
this.hasLast = hasLast; 
} 
}

 

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/11706.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论