PageModel

2722 ワード

package com.itsv.yiliao.back.personnel.model;

import java.util.List;
/**
 *  
 * @author kingmxj 2009-11-11
 *
 */
public class PageModel {
	
	private List list;// 
	
	private int totalRecords;// 
	
	private int pageSize = 10;// 
	
	private int pageNo = 1;// 
	
	private int totalPages;// 
	
	private boolean firstPage;// 
	
	private boolean lastPage;// 
	
	/**
	 *  
	 * @return
	 */
	public int getTopPageNo() {
		return 1;
	}
	
	/**
	 *  
	 * @return
	 */
	public int getPreviousPageNo() {
		if (this.pageNo <= 1){
			return 1;
		}
		return this.pageNo - 1;
	}
	
	/**
	 *  
	 * @return
	 */
	public int getNextPageNo() {
		if (this.pageNo >= this.getBottomPageNo()) {
			return this.getBottomPageNo();
		}
		return this.pageNo + 1;
	}
	
	/**
	 *  
	 * @return
	 */
	public int getBottomPageNo() {
		return this.getTotalPages();
	}
	
	/**
	 *  
	 * @return
	 */
	public int getTotalPages() {
		if(this.totalRecords==0){
			return 1;
		}
		return (this.totalRecords + this.pageSize - 1)/this.pageSize;
	}

	/**
	 *  
	 * @return
	 */
	public boolean isFirstPage() {
		if(pageNo==1){
			return true;
		}
		return false;
	}

	/**
	 *  
	 * @return
	 */
	public boolean isLastPage() {
		if(pageNo==totalPages){
			return true;
		}
		return false;
	}
	
	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getPageSize() {
		return pageSize;
	}

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

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public void setFirstPage(boolean firstPage) {
		this.firstPage = firstPage;
	}

	public void setLastPage(boolean lastPage) {
		this.lastPage = lastPage;
	}
	
	
}