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.schema.AttributeType;
21  import org.apache.regexp.RE;
22  
23  import javax.naming.NamingException;
24  import javax.naming.directory.Attribute;
25  import javax.naming.directory.Attributes;
26  import java.math.BigInteger;
27  
28  
29  /***
30   * Required interfaces for an index.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   * @version $Rev: 159259 $
34   */
35  public interface Index
36  {
37      /***
38       * Gets the attribute this Index is built upon.
39       *
40       * @return the id of the Index's attribute
41       */
42      AttributeType getAttribute();
43  
44      /***
45       * Gets the normalized value for an attribute.
46       *
47       * @param attrVal the user provided value to normalize
48       * @return the normalized value.
49       * @throws NamingException if something goes wrong.
50       */
51      Object getNormalized( Object attrVal ) throws NamingException;
52  
53      /***
54       * Gets the total scan count for this index.
55       *
56       * @return the number of key/value pairs in this index
57       * @throws NamingException if their is a failure accessing the index
58       */
59      int count() throws NamingException;
60  
61      /***
62       * Gets the scan count for the occurance of a specific attribute value 
63       * within the index.
64       *
65       * @param attrVal the value of the attribute to get a scan count for
66       * @return the number of key/value pairs in this index with the value value
67       * @throws NamingException if their is a failure accessing the index
68       */
69      int count( Object attrVal ) throws NamingException;
70  
71      /***
72       * TODO Document me!
73       *
74       * @param attrVal TODO
75       * @param isGreaterThan TODO
76       * @return TODO
77       * @throws NamingException TODO
78       */
79      int count( Object attrVal, boolean isGreaterThan ) throws NamingException;
80  
81      /***
82       * TODO Document me!
83       *
84       * @param attrVal TODO
85       * @return TODO
86       * @throws NamingException TODO
87       */
88      BigInteger forwardLookup( Object attrVal )  throws NamingException;
89  
90      /***
91       * TODO Document me!
92       *
93       * @param id TODO
94       * @return TODO
95       * @throws NamingException TODO
96       */
97      Object reverseLookup( BigInteger id ) throws NamingException;
98  
99      /***
100      * TODO Document me!
101      *
102      * @param attrVal TODO
103      * @param id TODO
104      * @throws NamingException TODO
105      */
106     void add( Object attrVal, BigInteger id ) throws NamingException;
107 
108     /***
109      * TODO Document me!
110      *
111      * @param attr TODO
112      * @param id TODO
113      * @throws NamingException TODO
114      */
115     void add( Attribute attr, BigInteger id ) throws NamingException;
116 
117     /***
118      * TODO Document me!
119      *
120      * @param attrs TODO
121      * @param id TODO
122      * @throws NamingException TODO
123      */
124     void add( Attributes attrs, BigInteger id ) throws NamingException;
125 
126     /***
127      * TODO Document me!
128      *
129      * @param entryId TODO
130      * @throws NamingException TODO
131      */
132     void drop( BigInteger entryId ) throws NamingException;
133 
134     /***
135      * TODO Document me!
136      *
137      * @param attrVal TODO
138      * @param id TODO
139      * @throws NamingException TODO
140      */
141     void drop( Object attrVal, BigInteger id ) throws NamingException;
142         
143     /***
144      * If the Attribute does not have any values then this reduces to a 
145      * drop(BigInteger) call.
146      *
147      * @param attr TODO
148      * @param id TODO
149      * @throws NamingException TODO
150      */
151     void drop( Attribute attr, BigInteger id ) throws NamingException;
152         
153     /***
154      * If the Attribute for this index within the Attributes does not have any 
155      * values then this reduces to a drop(BigInteger) call.
156      *
157      * @param attrs TODO
158      * @param id TODO
159      * @throws NamingException TODO
160      */
161     void drop( Attributes attrs, BigInteger id ) throws NamingException;
162         
163     /***
164      * TODO Document me!
165      *
166      * @param id TODO
167      * @return TODO
168      * @throws NamingException TODO
169      */
170     IndexEnumeration listReverseIndices( BigInteger id ) throws NamingException;
171 
172     /***
173      * TODO Document me!
174      *
175      * @return TODO
176      * @throws NamingException TODO
177      */
178     IndexEnumeration listIndices() throws NamingException;
179 
180     /***
181      * TODO Document me!
182      *
183      * @param attrVal TODO
184      * @return TODO
185      * @throws NamingException TODO
186      */
187     IndexEnumeration listIndices( Object attrVal ) throws NamingException;
188 
189     /***
190      * TODO Document me!
191      *
192      * @param attrVal TODO
193      * @param isGreaterThan TODO
194      * @return TODO
195      * @throws NamingException TODO
196      */
197     IndexEnumeration listIndices( Object attrVal, boolean isGreaterThan )
198         throws NamingException;
199 
200     /***
201      * TODO Document me!
202      *
203      * @param regex TODO
204      * @return TODO
205      * @throws NamingException TODO
206      */
207     IndexEnumeration listIndices( RE regex ) throws NamingException;
208 
209     /***
210      * TODO Document me!
211      *
212      * @param regex TODO
213      * @param prefix TODO
214      * @return TODO
215      * @throws NamingException TODO
216      */
217     IndexEnumeration listIndices( RE regex, String prefix )
218         throws NamingException;
219 
220     /***
221      * TODO Document me!
222      *
223      * @param attrVal TODO
224      * @param id TODO
225      * @return  TODO
226      * @throws NamingException TODO
227      */
228     boolean hasValue( Object attrVal, BigInteger id ) 
229         throws NamingException;
230 
231     /***
232      * TODO Document me!
233      *
234      * @param attrVal TODO
235      * @param id TODO
236      * @param isGreaterThan TODO
237      * @return TODO
238      * @throws NamingException TODO
239      */
240     boolean hasValue( Object attrVal, BigInteger id, boolean isGreaterThan )
241         throws NamingException;
242 
243     /***
244      * TODO Document me!
245      *
246      * @param regex TODO
247      * @param id TODO
248      * @return TODO
249      * @throws NamingException TODO
250      */
251     boolean hasValue( RE regex, BigInteger id ) throws NamingException;
252 
253     /***
254      * TODO Document me!
255      *
256      * @throws NamingException TODO
257      */
258     void close() throws NamingException;
259 
260     /***
261      * TODO Document me!
262      *
263      * @throws NamingException TODO
264      */
265     void sync() throws NamingException;
266 }