001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.search.config;
029
030import org.opencms.jsp.search.controller.I_CmsSearchControllerPagination;
031
032import java.util.List;
033
034/** The interface a pagination configuration must implement. */
035public interface I_CmsSearchConfigurationPagination {
036
037    /**
038     * Calculates the number of pages for the provided number of results.
039     * @param numFound the number of results
040     * @return the number of result pages for the provided number of results.
041     */
042    int getNumPages(long numFound);
043
044    /** Returns the length of a "Google"-like navigation. Should typically be an odd number.
045     * @return The length of a "Google"-like navigation.
046     */
047    int getPageNavLength();
048
049    /** Returns the request parameter that should be used to send the current page.
050     * @return The request parameter that should be used to send the current page.
051     */
052    String getPageParam();
053
054    /** Returns the page size of pages that have not explicitely a size set.
055     *
056     * That means, if you specify the sizes [5,8], meaning the first page should have 5 entries, all others 8,
057     * the size 8 is returned by the method.
058     *
059     * To get the size of a specific page use {@link I_CmsSearchConfigurationPagination#getSizeOfPage(int)}.
060     *
061     * @return The page size of pages that have not explicitely a size set.
062     *
063     * @deprecated use either {@link I_CmsSearchConfigurationPagination#getSizeOfPage(int)} to get the size
064     * for a specific page or {@link I_CmsSearchControllerPagination#getCurrentPageSize()} to get the size
065     * of the current page.
066     */
067    @Deprecated
068    int getPageSize();
069
070    /** Returns the page sizes as configured for the first pages of the search.
071     * The last provided size is the size of all following pages.
072     * @return the configured page sizes for the first pages.
073     */
074    List<Integer> getPageSizes();
075
076    /** Returns the page size for the provided page.
077     * @param pageNum the number of the page (starting with 1) for which the size should be returned.
078     * @return The page size for the provided page.
079     */
080    int getSizeOfPage(int pageNum);
081
082    /**
083     * Returns the index of the first item to show on the given page.
084     * @param pageNum the number of the page, for which the index of the first item to show on is requested.
085     * @return the index of the first item to show on the provided page.
086     */
087    int getStartOfPage(int pageNum);
088
089}