View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.aci.protectedItem;
21  
22  
23  import org.apache.directory.api.ldap.aci.ProtectedItem;
24  import org.apache.directory.api.ldap.model.filter.ExprNode;
25  
26  
27  /**
28   * Any attribute value which matches the specified filter, i.e. for which
29   * the specified filter evaluated on that attribute value would return TRUE.
30   */
31  public class RangeOfValuesItem extends ProtectedItem
32  {
33  
34      /** The filter. */
35      private final ExprNode filter;
36  
37  
38      /**
39       * Creates a new instance.
40       * 
41       * @param filter the expression
42       */
43      public RangeOfValuesItem( ExprNode filter )
44      {
45          if ( filter == null )
46          {
47              throw new IllegalArgumentException( "filter" );
48          }
49  
50          this.filter = filter;
51      }
52  
53  
54      /**
55       * Gets the filter.
56       * 
57       * TODO: rename to getFilter()
58       *
59       * @return the filter
60       */
61      public ExprNode getRefinement()
62      {
63          return filter;
64      }
65  
66  
67      /**
68       * {@inheritDoc}
69       */
70      @Override
71      public int hashCode()
72      {
73          int hash = 37;
74          hash = hash * 17 + filter.hashCode();
75          return hash;
76      }
77  
78  
79      /**
80       * {@inheritDoc}
81       */
82      @Override
83      public boolean equals( Object o )
84      {
85          if ( this == o )
86          {
87              return true;
88          }
89  
90          if ( o instanceof RangeOfValuesItem )
91          {
92              RangeOfValuesItem that = ( RangeOfValuesItem ) o;
93              return this.filter.equals( that.filter );
94          }
95  
96          return false;
97      }
98  
99  
100     /**
101      * @see Object#toString()
102      */
103     public String toString()
104     {
105         StringBuilder buf = new StringBuilder();
106 
107         buf.append( "rangeOfValues " );
108         buf.append( filter.toString() );
109 
110         return buf.toString();
111     }
112 }