001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.aci.protectedItem; 021 022 023import org.apache.directory.api.ldap.aci.ProtectedItem; 024import org.apache.directory.api.ldap.model.filter.ExprNode; 025 026 027/** 028 * Any attribute value which matches the specified filter, i.e. for which 029 * the specified filter evaluated on that attribute value would return TRUE. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public class RangeOfValuesItem extends ProtectedItem 034{ 035 /** The filter. */ 036 private final ExprNode filter; 037 038 039 /** 040 * Creates a new instance. 041 * 042 * @param filter the expression 043 */ 044 public RangeOfValuesItem( ExprNode filter ) 045 { 046 if ( filter == null ) 047 { 048 throw new IllegalArgumentException( "filter" ); 049 } 050 051 this.filter = filter; 052 } 053 054 055 /** 056 * Gets the filter. 057 * 058 * TODO: rename to getFilter() 059 * 060 * @return the filter 061 */ 062 public ExprNode getRefinement() 063 { 064 return filter; 065 } 066 067 068 /** 069 * {@inheritDoc} 070 */ 071 @Override 072 public int hashCode() 073 { 074 int hash = 37; 075 076 if ( filter != null ) 077 { 078 hash = hash * 17 + filter.hashCode(); 079 } 080 081 return hash; 082 } 083 084 085 /** 086 * {@inheritDoc} 087 */ 088 @Override 089 public boolean equals( Object o ) 090 { 091 if ( this == o ) 092 { 093 return true; 094 } 095 096 if ( o instanceof RangeOfValuesItem ) 097 { 098 RangeOfValuesItem that = ( RangeOfValuesItem ) o; 099 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}