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.expression;
18  
19  /***
20   * Less than or equal criteria
21   *
22   * @author teck
23   */
24  public class LessThanOrEqual extends ComparableValue {
25  
26      private final Comparable comparableValue;
27  
28      /***
29       * Constructor
30       *
31       * @param attributeName attribute name
32       * @param value
33       */
34      public LessThanOrEqual(String attributeName, Object value) {
35          super(attributeName, value);
36          this.comparableValue = (Comparable) value;
37      }
38  
39      /***
40       * {@inheritDoc}
41       */
42      @Override
43      protected boolean executeComparable(Comparable attributeValue) {
44          return attributeValue.compareTo(comparableValue) <= 0;
45      }
46  
47      /***
48       * {@inheritDoc}
49       */
50      @Override
51      protected boolean executeComparableString(Comparable attributeValue) {
52          return luceneStringCompare(attributeValue.toString(), comparableValue.toString()) <= 0;
53      }
54  
55      /***
56       * Comparable value.
57       *
58       * @return value
59       */
60      public Comparable getComparableValue() {
61          return comparableValue;
62      }
63  
64  }