001/* 002 * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id: ResultSet.java 28480 2008-01-04 14:04:49Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.core.search.api.client.search.results; 021 022import java.util.List; 023 024import org.nuxeo.ecm.core.search.api.client.SearchException; 025 026/** 027 * Result set. 028 * 029 * @author <a href="mailto:ja@nuxeo.com">Julien Anguenot</a> 030 */ 031public interface ResultSet extends List<ResultItem> { 032 033 String ALWAYS_DETACH_SEARCH_RESULTS_KEY = "org.nuxeo.ecm.core.search.alwaysDetachResults"; 034 035 /** 036 * Returns the current offset for this result set. 037 * 038 * @return the offset as an integer. 039 */ 040 int getOffset(); 041 042 /** 043 * Returns the amount of results from offset requested. 044 * 045 * @return the amount of results from offset requested. 046 */ 047 int getRange(); 048 049 /** 050 * Returns the total number of hits this resultset comes from. 051 * 052 * @return an integer value 053 */ 054 int getTotalHits(); 055 056 /** 057 * Returns the amount of actual matching results. 058 * <p> 059 * This is in contrast to getRange() that returns the maximum number of results per page. 060 * 061 * @return the amount of actual matching results. 062 */ 063 int getPageHits(); 064 065 /** 066 * Replays the exact same query. 067 * 068 * @return a new, updated ResultSet 069 * @throws SearchException 070 */ 071 ResultSet replay() throws SearchException; 072 073 /** 074 * Replays the same query with new offset and range. 075 * 076 * @param offset the new offset 077 * @param range the new range 078 * @return a new, updated ResultSet 079 * @throws SearchException 080 */ 081 ResultSet replay(int offset, int range) throws SearchException; 082 083 /** 084 * Computes the next page by replaying the exact same request. 085 * 086 * @return the next computed page or null if there is none. 087 * @throws SearchException 088 */ 089 ResultSet nextPage() throws SearchException; 090 091 /** 092 * Goes to requested page. 093 * 094 * @param page the page to go to 095 * @return the next computed page or null if there is none. 096 * @throws SearchException 097 */ 098 ResultSet goToPage(int page) throws SearchException; 099 100 /** 101 * Is there another page available? 102 * 103 * @return true if next page available / false if not. 104 */ 105 boolean hasNextPage(); 106 107 /** 108 * Is this result set the first page of results? 109 * 110 * @return true if first page / false of not. 111 */ 112 boolean isFirstPage(); 113 114 /** 115 * Computes the page number among the total set of results. 116 * 117 * @return the page number 118 */ 119 int getPageNumber(); 120 121}