View Javadoc

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.search;
18  
19  import java.util.List;
20  
21  /***
22   * Represents a single cache entry that has been selected by a cache query.
23   * <p/>
24   *
25   * @author teck
26   * @author Greg Luck
27   */
28  public interface Result {
29  
30      /***
31       * Return the key for this cache entry.
32       *
33       * @return key object
34       * @throws SearchException if keys were not selected by the originating query
35       */
36      Object getKey() throws SearchException;
37  
38      /***
39       * Return the value for this cache entry.
40       *
41       * @return value object. This value might be null if the value is no longer referenced
42       *         by the cache (ie. a concurrent update removed this entry).
43       * @throws SearchException if values were not selected by the originating query
44       */
45      Object getValue() throws SearchException;
46  
47      /***
48       * Retrieve the given attribute value for this cache entry
49       *
50       * @param attribute the attribute to retrieve
51       * @return the attribute value, or null if there is none
52       * @throws SearchException if the given attribute was not explicitly selected by the
53       *             originating query
54       */
55      <T> T getAttribute(Attribute<T> attribute) throws SearchException;
56  
57      /***
58       * Retrieve the aggregator value(s)
59       *
60       * @return the aggregators value as a {@link List}. The aggregator results will be in the same order they were added to the query
61       * @throws SearchException if no aggregators were requested in the query
62       */
63      List<Object> getAggregatorResults() throws SearchException;
64  
65  }