001/* 002 * (C) Copyright 2007 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 - initial API and implementation 018 * 019 * $Id: ResultSet.java 28480 2008-01-04 14:04:49Z sfermigier $ 020 */ 021 022package org.nuxeo.ecm.core.search.api.client.search.results; 023 024import java.util.List; 025 026import org.nuxeo.ecm.core.search.api.client.SearchException; 027 028/** 029 * Result set. 030 * 031 * @author <a href="mailto:ja@nuxeo.com">Julien Anguenot</a> 032 */ 033public interface ResultSet extends List<ResultItem> { 034 035 String ALWAYS_DETACH_SEARCH_RESULTS_KEY = "org.nuxeo.ecm.core.search.alwaysDetachResults"; 036 037 /** 038 * Returns the current offset for this result set. 039 * 040 * @return the offset as an integer. 041 */ 042 int getOffset(); 043 044 /** 045 * Returns the amount of results from offset requested. 046 * 047 * @return the amount of results from offset requested. 048 */ 049 int getRange(); 050 051 /** 052 * Returns the total number of hits this resultset comes from. 053 * 054 * @return an integer value 055 */ 056 int getTotalHits(); 057 058 /** 059 * Returns the amount of actual matching results. 060 * <p> 061 * This is in contrast to getRange() that returns the maximum number of results per page. 062 * 063 * @return the amount of actual matching results. 064 */ 065 int getPageHits(); 066 067 /** 068 * Replays the exact same query. 069 * 070 * @return a new, updated ResultSet 071 */ 072 ResultSet replay() throws SearchException; 073 074 /** 075 * Replays the same query with new offset and range. 076 * 077 * @param offset the new offset 078 * @param range the new range 079 * @return a new, updated ResultSet 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 */ 088 ResultSet nextPage() throws SearchException; 089 090 /** 091 * Goes to requested page. 092 * 093 * @param page the page to go to 094 * @return the next computed page or null if there is none. 095 */ 096 ResultSet goToPage(int page) throws SearchException; 097 098 /** 099 * Is there another page available? 100 * 101 * @return true if next page available / false if not. 102 */ 103 boolean hasNextPage(); 104 105 /** 106 * Is this result set the first page of results? 107 * 108 * @return true if first page / false of not. 109 */ 110 boolean isFirstPage(); 111 112 /** 113 * Computes the page number among the total set of results. 114 * 115 * @return the page number 116 */ 117 int getPageNumber(); 118 119}