X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fcontrols%2FResultsPager.java;fp=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fcontrols%2FResultsPager.java;h=0000000000000000000000000000000000000000;hb=cd63f324cf98a553f9cea33c50b0d68985552a8d;hp=95a20480729cfe7205e3164469d678e20515a95a;hpb=0bd75b32a504b9e04c4ebc901b075a2be89ee359;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/pz2utils4jsf/controls/ResultsPager.java b/src/main/java/com/indexdata/pz2utils4jsf/controls/ResultsPager.java deleted file mode 100644 index 95a2048..0000000 --- a/src/main/java/com/indexdata/pz2utils4jsf/controls/ResultsPager.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.indexdata.pz2utils4jsf.controls; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import com.indexdata.pz2utils4jsf.controls.PageLink; -import com.indexdata.pz2utils4jsf.pazpar2.Pz2Session; -import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse; - -public class ResultsPager implements Serializable { - - private static final long serialVersionUID = 8854795222615583071L; - private Pz2Session pz2session = null; - private int pageRangeLength = 13; - - public ResultsPager(Pz2Session session) { - this.pz2session = session; - } - - public ResultsPager(Pz2Session session, int pageRange) { - this.pz2session = session; - this.pageRangeLength = pageRange; - } - - private boolean hasHits () { - return (getShow().getMerged()>0); - } - - public int getCurrentPageNum () { - if (hasHits() && getShow().getNum()>0) { - return (getShow().getStart()/getShow().getNum())+1; - } else { - return 0; - } - } - - public int getPageSize() { - return getShow().getNum(); - } - - public int getFirstDisplayedPageNum () { - if (hasHits()) { - if (getCurrentPageNum() - (pageRangeLength/2) < 1) { - return 1; - } else { - return (getCurrentPageNum()-(pageRangeLength/2)); - } - } else { - return 0; - } - } - - public int getLastDisplayedPageNum () { - if (hasHits()) { - if ((getFirstDisplayedPageNum() + pageRangeLength-1) > getLastPageNum()) { - return getLastPageNum(); - } else { - return getFirstDisplayedPageNum() + pageRangeLength - 1; - } - } else { - return 0; - } - } - - public int getLastPageNum () { - if (hasHits()) { - return (int) Math.ceil(new Double(getShow().getMerged())/new Double(getShow().getNum())); - } else { - return 0; - } - } - - public List setPageLinks (int rangeLength) { - this.pageRangeLength = rangeLength; - return getPageLinks(); - } - - public List getPageLinks () { - ArrayList range = new ArrayList(); - if (hasHits()) { - for (int i = getFirstDisplayedPageNum(); i>0 && i<=getLastDisplayedPageNum();i++) { - range.add(new PageLink(i+"",i,this)); - } - } - return range; - } - - - public PageLink getPreviousPageLink (String text) { - String linkText = (text!=null && text.length()>0 ? text : "Prev"); - if (hasHits() && getCurrentPageNum()>1) { - return new PageLink(linkText,getCurrentPageNum()-1,this); - } else { - return new PageLink(linkText,0,this); - } - } - - public PageLink getNextPageLink (String text) { - String linkText = (text!=null && text.length()>0 ? text : "Next"); - if (hasHits() && getCurrentPageNum()1; - } - - public boolean hasNextPage () { - return getCurrentPage() < getLastPageNum(); - } - - public boolean hasPageAfterLastDisplayed() { - return getLastDisplayedPageNum() < getLastPageNum(); - } - - - private ShowResponse getShow() { - return pz2session.getShow(); - } - -}