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.server.xdbm.search.evaluator; 021 022 023import org.apache.directory.api.ldap.model.filter.SimpleNode; 024import org.apache.directory.api.ldap.model.schema.AttributeType; 025import org.apache.directory.api.ldap.model.schema.LdapComparator; 026import org.apache.directory.api.ldap.model.schema.Normalizer; 027import org.apache.directory.api.ldap.model.schema.SchemaManager; 028import org.apache.directory.server.xdbm.Index; 029import org.apache.directory.server.xdbm.Store; 030import org.apache.directory.server.xdbm.search.Evaluator; 031 032 033/** 034 * An abstract evaluator to store the common fileds for the Simple node evaluators 035 * (ApproximateEvaluator, EqualityEvaluator, GreaterEqEvluator and LessEqEvluator) 036 * 037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 038 * @version $Rev$, $Date$ 039 */ 040public abstract class LeafEvaluator<T> implements Evaluator<SimpleNode<T>> 041{ 042 /** The ExprNode to evaluate */ 043 protected final SimpleNode<T> node; 044 045 /** The backend */ 046 protected final Store db; 047 048 /** The SchemaManager instance */ 049 protected final SchemaManager schemaManager; 050 051 /** The AttributeType we will use for the evaluation */ 052 protected final AttributeType attributeType; 053 054 /** The associated normalizer */ 055 protected Normalizer normalizer; 056 057 /** The associated comparator */ 058 protected LdapComparator<? super Object> ldapComparator; 059 060 /** The index to use if any */ 061 protected Index<T, String> idx; 062 063 064 /** 065 * Creates a new LeafEvaluator 066 * 067 * @param node The LeafNode 068 * @param db The Store 069 * @param schemaManager The SchemaManager 070 */ 071 public LeafEvaluator( SimpleNode<T> node, Store db, SchemaManager schemaManager ) 072 { 073 this.db = db; 074 this.node = node; 075 this.schemaManager = schemaManager; 076 this.attributeType = node.getAttributeType(); 077 } 078 079 080 /** 081 * @return The AttributeType 082 */ 083 public AttributeType getAttributeType() 084 { 085 return attributeType; 086 } 087 088 089 /** 090 * @return The Normalizer associated with the AttributeType 091 */ 092 public Normalizer getNormalizer() 093 { 094 return normalizer; 095 } 096 097 098 /** 099 * @return The LdapComparator associated with the AttributeType 100 */ 101 public LdapComparator<? super Object> getComparator() 102 { 103 return ldapComparator; 104 } 105 106 107 /** 108 * @see Object#toString() 109 */ 110 public String toString() 111 { 112 StringBuilder sb = new StringBuilder(); 113 114 sb.append( node ); 115 116 return sb.toString(); 117 } 118}