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.impl;
18  
19  import java.util.Map;
20  
21  import net.sf.ehcache.store.StoreQuery;
22  
23  /***
24   * Result implementation
25   *
26   * @author teck
27   */
28  public class ResultImpl extends BaseResult {
29  
30      private final Object key;
31      private final Object value;
32      private final Map<String, Object> attributes;
33      private final Object[] sortAttributes;
34  
35      /***
36       * Constructor
37       *
38       * @param key
39       * @param value
40       * @param query
41       * @param attributes
42       * @param sortAttributes
43       */
44      public ResultImpl(Object key, Object value, StoreQuery query, Map<String, Object> attributes, Object[] sortAttributes) {
45          super(query);
46          this.key = key;
47          this.value = value;
48          this.attributes = attributes;
49          this.sortAttributes = sortAttributes;
50      }
51  
52      /***
53       * Get attribute value for use in sorting
54       *
55       * @param pos
56       * @return
57       */
58      Object getSortAttribute(int pos) {
59          return sortAttributes[pos];
60      }
61  
62      @Override
63      protected Object basicGetKey() {
64          return key;
65      }
66  
67      @Override
68      protected Object basicGetValue() {
69          return value;
70      }
71  
72      @Override
73      protected Object basicGetAttribute(String name) {
74          return attributes.get(name);
75      }
76  
77  }