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.entry.Entry; 024import org.apache.directory.api.ldap.model.exception.LdapException; 025import org.apache.directory.api.ldap.model.filter.UndefinedNode; 026import org.apache.directory.server.core.api.partition.PartitionTxn; 027import org.apache.directory.server.xdbm.IndexEntry; 028import org.apache.directory.server.xdbm.Store; 029import org.apache.directory.server.xdbm.search.Evaluator; 030 031 032/** 033 * An Evaluator that always validate all the submitted values 034 * 035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 036 */ 037public class PassThroughEvaluator implements Evaluator<UndefinedNode> 038{ 039 /** The backend */ 040 private final Store db; 041 042 043 /** 044 * Create a new instance of the PassThroughEvaluator 045 * 046 * @param db The Store instance 047 */ 048 public PassThroughEvaluator( Store db ) 049 { 050 this.db = db; 051 } 052 053 054 /** 055 * {@inheritDoc} 056 */ 057 public boolean evaluate( PartitionTxn partitionTxn, IndexEntry<?, String> indexEntry ) throws LdapException 058 { 059 Entry entry = indexEntry.getEntry(); 060 061 // resuscitate the entry if it has not been and set entry in IndexEntry 062 if ( null == entry ) 063 { 064 entry = db.fetch( partitionTxn, indexEntry.getId() ); 065 066 if ( null == entry ) 067 { 068 // The entry is not anymore present : get out 069 return false; 070 } 071 072 indexEntry.setEntry( entry ); 073 } 074 075 return true; 076 } 077 078 079 /** 080 * {@inheritDoc} 081 */ 082 public boolean evaluate( Entry entry ) throws LdapException 083 { 084 return true; 085 } 086 087 088 /** 089 * Gets the expression used by this expression Evaluator. 090 * 091 * @return the AST for the expression 092 */ 093 public UndefinedNode getExpression() 094 { 095 return null; 096 } 097 098 099 /** 100 * @see Object#toString() 101 */ 102 public String toString( String tabs ) 103 { 104 StringBuilder sb = new StringBuilder(); 105 106 sb.append( tabs ).append( "PassthroughEvaluator\n" ); 107 108 return sb.toString(); 109 } 110 111 112 /** 113 * @see Object#toString() 114 */ 115 public String toString() 116 { 117 return toString( "" ); 118 } 119}