reducepage.java

来自「提供hibernate,spring」· Java 代码 · 共 88 行

JAVA
88
字号
package phz.util.page;

public class ReducePage {

	private int currentPage;
	private int pageSize;
	private int totalSize;
	private int totalPage;

	public ReducePage(int currentPage, int totalSize, int pageSize) {
		this.currentPage = currentPage;
		this.totalSize = totalSize;
		this.pageSize = pageSize;

	}

	public ReducePage(int currentPage, int totalSize) {
		this.currentPage = currentPage;
		this.totalSize = totalSize;
		this.pageSize = 5;
	}

	public ReducePage(int totalSize) {
		this.currentPage = 1;
		this.totalSize = totalSize;
		this.pageSize = 5;
	}

	public boolean isHasFirst() {
		if (getCurrentPage() == 1)
			return false;
		return true;
	}

	public boolean isHasLast() {
		if (getCurrentPage() == getTotalPage())
			return false;
		return true;
	}

	public boolean isHasPrevious() {
		if (isHasFirst())
			return true;
		return false;
	}

	public boolean isHasNext() {
		if (isHasLast())
			return true;
		return false;
	}

	public int getCurrentPage() {
		if (currentPage < 1 || currentPage > getTotalPage()) {
			return 1;
		}
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public int getTotalPage() {
		totalPage = getTotalSize() / getPageSize();
		if (getTotalSize() % getPageSize() != 0)
			totalPage++;
		return totalPage;
	}

}

⌨️ 快捷键说明

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