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   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public class RangeOfValuesItem extends ProtectedItem
34  {
35      /** The filter. */
36      private final ExprNode filter;
37  
38  
39      /**
40       * Creates a new instance.
41       * 
42       * @param filter the expression
43       */
44      public RangeOfValuesItem( ExprNode filter )
45      {
46          if ( filter == null )
47          {
48              throw new IllegalArgumentException( "filter" );
49          }
50  
51          this.filter = filter;
52      }
53  
54  
55      /**
56       * Gets the filter.
57       * 
58       * TODO: rename to getFilter()
59       *
60       * @return the filter
61       */
62      public ExprNode getRefinement()
63      {
64          return filter;
65      }
66  
67  
68      /**
69       * {@inheritDoc}
70       */
71      @Override
72      public int hashCode()
73      {
74          int hash = 37;
75          
76          if ( filter != null )
77          {
78              hash = hash * 17 + filter.hashCode();
79          }
80          
81          return hash;
82      }
83  
84  
85      /**
86       * {@inheritDoc}
87       */
88      @Override
89      public boolean equals( Object o )
90      {
91          if ( this == o )
92          {
93              return true;
94          }
95  
96          if ( o instanceof RangeOfValuesItem )
97          {
98              RangeOfValuesItem that = ( RangeOfValuesItem ) o;
99              
100             return filter.equals( that.filter );
101         }
102 
103         return false;
104     }
105 
106 
107     /**
108      * @see Object#toString()
109      */
110     @Override
111     public String toString()
112     {
113         StringBuilder buf = new StringBuilder();
114 
115         buf.append( "rangeOfValues " );
116         
117         if ( filter != null )
118         {
119             buf.append( filter.toString() );
120         }
121 
122         return buf.toString();
123     }
124 }