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; 026 027/** 028 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 029 * @since 5.7 (extracted from PaginableDocumentModelList) 030 */ 031public interface Paginable<T> extends List<T> { 032 033 /** 034 * Returns the number of results per page. 0 means no pagination. 035 */ 036 long getPageSize(); 037 038 /** 039 * Returns the max number of results per page. 0 means no pagination. 040 * <p> 041 * If page size is greater than this maximum value, it will be taken into account instead. 042 */ 043 long getMaxPageSize(); 044 045 /** 046 * Returns the number of result elements if available or a negative value if it is unknown: 047 * <code>UNKNOWN_SIZE</code> if it is unknown as query was not done, and since 5.5, 048 * <code>UNKNOWN_SIZE_AFTER_QUERY</code> if it is still unknown after query was done. 049 */ 050 long getResultsCount(); 051 052 /** 053 * Returns the total number of pages or 0 if number of pages is unknown. 054 */ 055 long getNumberOfPages(); 056 057 /** 058 * Returns a boolean expressing if there are further pages. 059 */ 060 boolean isNextPageAvailable(); 061 062 /** 063 * Returns a boolean expressing if the last page can be displayed. 064 */ 065 boolean isLastPageAvailable(); 066 067 /** 068 * Returns a boolean expressing if there is a previous page. 069 */ 070 boolean isPreviousPageAvailable(); 071 072 /** 073 * Returns the number of elements in current page. 074 */ 075 long getCurrentPageSize(); 076 077 /** 078 * Returns the current page index as a zero-based integer. 079 */ 080 long getCurrentPageIndex(); 081 082 /** 083 * Returns if this provider is sortable. 084 */ 085 boolean isSortable(); 086 087 boolean hasError(); 088 089 String getErrorMessage(); 090 091 /** 092 * @since 6.0 093 */ 094 Map<String, Aggregate<? extends Bucket>> getAggregates(); 095 096 /** 097 * @since 6.0 098 */ 099 boolean hasAggregateSupport(); 100 101}