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.Collections;
20  import java.util.List;
21  
22  /***
23   * An empty result instance
24   *
25   * @author teck
26   */
27  public class NullResults implements Results {
28  
29      /***
30       * A global instance that can be freely shared with the world since this type has no state
31       */
32      public static final NullResults INSTANCE = new NullResults();
33  
34      /***
35       * {@inheritDoc}
36       */
37      public void discard() {
38          //
39      }
40  
41      /***
42       * {@inheritDoc}
43       */
44      public List<Result> all() throws SearchException {
45          return Collections.EMPTY_LIST;
46      }
47  
48      /***
49       * {@inheritDoc}
50       */
51      public List<Result> range(int start, int count) throws SearchException, IndexOutOfBoundsException {
52          return Collections.EMPTY_LIST;
53      }
54  
55      /***
56       * {@inheritDoc}
57       */
58      public int size() {
59          return 0;
60      }
61  
62      /***
63       * {@inheritDoc}
64       */
65      public boolean hasKeys() {
66          return false;
67      }
68  
69      /***
70       * {@inheritDoc}
71       */
72      public boolean hasValues() {
73          return false;
74      }
75  
76      /***
77       * {@inheritDoc}
78       */
79      public boolean hasAttributes() {
80          return false;
81      }
82  
83      /***
84       * {@inheritDoc}
85       */
86      public boolean hasAggregators() {
87          return false;
88      }
89  
90  }