001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo 018 */ 019package org.nuxeo.ecm.automation.core.util; 020 021import java.util.List; 022import java.util.Map; 023 024import org.nuxeo.ecm.platform.query.api.Aggregate; 025import org.nuxeo.ecm.platform.query.api.Bucket; 026import org.nuxeo.ecm.platform.query.api.QuickFilter; 027 028/** 029 * @author <a href="mailto:[email protected]">Tiry</a> 030 * @since 5.7 (extracted from PaginableDocumentModelList) 031 */ 032public interface Paginable<T> extends List<T> { 033 034 /** 035 * Returns the number of results per page. 0 means no pagination. 036 */ 037 long getPageSize(); 038 039 /** 040 * Returns the max number of results per page. 0 means no pagination. 041 * <p> 042 * If page size is greater than this maximum value, it will be taken into account instead. 043 */ 044 long getMaxPageSize(); 045 046 /** 047 * Returns the number of result elements if available or a negative value if it is unknown: 048 * <code>UNKNOWN_SIZE</code> if it is unknown as query was not done, and since 5.5, 049 * <code>UNKNOWN_SIZE_AFTER_QUERY</code> if it is still unknown after query was done. 050 */ 051 long getResultsCount(); 052 053 /** 054 * Returns the total number of pages or 0 if number of pages is unknown. 055 */ 056 long getNumberOfPages(); 057 058 /** 059 * Returns a boolean expressing if there are further pages. 060 */ 061 boolean isNextPageAvailable(); 062 063 /** 064 * Returns a boolean expressing if the last page can be displayed. 065 */ 066 boolean isLastPageAvailable(); 067 068 /** 069 * Returns a boolean expressing if there is a previous page. 070 */ 071 boolean isPreviousPageAvailable(); 072 073 /** 074 * Returns the number of elements in current page. 075 */ 076 long getCurrentPageSize(); 077 078 /** 079 * Returns the offset (starting from 0) of the first element in the current page or <code>UNKNOWN_SIZE</code>. 080 * 081 * @since 9.3 082 */ 083 long getCurrentPageOffset(); 084 085 /** 086 * Returns the current page index as a zero-based integer. 087 */ 088 long getCurrentPageIndex(); 089 090 /** 091 * Returns if this provider is sortable. 092 */ 093 boolean isSortable(); 094 095 boolean hasError(); 096 097 String getErrorMessage(); 098 099 /** 100 * @since 6.0 101 */ 102 Map<String, Aggregate<? extends Bucket>> getAggregates(); 103 104 /** 105 * @since 6.0 106 */ 107 boolean hasAggregateSupport(); 108 109 /** 110 * @since 8.4 111 */ 112 List<QuickFilter> getActiveQuickFilters(); 113 114 /** 115 * @since 8.4 116 */ 117 List<QuickFilter> getAvailableQuickFilters(); 118 119 /** 120 * Limit of number of results beyond which the page provider may not be able to compute {@link #getResultsCount())} 121 * or navigate. 122 * <p> 123 * Requesting results beyond this limit may result in error. When {@link #getResultsCount())} is negative, it means 124 * there may be more results than this limit. 125 * <p> 126 * 0 means there is no limit. 127 * 128 * @since 9.3 129 */ 130 long getResultsCountLimit(); 131 132}