pagination.java

来自「Speedframework--基于类型元数据的羽量级ORM.完全基于Java类」· Java 代码 · 共 148 行

JAVA
148
字号

package org.speedframework.entity;

/**
 * <p>Title: SpeedFrameworkWork持久层框架</p>
 *
 * <p>Description: 分页类</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: SpeedFrameworkWork</p>
 * @author 李志峰 电话:13824431576
 * @version 1.1beta
 */
public class Pagination {
  /**
   * 每页显示行数
   */
  private int count = 10; //每页显示行数

  /**
   * 总行数
   */
  private int totalCount = 0; //总行数

  /**
   * 总页数
   */
  private int totalPage = 0; //总页数

  /**
   * 从页面传过来的页数
   */
  private int page = 0; //从页面传过来的页数

  /**
   * 是否有下一页
   */
  private boolean hasNextPage = false; //是否有下一页

  /**
   * 是否有前一页
   */
  private boolean hasPreviousPage = false; //是否有前一页

  /**
   * @return Returns the count.
   */
  public int getCount() {
    return count;
  }

  /**
   * @param count The count to set.
   */
  public void setCount(int count) {
    this.count = count;
  }

  /**
   * @return Returns the currPage.
   */
  public int getCurrPage() {
    return page;
  }

  /**
   * @return Returns the totalPage.
   */
  public int getTotalPage() {
    totalPage = totalCount / count;
    if (totalCount % count > 0 || totalPage == 0) {
      totalPage += 1;
    }
    return totalPage;
  }

  /**
   * @return Returns the page.
   */
  public int getPage() {
    return this.page;
  }

  /**
   * @param page The page to set.
   */
  public void setPage(int page) {
    this.page = page;
  }

  /**
   * @return Returns the totalCount.
   */
  public int getTotalCount() {
    return totalCount;
  }

  /**
   * @param totalCount The totalCount to set.
   */
  public void setTotalCount(int totalCount) {
    this.totalCount = totalCount;
  }

  /**
   * @return Returns the hasNextPage.
   */
  public boolean isHasNextPage() {
    if (getCurrPage() >= getTotalPage()) {
      hasNextPage = false;
    }
    else {
      hasNextPage = true;
    }
    return hasNextPage;
  }

  /**
   * @return Returns the hasPreviousPage.
   */
  public boolean isHasPreviousPage() {
    if ( (getCurrPage() - 1) > 0) {
      hasPreviousPage = true;
    }
    else {
      hasPreviousPage = false;
    }
    return hasPreviousPage;
  }

  /**
   * 获得下一页的页数
   * @return
   */
  public int getNextPage() {
    return page + 1;
  }

  /**
   * 获得上一页的页数
   * @return
   */
  public int getPreviousPage() {
    return page - 1;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?