1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.ehcache.store;
18
19 import java.util.List;
20 import java.util.Set;
21
22 import net.sf.ehcache.Cache;
23 import net.sf.ehcache.search.Attribute;
24 import net.sf.ehcache.search.Direction;
25 import net.sf.ehcache.search.aggregator.AggregatorInstance;
26 import net.sf.ehcache.search.expression.Criteria;
27
28 /***
29 * An immutable query that a {@link Store} can execute
30 *
31 * @author teck
32 */
33 public interface StoreQuery {
34
35 /***
36 * Get the search criteria
37 *
38 * @return the search criteria
39 */
40 Criteria getCriteria();
41
42 /***
43 * Are keys requested?
44 *
45 * @return true if keys requested
46 */
47 boolean requestsKeys();
48
49 /***
50 * Are values requested?
51 *
52 * @return true if values requested
53 */
54 boolean requestsValues();
55
56 /***
57 * Get the cache this query originated from
58 *
59 * @return cache
60 */
61 Cache getCache();
62
63 /***
64 * Get the set of attributes requested by this query
65 *
66 * @return the requested attributes (if any)
67 */
68 Set<Attribute<?>> requestedAttributes();
69
70 /***
71 * Get the requested search orderings
72 *
73 * @return the request sort orders (if any)
74 */
75 List<Ordering> getOrdering();
76
77 /***
78 * Get the maximum number of results to return
79 *
80 * @return max results. A negative number means unlimited results
81 */
82 int maxResults();
83
84 /***
85 * Get the requested aggregators
86 *
87 * @return the include aggregators (if any)
88 */
89 List<AggregatorInstance<?>> getAggregatorInstances();
90
91 /***
92 * An attribute / direction ordering pair
93 */
94 public interface Ordering {
95 /***
96 * Attribute to order by
97 *
98 * @return attribute
99 */
100 Attribute<?> getAttribute();
101
102 /***
103 * Ordering direction
104 *
105 * @return direction
106 */
107 Direction getDirection();
108 }
109
110 }