/*
 * Pager.java created on 2012-4-19 下午1:32:48 by xie-qing
 */

package com.dgt.graphdemo.entity.fqz;

import java.io.Serializable;
import java.util.*;

/**
 * 分页对象
 * @author: xie-qing
 * @since: 2012-4-19
 */
public class Pager<T> implements Serializable {

	private static final long serialVersionUID = -674342573401174523L;

	public final static String CURRENT_PAGE = "currentPage";
	
	public final static String LIMIT_NUM = "limit";

	private int limit = 10;

	private boolean hasPre;

	private boolean hasNext;

	private int currentPage = 1;

	private Long total;

	private boolean needPage = true;

	private transient List<T> dataList = new ArrayList<T>();

	//专门标识人的标识位
	private List<String> tagList;



	private List<Integer> limitList = new ArrayList<Integer>();

	private String ids;

	private Date beginDate;

	private Date endDate;

	private String submitFlag;

	private transient Map<String, Object> param = new HashMap<String, Object>();

	/**容器ID,主要用来load进分页页面的：  $("#"+tdId).load(url,param,function(){......*/
	private String containerId;

	/**上一页,下一页等调用的url： ${ctx}/BestDataMonitor/user/list.do*/
	private String url;

	/**
	 * myPagination分页组件传过来的当前页数(第几页)
	 */
	public final static String MY_PAGINATION_CURRENT_PAGE = "page";

	public Pager() {

	}

	public Pager(boolean needPage) {
		this.needPage = needPage;
	}

	public Pager(int currentPage, Long total) {
		super();
		this.currentPage = currentPage;
		this.total = total;
	}

	public Pager(int limit, int currentPage, Long total) {
		super();
		this.limit = limit;
		this.currentPage = currentPage;
		this.total = total;
	}

	public int getTotalPage() {
		try {
			if (0 == total) {
				return 1;
			}
		} catch (Exception e) {
			return 1;
		}
		return (int) (total - 1) / this.getLimit() + 1;
	}

	public boolean isFirstPage() {
		return 1 == currentPage ? true : false;
	}

	public boolean isLastPage() {
		return currentPage == getTotalPage() ? true : false;
	}

	/** 获取上一页是第几页 */
	public int getPrePage() {
		return currentPage - 1;
	}

	/** 获取下一页是第几页 */
	public int getNextPage() {
		return currentPage + 1;
	}

	// /////////////////////////////////////////////////////////////////////////

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public boolean isHasPre() {
		return hasPre;
	}

	public void setHasPre(boolean hasPre) {
		this.hasPre = hasPre;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}

	public int getCurrentPage() {
		return currentPage;
	}

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

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public boolean isNeedPage() {
		return needPage;
	}

	public void setNeedPage(boolean needPage) {
		this.needPage = needPage;
	}

	public List<T> getDataList() {
		return dataList;
	}

	public void setDataList(List<T> dataList) {
		this.dataList = dataList;
	}

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getSubmitFlag() {
		return submitFlag;
	}

	public void setSubmitFlag(String submitFlag) {
		this.submitFlag = submitFlag;
	}

	public Map<String, Object> getParam() {
		return param;
	}

	public void setParam(Map<String, Object> param) {
		this.param = param;
	}

	public String getContainerId() {
		return containerId;
	}

	public void setContainerId(String containerId) {
		this.containerId = containerId;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public List<String> getTagList() {
		return tagList;
	}

	public void setTagList(List<String> tagList) {
		this.tagList = tagList;
	}

	public List<Integer> getLimitList() {
		limitList.add(5);
		limitList.add(10);
		limitList.add(12);
		limitList.add(15);
		limitList.add(20);
		limitList.add(50);
		limitList.add(100);
		limitList.add(1000);
		return limitList;
	}

	public void setLimitList(List<Integer> limitList) {
		this.limitList = limitList;
	}

}
