package cn.com.oims.common;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
 * list的分页查询以及和Map之间的转换,当前页,每页显示条数,总页数。
 * @author GuoBaoqiang
 *
 */

public class getListForPage {
	/**
	 * 分页方法
	 * 
	 * @param list
	 *            源数据
	 * @param currentPage
	 *            当前页
	 * @param maxNum
	 *            每页显示几条
	 * @param pageNum
	 *            总页数
	 * @return
	 */
	public static List getPageList(List list, int currentPage, int maxNum,
			int pageNum) {

		int fromIndex = 0; // 从哪里开始截取
		int toIndex = 0; // 截取几个
		if (list == null || list.size() == 0)
			return null;
		// 当前页小于或等于总页数时执行
		if (currentPage <= pageNum && currentPage != 0) {
			fromIndex = (currentPage - 1) * maxNum;

			if (currentPage == pageNum) {
				toIndex = list.size();
				
			} else {
				toIndex = currentPage * maxNum;
			}

		}
		return list.subList(fromIndex, toIndex);
	}
	/**
	 * 和list之间的转化
	 * 
	 */
	public static boolean checkList(Map map,List list){
		boolean flag=false;
		List l=new ArrayList();
		
		Set set=map.keySet();
		Iterator iterator=set.iterator();
		while(iterator.hasNext()){
			l.add(map.get(iterator));
		}
		for (int i = 0; i < l.size(); i++) {
			if(l.get(i).equals(list.get(i))){
				flag=true;
			}
			else
				flag=false;
		}
		return flag;
	}
}
最近下载更多
tangjj7260  LV18 2021年12月8日
疯啦ad啊  LV12 2019年10月10日
最代码酒酒  LV20 2019年9月27日
mysteel12  LV1 2019年5月10日
一道念  LV10 2019年3月29日
张琳srml  LV6 2018年4月9日
271972030  LV9 2018年3月14日
gann2015  LV24 2016年9月12日
364502984  LV18 2016年1月12日
yanxinqiu  LV2 2015年1月6日
最近浏览更多
微信网友_6802139027345408  LV2 2023年12月31日
lironggang  LV38 2023年3月26日
heqian  LV16 2023年1月10日
qwdqwdqw  LV3 2022年12月2日
tangjj7260  LV18 2021年12月8日
.空运绵熊.  LV1 2021年6月5日
Diontll  LV3 2020年11月23日
yale1422688399  LV3 2020年11月16日
kerry0304  LV4 2020年5月9日
能不能不存在  LV13 2020年4月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友