码迷,mamicode.com
首页 > 编程语言 > 详细

java实现分页功能的类

时间:2017-07-29 01:00:53      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:span   this   turn   als   return   ast   private   eth   public   

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;
    }
    
    
}

 

java实现分页功能的类

标签:span   this   turn   als   return   ast   private   eth   public   

原文地址:http://www.cnblogs.com/lm970585581/p/7253022.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!