001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo
011 */
012package org.nuxeo.ecm.automation.core.util;
013
014import java.util.List;
015import java.util.Map;
016
017import org.nuxeo.ecm.platform.query.api.Aggregate;
018import org.nuxeo.ecm.platform.query.api.Bucket;
019
020/**
021 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
022 * @since 5.7 (extracted from PaginableDocumentModelList)
023 */
024public interface Paginable<T> extends List<T> {
025
026    /**
027     * Returns the number of results per page. 0 means no pagination.
028     */
029    long getPageSize();
030
031    /**
032     * Returns the max number of results per page. 0 means no pagination.
033     * <p>
034     * If page size is greater than this maximum value, it will be taken into account instead.
035     */
036    long getMaxPageSize();
037
038    /**
039     * Returns the number of result elements if available or a negative value if it is unknown:
040     * <code>UNKNOWN_SIZE</code> if it is unknown as query was not done, and since 5.5,
041     * <code>UNKNOWN_SIZE_AFTER_QUERY</code> if it is still unknown after query was done.
042     */
043    long getResultsCount();
044
045    /**
046     * Returns the total number of pages or 0 if number of pages is unknown.
047     */
048    long getNumberOfPages();
049
050    /**
051     * Returns a boolean expressing if there are further pages.
052     */
053    boolean isNextPageAvailable();
054
055    /**
056     * Returns a boolean expressing if the last page can be displayed.
057     */
058    boolean isLastPageAvailable();
059
060    /**
061     * Returns a boolean expressing if there is a previous page.
062     */
063    boolean isPreviousPageAvailable();
064
065    /**
066     * Returns the number of elements in current page.
067     */
068    long getCurrentPageSize();
069
070    /**
071     * Returns the current page index as a zero-based integer.
072     */
073    long getCurrentPageIndex();
074
075    /**
076     * Returns if this provider is sortable.
077     */
078    boolean isSortable();
079
080    boolean hasError();
081
082    String getErrorMessage();
083
084    /**
085     * @since 6.0
086     */
087    Map<String, Aggregate<? extends Bucket>> getAggregates();
088
089    /**
090     * @since 6.0
091     */
092    boolean hasAggregateSupport();
093
094}