View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.db;
18  
19  
20  import org.apache.ldap.common.filter.ExprNode;
21  
22  import javax.naming.Name;
23  import javax.naming.NamingEnumeration;
24  import javax.naming.NamingException;
25  import javax.naming.directory.SearchControls;
26  import java.math.BigInteger;
27  import java.util.Map;
28  
29  
30  /***
31   * Given a search filter and a scope the search engine identifies valid
32   * candidate entries returning their ids.
33   * 
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   * @version $Rev: 159259 $
36   */
37  public interface SearchEngine 
38  {
39      /***
40       * @todo put this in the right place
41       * The alias dereferencing mode key for JNDI providers 
42       */
43      String ALIASMODE_KEY = "java.naming.ldap.derefAliases";
44      /*** 
45       * @todo put this in the right place
46       * The alias dereferencing mode value for JNDI providers 
47       */
48      String ALWAYS = "always";
49      /*** 
50       * @todo put this in the right place
51       * The alias dereferencing mode value for JNDI providers 
52       */
53      String NEVER = "never";
54      /*** 
55       * @todo put this in the right place
56       * The alias dereferencing mode value for JNDI providers 
57       */
58      String FINDING = "finding";
59      /*** 
60       * @todo put this in the right place
61       * The alias dereferencing mode value for JNDI providers 
62       */
63      String SEARCHING = "searching";
64      
65      /***
66       * Gets the optimizer for this DefaultSearchEngine.
67       *
68       * @return the optimizer
69       */
70      Optimizer getOptimizer();
71      
72      /***
73       * Conducts a search on a database.
74       * 
75       * @param base the search base
76       * @param env the environment for the search
77       * @param filter the search filter AST root
78       * @param searchCtls the JNDI search controls
79       * @return enumeration over SearchResults
80       * @throws NamingException if the search fails
81       */
82      NamingEnumeration search( Name base, Map env, ExprNode filter,
83          SearchControls searchCtls ) throws NamingException;
84  
85      /***
86       * Evaluates a filter on an entry with a id.
87       * 
88       * @param filter the filter root AST node
89       * @param id the id of the entry to test
90       * @return true if the filter passes the entry, false otherwise
91       * @throws NamingException if something goes wrong while accessing the db
92       */
93      boolean evaluate( ExprNode filter, BigInteger id )  throws NamingException;
94  }