1 /* 2 * Copyright (c) 2002-2022, City of Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.util.html; 35 36 import java.io.Serializable; 37 38 import java.util.List; 39 40 /** 41 * Handles paging 42 * 43 * @param <E> 44 * the type 45 */ 46 public interface IPaginator<E> extends Serializable 47 { 48 /** Default value for Page Index Parameter */ 49 String PARAMETER_PAGE_INDEX = "page_index"; 50 51 /** Default value for Items Per Page Parameter */ 52 String PARAMETER_ITEMS_PER_PAGE = "items_per_page"; 53 String LABEL_FIRST = "|<"; 54 String LABEL_PREVIOUS = "<"; 55 String LABEL_NEXT = ">"; 56 String LABEL_LAST = ">|"; 57 58 /** 59 * Gets the number of pages 60 * 61 * @return the number of pages 62 */ 63 int getPagesCount( ); 64 65 /** 66 * Returns the List 67 * 68 * @return The List 69 */ 70 List<E> getPageItems( ); 71 72 /** 73 * Returns the current page index 74 * 75 * @return The current page index 76 */ 77 int getPageCurrent( ); 78 79 /** 80 * Returns the previous page link 81 * 82 * @return The previous page link 83 */ 84 String getFirstPageLink( ); 85 86 /** 87 * Returns the previous page link 88 * 89 * @return The previous page link 90 */ 91 String getPreviousPageLink( ); 92 93 /** 94 * Returns the previous page link 95 * 96 * @return The previous page link 97 */ 98 String getLastPageLink( ); 99 100 /** 101 * Returns the previous page link 102 * 103 * @return The previous page link 104 */ 105 String getNextPageLink( ); 106 107 /** 108 * Returns Pages Links 109 * 110 * @return Pages Links 111 */ 112 List<PaginatorPage> getPagesLinks( ); 113 114 /** 115 * Returns the index of the first item of the current page range 116 * 117 * @return The index of the first item of the current page range 118 */ 119 int getRangeMin( ); 120 121 /** 122 * Returns the index of the last item of the current page range 123 * 124 * @return The index of the last item of the current page range 125 */ 126 int getRangeMax( ); 127 128 /** 129 * Returns the number of items in the collection 130 * 131 * @return The number of items in the collection 132 */ 133 int getItemsCount( ); 134 135 /** 136 * Get First label 137 * 138 * @return The Label 139 */ 140 String getLabelFirst( ); 141 142 /** 143 * Get Previous label 144 * 145 * @return The Label 146 */ 147 String getLabelPrevious( ); 148 149 /** 150 * Get Next label 151 * 152 * @return The Label 153 */ 154 String getLabelNext( ); 155 156 /** 157 * Get First label 158 * 159 * @return The Label 160 */ 161 String getLabelLast( ); 162 163 /** 164 * Get Item Count label 165 * 166 * @return The Label 167 */ 168 String getLabelItemCount( ); 169 170 /** 171 * Get Item Count per page label 172 * 173 * @return The Label 174 */ 175 String getLabelItemCountPerPage( ); 176 177 /** 178 * Get the parameter name of the <code>items_per_page</code> 179 * 180 * @return the parameter name 181 */ 182 String getItemsPerPageParameterName( ); 183 184 /** 185 * Set the parameter name of the <code>items_per_page</code> 186 * 187 * @param strItemsPerPageParameterName 188 * the parameter name 189 */ 190 void setItemsPerPageParameterName( String strItemsPerPageParameterName ); 191 192 /** 193 * Gets the items count per page. 194 * 195 * @return items count per page. 196 */ 197 int getItemsPerPage( ); 198 }