⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageinfoimpl.java

📁 本项目是基于展示新闻的一款产品。在本系统中用户可以自定义栏目及新闻分类 发布新闻信息
💻 JAVA
字号:
package cn.handson.model.service.dao.page;

import java.util.List;


public class PageInfoImpl implements PageInfo{
	

	private List pageContent;
	   /* (non-Javadoc)
	 * @see cn.handson.model.service.dao.page.PageInfo#getPageContent()
	 */
	public List getPageContent() {
		return pageContent;
	}
	/* (non-Javadoc)
	 * @see cn.handson.model.service.dao.page.PageInfo#setPageContent(java.util.List)
	 */
	public void setPageContent(List list) {
		this.pageContent = list;
		
	}
	private int pageCount;
	   private int currentSize;
	   private long totalRec;
	   private long start;
	   private int currentNo;

	   public PageInfoImpl(int pageSize,long rowCount,int pageNo){
	      this.currentSize = pageSize;
	      this.totalRec = rowCount;
	      this.currentNo = pageNo;
	      this.start = getStartOfAnyPage( currentNo );

	      this.pageCount = ((int)totalRec + currentSize -1) / currentSize;

	      if(totalRec==0){
	        this.pageCount = 0;
	      }

	      if( this.currentNo == this.pageCount ){
	        this.currentSize = (int)totalRec-((this.currentNo-1) * pageSize);
	      }
	   }
	   /**
	    * Returns the amount of the pages of special pageable object.
	    * @return the amount of the pages.
	    */
	   public int getPageCount(){
	     return this.pageCount;
	   }

	   /**
	    * Returns the amount of total rows.
	    * @return the amount of total rows.
	    */
	   public long getRowCount(){
	     return this.totalRec;
	   }

	   /**
	    * If the current page is the last page,returns false,otherwise,returns true.
	    * @return if the current page is the last one.
	    */
	   public boolean getNextPage(){
	     return (this.currentNo < this.pageCount);
	   }

	   public boolean getPreviousPage(){
	     return (this.currentNo!=1);
	   }
	   /**
	    * Returns the current pagenumber.
	    * @return the current pagenumber.
	    */
	   public int getCurrentPageNo(){
	     return this.currentNo;
	   }
	   /**
	    * Returns the start index of previous page
	    * @return the start index of previous page
	    */
	   public int getStartOfPreviousPage(){
	     int pNo = this.currentNo - 1;
	     if( pNo<1 ){
	       pNo = 1;
	     }
	     return this.getStartOfAnyPage(pNo);
	   }
	   /**
	    * Returns the start index of next page
	    * @return the start index of next page
	    */
	   public int getStartOfNextPage(){
	     int pNo = this.currentNo + 1;
	     if( pNo > this.pageCount ){
	       pNo = this.pageCount;
	     }

	     return this.getStartOfAnyPage( pNo );
	   }
	   /**
	    * Returns the start index of any page
	    * @param pageNo the page no
	    * @return the start index of any page
	    */
	   public int getStartOfAnyPage(int pageNo){
	     int startIndex = ( pageNo - 1) * currentSize + 1;
	     if (startIndex < 1){
	       startIndex = 1;
	     }

	     return startIndex;
	   }
	   /**
	    * Returns the amount of the record in this page.
	    * @return  the amount of the record in this page.
	    */
	   public int getPageSize(){
	     return this.currentSize;
	   }
	   /**
	    * Return the start index of current page
	    * @return  the start index of current page
	    */
	   public long getStartIndex(){
	     return this.start;
	   }
	   /**
	    * Return the end index of current page
	    * @return the end index of current page
	    */
	   public long getEndIndex(){
	     return this.start + this.getPageSize() - 1;
	   }

	}


⌨️ 快捷键说明

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