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

📄 pageserviceimpl.java

📁 本系统实现了从五个网站上搜索的图书进行整合后
💻 JAVA
字号:
package com.booksearch.service.process;

/**
 * Class:PageServiceImpl
 * Description: 获得分页工具栏
 * extens:no
 * implements PageService
 * @author  feng guang
 * @since   11/16/08
 */
public class PageServiceImpl implements PageService {
		
	    /*当前页号码*/
	    private long currentPageNo;  
	    /*页数总数*/
	    private long pageCount;
	    /*上一页 */ 
	    private long previousPageNo;
	    /*下一页*/
	    private long nextPageNo;
	    /*用来判断是否是第一页*/
	    private boolean isFirstPage;
	    /*用来判断是否是最后一页*/
	    private boolean isLastPage = false;
	    /*用来判断是否有前页*/
	    private boolean hasPreviousPage;

		/**
		* Function:  setCurrentPageNo
		* Description:  设置当前页数
		* Calls:  no
		* Called By:  PageAction.execute()
		* @param currentPageNo as int
		* @return void
		* @throws no
		*/
	    public void setCurrentPageNo(long currentPageNo){
	        /*设置当前页*/
	        this.currentPageNo = currentPageNo;
	        
	        /*每次设置当前页时更新上一页、下一页、是否首页、是否末页、是否有上一页、是否有下一页标志*/
	        isFirstPage = (currentPageNo == 1)?true:false;
	        hasPreviousPage = (currentPageNo == 1)? false:true;
            /*如果hasPreviousPage为ture则设置前一页,如果为false则把当前页设置前一页*/
	        previousPageNo = (hasPreviousPage)? (currentPageNo - 1):currentPageNo;
	        nextPageNo = currentPageNo + 1;
	        isLastPage=(currentPageNo==pageCount)?true:false;
	    }

		/**
		* Function:  getPageToolBar
		* Description: 取到页数导航字符串
		* Calls:  no
		* Called By:  PageAction.execute()
		* @param no
		* @return String
		* @throws no
		*/
	    public String getPageToolBar(){
	    	String str = "<div class='manu'>";
	    	/*设置分页工具栏中的上一页*/
	    	if(isFirstPage&&isLastPage){
	    		return str;
	    	}
	    	else
	    	{  if(isFirstPage){
	    		    str+="<span class='disabled'> <  Prev</span>";
	    		}else{
	    		str += "<a href='Page.do?page=" + previousPageNo + "'><  Prev</a>&nbsp;";
	    		}
	    	}

	       	/*设置分页工具栏要显示的页数,并设置每一页的超链接*/
	    	for(long j=10;j<=pageCount+10;j+=10){
	    	   if((currentPageNo<=j)&&(currentPageNo>=j-10)){	

	    	         for( long i=j-9; (i<=j)&&(i<=pageCount);i++){
	    		           if(i == currentPageNo){
	    			           str += "<span class='current'>"+ i+"</span>";
	    		           }
	    		           else{
	    			           str += "<a href='Page.do?page=" + i + "'>" + i + "</a>&nbsp;";
	    		           }
	    	          }
	    	         break;
	    	   }
	       }    	
	    	   	
	    	/*根据是否为最后一页来设置分页工具栏中的下一页*/
	    	if(isLastPage){
	    		str+="<span class='disabled'> Next  ></span>";
	    	}
	    	else{    		
	    		str += "&nbsp;<a href='Page.do?page=" + nextPageNo + "'>Next  > </a>&nbsp;";
	    	}
	        str+="</div>";
	    	return str;
	    }
		/**
		* Function:  getCurrentPageStartRecord
		* Description: 设置当前页的起始记录
		* Called By:  PageAction.execute()
		* @param no
		* @return int
		*/
	    public long getCurrentPageStartRecord(){
	        return (currentPageNo - 1) * 10;
	    }
	    
		/**
		* Function:  getCurrentPageEndRecord
		* Description: 设置当前页的结束记录
		* Called By:  PageAction.execute()
		* @param no
		* @return int
		*/
	    public long getCurrentPageEndRecord(){
	        return (currentPageNo -1) * 10 + 9;
	    }
		/**
		* Function:  isLastPage
		* Description: 判断当前页是否是最后一页
		* Called By:  PageAction.execute()
		* @param no
		* @return boolean
		*/
		public boolean isLastPage() {
			
			return isLastPage;
		}
		/**
		* Function:  setLastPage
		* Description: 设置当前页是否是最后一页
		* Called By:  PageAction.execute()
		* @param isLastPage as boolean
		* @return void
		*/
		public void setLastPage(boolean isLastPage) {
			this.isLastPage = isLastPage;
		}    
		/**
		* Function:  getPageCount
		* Description: 取得当前页
		* Called By:  PageAction.execute()
		* @param no
		* @return int
		*/
	    public long getPageCount(){
	    	
			return currentPageNo;    	
	    }
		/**
		* Function:  setPageCount
		* Description: 设置当前页
		* Called By:  PageAction.execute()
		* @param pageCount as int
		* @return void
		*/
		public void setPageCount(long pageCount) {
			this.pageCount = pageCount;
		}


}

⌨️ 快捷键说明

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