1 // Copyright 2008 Thiago H. de Paula Figueiredo
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package br.com.arsmachina.tapestrycrud.grid;
16
17 import java.util.List;
18
19 import br.com.arsmachina.dao.SortCriterion;
20
21 /**
22 * Interface that defines a search that can be carried on in a paged fashion.
23 *
24 * @param <T> the type of the elements returned.
25 * @author Thiago H. de Paula Figueiredo
26 */
27 public interface PagedSearch<T> {
28
29 /**
30 * Performs the search.
31 *
32 * @param firstIndex an <code>int</code> with the index of the first object to be returned.
33 * The first object has index 0.
34 * @param maximumResults an <code>int</code> with the maximum number of objects to be returned.
35 * @param sortingConstraints an {@link SortCriterion} array used to define how the returned
36 * list will be sorted.
37 * @return a {@link List} of <code>T</code>.
38 */
39 List<T> search(int firstIndex, int maximumResults, SortCriterion... sortingConstraints);
40
41 /**
42 * Return the number of available objects to be returned by the search.
43 *
44 * @return an <code>int</code>.
45 */
46 int count();
47
48 }