You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/09/30 04:00:04 UTC
svn commit: rev 47525 - in incubator/directory/eve/trunk/backend/core: . src/java/org/apache/eve/db src/java/org/apache/eve/db/jdbm
Author: akarasulu
Date: Wed Sep 29 19:00:03 2004
New Revision: 47525
Added:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitor.java (contents, props changed)
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitorAdapter.java (contents, props changed)
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ConjunctionEnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ConjunctionEnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultDatabase.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/DefaultDatabase.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultIndex.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/index/DefaultIndex.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultMasterTable.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultMasterTable.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultOptimizer.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultOptimizer.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultSearchEngine.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultSearchEngine.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTable.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTable.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTupleBrowser.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTupleBrowser.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DisjunctionEnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DisjunctionEnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EvaluatorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EvaluatorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/LeafEvaluatorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/LeafEvaluatorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/NegationEnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/NegationEnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEvaluatorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEvaluatorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEnumeratorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEnumeratorImpl.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEvaluatorImpl.java
- copied, changed from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEvaluatorImpl.java
Removed:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ConjunctionEnumerator.java
Modified:
incubator/directory/eve/trunk/backend/core/project.xml
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/DupsEnumeration.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Enumerator.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Evaluator.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/IndexEnumeration.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/NoDupsEnumeration.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Optimizer.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchEngine.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultEnumeration.java
Log:
Commit changes ...
o moved classes from database-impl projects in the sandbox
o flattened packages again and using new jdbm impl package
o cleaned up all avalon references
o corrected references to ldap-common schema objects
o started cleaning up code style and formatting
Notes ...
o this is an intermediate state that does not currently compile!
o we need to move stuff out of jdbm that really does not reference jdbm
o we need to remove some unnecessary interfaces
Modified: incubator/directory/eve/trunk/backend/core/project.xml
==============================================================================
--- incubator/directory/eve/trunk/backend/core/project.xml (original)
+++ incubator/directory/eve/trunk/backend/core/project.xml Wed Sep 29 19:00:03 2004
@@ -32,6 +32,13 @@
<version>1.2</version>
<url>http://jakarta.apache.org/regexp/index.html</url>
</dependency>
+
+ <dependency>
+ <groupId>jdbm</groupId>
+ <artifactId>jdbm</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://jdbm.sourceforge.net</url>
+ </dependency>
</dependencies>
</project>
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/DupsEnumeration.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/DupsEnumeration.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/DupsEnumeration.java Wed Sep 29 19:00:03 2004
@@ -73,11 +73,10 @@
* Creates a DupsEnumeration over a enumeration of Tuples holding TreeSets
* for values that have the same key.
*
- * @param list TODO
- * @throws NamingException TODO
+ * @param list the underlying enumeration
+ * @throws NamingException if there is a problem
*/
- DupsEnumeration( NoDupsEnumeration list )
- throws NamingException
+ public DupsEnumeration( NoDupsEnumeration list ) throws NamingException
{
underlying = list;
@@ -102,8 +101,7 @@
*
* @see javax.naming.NamingEnumeration#next()
*/
- public Object next()
- throws NamingException
+ public Object next() throws NamingException
{
returned.setKey( prefetched.getKey() );
returned.setValue( prefetched.getValue() );
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Enumerator.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Enumerator.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Enumerator.java Wed Sep 29 19:00:03 2004
@@ -29,7 +29,7 @@
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Enumerator extends DatabaseEnabled
+public interface Enumerator
{
/**
* Creates an enumeration to enumerate through the set of candidates
Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitor.java Wed Sep 29 19:00:03 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.db;
+
+/**
+ * A monitor for enumerators.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface EnumeratorMonitor
+{
+
+}
Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/EnumeratorMonitorAdapter.java Wed Sep 29 19:00:03 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.db;
+
+/**
+ * Document me.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
+ * @version $Rev$
+ */
+public class EnumeratorMonitorAdapter implements EnumeratorMonitor
+{
+}
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Evaluator.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Evaluator.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Evaluator.java Wed Sep 29 19:00:03 2004
@@ -30,7 +30,7 @@
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Evaluator extends DatabaseEnabled
+public interface Evaluator
{
/**
* Evaluates a candidate to determine if a filter expression selects it.
@@ -40,6 +40,5 @@
* @return true if the filter selects the candidate false otherwise
* @throws NamingException if there is a database fault during evaluation
*/
- boolean evaluate( ExprNode node, IndexRecord record )
- throws NamingException;
+ boolean evaluate( ExprNode node, IndexRecord record ) throws NamingException;
}
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/IndexEnumeration.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/IndexEnumeration.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/IndexEnumeration.java Wed Sep 29 19:00:03 2004
@@ -62,7 +62,7 @@
* @param list TODO
* @throws NamingException TODO
*/
- IndexEnumeration( NamingEnumeration list ) throws NamingException
+ public IndexEnumeration( NamingEnumeration list ) throws NamingException
{
this( list, false, null );
}
@@ -75,7 +75,7 @@
* @param swapKeyVal TODO
* @throws NamingException TODO
*/
- IndexEnumeration( NamingEnumeration list, boolean swapKeyVal )
+ public IndexEnumeration( NamingEnumeration list, boolean swapKeyVal )
throws NamingException
{
this( list, swapKeyVal, null );
@@ -90,8 +90,9 @@
* @param regex TODO
* @throws NamingException TODO
*/
- IndexEnumeration( NamingEnumeration list, boolean swapKeyVal,
- RE regex ) throws NamingException
+ public IndexEnumeration( NamingEnumeration list, boolean swapKeyVal,
+ RE regex )
+ throws NamingException
{
re = regex;
underlying = list;
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/NoDupsEnumeration.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/NoDupsEnumeration.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/NoDupsEnumeration.java Wed Sep 29 19:00:03 2004
@@ -62,7 +62,7 @@
* @param doAscendingScan TODO
* @throws NamingException TODO
*/
- NoDupsEnumeration( TupleBrowser browser, boolean doAscendingScan )
+ public NoDupsEnumeration( TupleBrowser browser, boolean doAscendingScan )
throws NamingException
{
this.browser = browser;
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Optimizer.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Optimizer.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/Optimizer.java Wed Sep 29 19:00:03 2004
@@ -33,13 +33,13 @@
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Optimizer extends DatabaseEnabled
+public interface Optimizer
{
/**
- * TODO Document me!
+ * Annotates the expression node tree for optimized traversal metrics.
*
- * @param node TODO
- * @throws NamingException TODO
+ * @param node the root of the expression node tree
+ * @throws NamingException if there are failures while optimizing
*/
void annotate( ExprNode node ) throws NamingException;
}
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchEngine.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchEngine.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchEngine.java Wed Sep 29 19:00:03 2004
@@ -35,7 +35,7 @@
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public interface SearchEngine extends DatabaseEnabled
+public interface SearchEngine
{
/**
* @todo put this in the right place
Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultEnumeration.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultEnumeration.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultEnumeration.java Wed Sep 29 19:00:03 2004
@@ -36,8 +36,7 @@
* @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SearchResultEnumeration
- implements DatabaseEnabled, NamingEnumeration
+public class SearchResultEnumeration implements NamingEnumeration
{
/** Database used to lookup entries from */
private Database db = null;
@@ -54,25 +53,17 @@
*
* @param attrIds the returned attributes
* @param underlying the enumeration over IndexRecords
- * @throws NamingException if there is a problem accessing the underlying db
*/
public SearchResultEnumeration( String [] attrIds,
- NamingEnumeration underlying ) throws NamingException
+ NamingEnumeration underlying,
+ Database db )
{
+ this.db = db;
this.attrIds = attrIds;
this.underlying = underlying;
}
- /**
- * @see org.apache.eve.db.DatabaseEnabled#enableDatabase( Database)
- */
- public void enableDatabase( Database db )
- {
- this.db = db;
- }
-
-
/**
* @see javax.naming.NamingEnumeration#close()
*/
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ConjunctionEnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ConjunctionEnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ConjunctionEnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ConjunctionEnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,272 +1,53 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: ConjunctionEnumeratorImpl.java,v 1.2 2003/10/15 01:59:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 13, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
-import java.util.ArrayList ;
-import java.math.BigInteger ;
+import java.util.ArrayList;
+import java.math.BigInteger;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.BranchNode;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
+import org.apache.eve.db.*;
/**
- * Creats a NamingEnumeration over the candidates satisfying a filter expression
- * of AND'ed filter sub-expressions.
- *
- * @avalon.component name="conjunction-enumerator" lifestyle="transient"
+ * An enumerator implementation which creates a NamingEnumeration over the
+ * candidates satisfying a filter expression of AND'ed filter sub-expressions.
*
- * @avalon.service type="org.apache.ldap.server.backend.db.search.ConjunctionEnumerator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class ConjunctionEnumeratorImpl extends AbstractLogEnabled
- implements Serviceable, ConjunctionEnumerator, EnumeratorDependent
+public class ConjunctionEnumeratorImpl implements Enumerator
{
- /** Database used */
- private Database m_db = null ;
/** Top level evaluator Avalon dependency */
- private Evaluator m_evaluator ;
+ private Evaluator evaluator;
/** Top level expression enumerator - non Avalon dependency avaoids cycle */
- private Enumerator m_enumerator ;
-
-
+ private Enumerator enumerator;
+
+
+ /**
+ * Creates a conjunction expression enumerator.
+ *
+ * @param enumerator the top level expression enumerator
+ * @param evaluator the top level expression evaluator
+ */
+ public ConjunctionEnumeratorImpl( Enumerator enumerator, Evaluator evaluator )
+ {
+ this.enumerator = enumerator;
+ this.evaluator = evaluator;
+ }
+
+
/**
- * @see org.apache.ldap.server.backend.db.search.Enumerator#enumerate(
- * org.apache.ldap.common.filter.ExprNode)
+ * @see org.apache.eve.db.Enumerator#enumerate(ExprNode)
*/
- public NamingEnumeration enumerate( final ExprNode a_node )
+ public NamingEnumeration enumerate( final ExprNode node )
throws NamingException
{
- int l_minIndex = 0 ;
- int l_minValue = Integer.MAX_VALUE ;
- int l_value = Integer.MAX_VALUE ;
- NamingEnumeration l_NamingEnumeration = null ;
+ int minIndex = 0;
+ int minValue = Integer.MAX_VALUE;
+ int value = Integer.MAX_VALUE;
/*
* We scan the child nodes of a branch node searching for the child
@@ -274,89 +55,49 @@
* we will use for iteration by creating a NamingEnumeration over its
* expression.
*/
- final ArrayList l_children = ( ( BranchNode ) a_node ).getChildren() ;
- for ( int ii = 0 ; ii < l_children.size(); ii++ )
+ final ArrayList children = ( ( BranchNode ) node ).getChildren();
+ for ( int ii = 0; ii < children.size(); ii++ )
{
- ExprNode l_child = ( ExprNode ) l_children.get( ii ) ;
- l_value = ( ( BigInteger ) l_child.get( "count" ) ).intValue() ;
- l_minValue = Math.min( l_minValue, l_value ) ;
+ ExprNode child = ( ExprNode ) children.get( ii );
+ value = ( ( BigInteger ) child.get( "count" ) ).intValue();
+ minValue = Math.min( minValue, value );
- if ( l_minValue == l_value )
+ if ( minValue == value )
{
- l_minIndex = ii ;
+ minIndex = ii;
}
}
// Once found we build the child enumeration & the wrapping enum
- final ExprNode l_minChild = ( ExprNode ) l_children.get( l_minIndex ) ;
- IndexAssertion l_assertion = new IndexAssertion()
+ final ExprNode minChild = ( ExprNode ) children.get( minIndex );
+ IndexAssertion assertion = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord a_rec )
+ public boolean assertCandidate( IndexRecord rec )
throws NamingException
{
- for ( int ii = 0; ii < l_children.size(); ii++ )
+ for ( int ii = 0; ii < children.size(); ii++ )
{
- ExprNode l_child = ( ExprNode ) l_children.get( ii ) ;
+ ExprNode child = ( ExprNode ) children.get( ii );
// Skip the child (with min scan count) chosen for enum
- if ( l_child == l_minChild )
+ if ( child == minChild )
{
- continue ;
+ continue;
}
- else if ( ! m_evaluator.evaluate( l_child, a_rec ) )
+ else if ( ! evaluator.evaluate( child, rec ) )
{
- return false ;
+ return false;
}
}
- return true ;
+ return true;
}
- } ;
+ };
// Do recursive call to build child enumeration then wrap and return
- NamingEnumeration l_underlying = m_enumerator.enumerate( l_minChild ) ;
- return new IndexAssertionEnumeration( l_underlying, l_assertion ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_evaluator.enableDatabase( a_db ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.search.EnumeratorDependent#
- * setEnumeratorDependency(org.apache.ldap.server.backend.db.search.Enumerator)
- */
- public void setEnumeratorDependency( Enumerator a_enumerator )
- {
- m_enumerator = a_enumerator ;
+ NamingEnumeration underlying = enumerator.enumerate( minChild );
+ IndexAssertionEnumeration iae;
+ iae = new IndexAssertionEnumeration( underlying, assertion );
+ return iae;
}
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.Evaluator"
- * key="evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#
- * service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "looking up the evaluator" ) ;
- m_evaluator = ( EvaluatorImpl ) a_manager.lookup( "evaluator" ) ;
- }
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultDatabase.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/DefaultDatabase.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/DefaultDatabase.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultDatabase.java Wed Sep 29 19:00:03 2004
@@ -1,531 +1,295 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+package org.apache.eve.db.jdbm;
-/*
- * $Id: DefaultDatabase.java,v 1.17 2003/10/15 01:59:47 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-
-package org.apache.ldap.server.backend.db ;
+import java.math.BigInteger;
-import java.math.BigInteger ;
+import java.io.File;
+import java.io.IOException;
-import java.io.File ;
-import java.io.IOException ;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+
+import jdbm.helper.MRU;
+import jdbm.RecordManager;
+import jdbm.recman.BaseRecordManager;
+import jdbm.recman.CacheRecordManager;
+
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.MultiException;
+import org.apache.ldap.common.schema.AttributeType;
+import org.apache.ldap.common.schema.Normalizer;
+import org.apache.ldap.common.util.NamespaceTools;
+import org.apache.ldap.common.message.LockableAttributesImpl;
-import java.util.Map ;
-import java.util.HashMap ;
-import java.util.Iterator ;
-import java.util.ArrayList ;
-
-import javax.naming.Name ;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.Attributes ;
-import javax.naming.directory.DirContext ;
-import javax.naming.directory.ModificationItem ;
-
-import jdbm.helper.MRU ;
-import jdbm.RecordManager ;
-import jdbm.recman.BaseRecordManager ;
-import jdbm.recman.CacheRecordManager ;
-
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.schema.matching.Normalizer ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
-import org.apache.ldap.server.backend.db.index.DefaultIndex ;
-import org.apache.ldap.server.schema.attribute.AttributeType ;
-import org.apache.ldap.server.backend.db.search.IndexAssertion ;
-import org.apache.ldap.server.backend.db.table.DefaultMasterTable ;
-import org.apache.ldap.server.backend.db.search.IndexAssertionEnumeration ;
-
-import org.apache.ldap.common.name.LdapName ;
-import org.apache.ldap.common.MultiException ;
-import org.apache.ldap.common.util.NamespaceTools ;
-import org.apache.ldap.common.message.LockableAttributesImpl ;
+import org.apache.eve.db.*;
/**
* A Database implementation based on JDBM B+Tree implementation.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.17 $
*/
-public class DefaultDatabase
- implements Database
+public class DefaultDatabase implements Database
{
/** the JDBM record manager used by this database */
- private final RecordManager m_recMan ;
+ private final RecordManager recMan;
/** the suffix of this backend database */
- private final Name m_suffix ;
+ private final Name suffix;
/** the working directory to use for files */
- private final String m_wkdir ;
+ private final String wkdir;
/** the master table storing entries by primary key */
- private final DefaultMasterTable m_master ;
+ private final DefaultMasterTable master;
/** a map of attribute names to user indices */
- private final Map m_indices ;
+ private final Map indices;
/** a map of index names to system indices */
- private final Map m_sysIndices ;
+ private final Map sysIndices;
/** the normalized distinguished name index */
- private Index m_ndnIdx ;
+ private Index ndnIdx;
/** the user provided distinguished name index */
- private Index m_updnIdx ;
+ private Index updnIdx;
/** the attribute existance index */
- private Index m_existanceIdx ;
+ private Index existanceIdx;
/** the parent child relationship index */
- private Index m_heirarchyIdx ;
+ private Index heirarchyIdx;
/** the one level scope alias index */
- private Index m_oneAliasIdx ;
+ private Index oneAliasIdx;
/** the subtree scope alias index */
- private Index m_subAliasIdx ;
+ private Index subAliasIdx;
/** a system index on aliasedObjectName attribute */
- private Index m_aliasIdx ;
+ private Index aliasIdx;
/**
* Creates a Databased based on JDBM B+Trees.
*
- * @param a_suffix the user provided suffix name
- * @param a_wkdirPath the path to the working directory where the db resides
+ * @param suffix the user provided suffix name
+ * @param wkdirPath the path to the working directory where the db resides
* @throws NamingException if db cannot be created
*/
- public DefaultDatabase ( final Name a_suffix, final String a_wkdirPath )
+ public DefaultDatabase ( final Name suffix, final String wkdirPath )
throws NamingException
{
- m_suffix = a_suffix ;
- m_wkdir = a_wkdirPath ;
+ this.suffix = suffix;
+ this.wkdir = wkdirPath;
try
{
- String l_path = a_wkdirPath + File.separator + "master" ;
- BaseRecordManager l_base = new BaseRecordManager( l_path ) ;
- l_base.disableTransactions() ;
- m_recMan = new CacheRecordManager( l_base, new MRU( 1000 ) ) ;
+ String path = wkdirPath + File.separator + "master";
+ BaseRecordManager base = new BaseRecordManager( path );
+ base.disableTransactions();
+ recMan = new CacheRecordManager( base, new MRU( 1000 ) );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException(
- "Could not initialize RecordManager" ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException(
+ "Could not initialize RecordManager" );
+ ne.setRootCause( e );
+ throw ne;
}
- m_master = new DefaultMasterTable( m_recMan ) ;
- m_indices = new HashMap() ;
- m_sysIndices = new HashMap() ;
+ master = new DefaultMasterTable( recMan );
+ indices = new HashMap();
+ sysIndices = new HashMap();
}
/**
- * @see org.apache.ldap.server.backend.Database#addIndexOn(
- * org.apache.ldap.server.schema.AttributeTypeImpl)
+ * @see Database#addIndexOn(AttributeType)
*/
- public void addIndexOn( AttributeType a_spec )
+ public void addIndexOn( AttributeType spec )
throws NamingException
{
- Index l_idx = new DefaultIndex( a_spec, m_wkdir ) ;
- String l_id = a_spec.getName() ;
- m_indices.put( a_spec.getName().toLowerCase(), l_idx ) ;
+ Index idx = new DefaultIndex( spec, wkdir );
+ indices.put( spec.getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.Database#getExistanceIndex()
+ * @see Database#getExistanceIndex()
*/
public Index getExistanceIndex()
{
- return m_existanceIdx ;
+ return existanceIdx;
}
/**
* Sets the attribute existance Index.
*
- * @param a_idx the attribute existance Index
+ * @param idx the attribute existance Index
*/
- public void setExistanceIndex( Index a_idx )
+ public void setExistanceIndex( Index idx )
{
- m_existanceIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ existanceIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.Database#getHeirarchyIndex()
+ * @see Database#getHeirarchyIndex()
*/
public Index getHeirarchyIndex()
{
- return m_heirarchyIdx ;
+ return heirarchyIdx;
}
/**
* Sets the heirarchy Index.
*
- * @param a_idx the heirarchy Index
+ * @param idx the heirarchy Index
*/
- public void setHeirarchyIndex( Index a_idx )
+ public void setHeirarchyIndex( Index idx )
{
- m_heirarchyIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase()
- , a_idx ) ;
+ heirarchyIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase()
+ , idx );
}
/**
- * @see org.apache.ldap.server.backend.Database#getUpdnIndex()
+ * @see Database#getUpdnIndex()
*/
public Index getUpdnIndex()
{
- return m_updnIdx ;
+ return updnIdx;
}
/**
- * @see org.apache.ldap.server.backend.db.Database#getAliasIndex()
+ * @see Database#getAliasIndex()
*/
public Index getAliasIndex()
{
- return m_aliasIdx ;
+ return aliasIdx;
}
/**
- * @see org.apache.ldap.server.backend.db.Database#setAliasIndex(
- * org.apache.ldap.server.backend.db.index.Index)
+ * @see Database#setAliasIndex(Index)
*/
- public void setAliasIndex( Index a_idx )
+ public void setAliasIndex( Index idx )
{
- m_aliasIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ aliasIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.db.Database#getOneAliasIndex()
+ * @see Database#getOneAliasIndex()
*/
public Index getOneAliasIndex()
{
- return m_oneAliasIdx ;
+ return oneAliasIdx;
}
/**
- * @see org.apache.ldap.server.backend.db.Database#setOneAliasIndex(
- * org.apache.ldap.server.backend.db.index.Index)
+ * @see Database#setOneAliasIndex(Index)
*/
- public void setOneAliasIndex( Index a_idx )
+ public void setOneAliasIndex( Index idx )
{
- m_oneAliasIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ oneAliasIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.db.Database#getSubAliasIndex()
+ * @see Database#getSubAliasIndex()
*/
public Index getSubAliasIndex()
{
- return m_subAliasIdx ;
+ return subAliasIdx;
}
/**
- * @see org.apache.ldap.server.backend.db.Database#setSubAliasIndex(
- * org.apache.ldap.server.backend.db.index.Index)
+ * @see Database#setSubAliasIndex(Index)
*/
- public void setSubAliasIndex( Index a_idx )
+ public void setSubAliasIndex( Index idx )
{
- m_subAliasIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ subAliasIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
* Sets the user provided distinguished name Index.
*
- * @param a_idx the updn Index
+ * @param idx the updn Index
*/
- public void setUpdnIndex( Index a_idx )
+ public void setUpdnIndex( Index idx )
{
- m_updnIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ updnIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.Database#getNdnIndex()
+ * @see Database#getNdnIndex()
*/
public Index getNdnIndex()
{
- return m_ndnIdx ;
+ return ndnIdx;
}
/**
* Sets the normalized distinguished name Index.
*
- * @param a_idx the ndn Index
+ * @param idx the ndn Index
*/
- public void setNdnIndex( Index a_idx )
+ public void setNdnIndex( Index idx )
{
- m_ndnIdx = a_idx ;
- m_sysIndices.put( a_idx.getAttribute().getName().toLowerCase(),
- a_idx ) ;
+ ndnIdx = idx;
+ sysIndices.put( idx.getAttribute().getName().toLowerCase(), idx );
}
/**
- * @see org.apache.ldap.server.backend.Database#getUserIndices()
+ * @see Database#getUserIndices()
*/
public Iterator getUserIndices()
{
- return m_indices.keySet().iterator() ;
+ return indices.keySet().iterator();
}
/**
- * @see org.apache.ldap.server.backend.Database#getSystemIndices()
+ * @see Database#getSystemIndices()
*/
public Iterator getSystemIndices()
{
- return m_sysIndices.keySet().iterator() ;
+ return sysIndices.keySet().iterator();
}
/**
- * @see org.apache.ldap.server.backend.db.Database#hasUserIndexOn(java.lang.String)
+ * @see Database#hasUserIndexOn(String)
*/
- public boolean hasUserIndexOn( String an_attribute )
+ public boolean hasUserIndexOn( String attribute )
{
- return
- m_indices.containsKey( an_attribute ) ||
- m_indices.containsKey( an_attribute.toLowerCase() ) ;
+ return indices.containsKey( attribute ) ||
+ indices.containsKey( attribute.toLowerCase() );
}
/**
- * @see org.apache.ldap.server.backend.db.Database#hasSystemIndexOn(java.lang.String)
+ * @see Database#hasSystemIndexOn(String)
*/
- public boolean hasSystemIndexOn( String an_attribute )
+ public boolean hasSystemIndexOn( String attribute )
{
- return
- m_sysIndices.containsKey( an_attribute ) ||
- m_sysIndices.containsKey( an_attribute.toLowerCase() ) ;
+ return sysIndices.containsKey( attribute ) ||
+ sysIndices.containsKey( attribute.toLowerCase() );
}
@@ -533,25 +297,24 @@
* @todo replace lookups to use the OID instead of the name. Also note
* that the OID registry can be used to go between names and oids.
*
- * @see org.apache.ldap.server.backend.Database#getIndex(java.lang.String)
+ * @see Database#getUserIndex(String)
*/
- public Index getUserIndex( String an_attribute )
- throws IndexNotFoundException
+ public Index getUserIndex( String attribute ) throws IndexNotFoundException
{
- String l_lowerCased = an_attribute.toLowerCase() ;
+ String lowerCased = attribute.toLowerCase();
- if ( m_indices.containsKey( an_attribute ) )
+ if ( indices.containsKey( attribute ) )
{
- return ( Index ) m_indices.get( an_attribute ) ;
+ return ( Index ) indices.get( attribute );
}
- else if ( m_indices.containsKey( l_lowerCased ) )
+ else if ( indices.containsKey( lowerCased ) )
{
- return ( Index ) m_indices.get( l_lowerCased ) ;
+ return ( Index ) indices.get( lowerCased );
}
else
{
throw new IndexNotFoundException( "An index on attribute " +
- an_attribute + " does not exist!" ) ;
+ attribute + " does not exist!" );
}
}
@@ -560,98 +323,97 @@
* @todo replace lookups to use the OID instead of the name. Also note
* that the OID registry can be used to go between names and oids.
*
- * @see org.apache.ldap.server.backend.db.Database#getEntryId(java.lang.String)
+ * @see Database#getEntryId(String)
*/
- public Index getSystemIndex( String a_indexName )
+ public Index getSystemIndex( String indexName )
throws IndexNotFoundException
{
- String l_lowerCased = a_indexName.toLowerCase() ;
+ String lowerCased = indexName.toLowerCase();
- if ( m_sysIndices.containsKey( a_indexName ) )
+ if ( sysIndices.containsKey( indexName ) )
{
- return ( Index ) m_sysIndices.get( a_indexName ) ;
+ return ( Index ) sysIndices.get( indexName );
}
- else if ( m_sysIndices.containsKey( l_lowerCased ) )
+ else if ( sysIndices.containsKey( lowerCased ) )
{
- return ( Index ) m_sysIndices.get( l_lowerCased ) ;
+ return ( Index ) sysIndices.get( lowerCased );
}
else
{
throw new IndexNotFoundException( "A system index by the name of " +
- a_indexName + " does not exist!" ) ;
+ indexName + " does not exist!" );
}
}
/**
- * @see org.apache.ldap.server.backend.Database#getEntryId(java.lang.String)
+ * @see Database#getEntryId(String)
*/
- public BigInteger getEntryId( String a_dn )
+ public BigInteger getEntryId( String dn )
throws NamingException
{
- return m_ndnIdx.forwardLookup( a_dn ) ;
+ return ndnIdx.forwardLookup( dn );
}
/**
- * @see org.apache.ldap.server.backend.Database#getEntryDn(java.math.BigInteger)
+ * @see Database#getEntryDn(java.math.BigInteger)
*/
- public String getEntryDn( BigInteger a_id )
+ public String getEntryDn( BigInteger id )
throws NamingException
{
- return ( String ) m_ndnIdx.reverseLookup( a_id ) ;
+ return ( String ) ndnIdx.reverseLookup( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#getParentId(java.lang.String)
+ * @see Database#getParentId(String)
*/
- public BigInteger getParentId( String a_dn )
+ public BigInteger getParentId( String dn )
throws NamingException
{
- BigInteger l_childId = m_ndnIdx.forwardLookup( a_dn ) ;
- return ( BigInteger ) m_heirarchyIdx.reverseLookup( l_childId ) ;
+ BigInteger childId = ndnIdx.forwardLookup( dn );
+ return ( BigInteger ) heirarchyIdx.reverseLookup( childId );
}
/**
- * @see org.apache.ldap.server.backend.Database#getParentId(java.math.BigInteger)
+ * @see Database#getParentId(java.math.BigInteger)
*/
- public BigInteger getParentId( BigInteger a_childId )
+ public BigInteger getParentId( BigInteger childId )
throws NamingException
{
- return ( BigInteger ) m_heirarchyIdx.reverseLookup( a_childId ) ;
+ return ( BigInteger ) heirarchyIdx.reverseLookup( childId );
}
/**
- * @see org.apache.ldap.server.backend.Database#getEntryUpdn(java.math.BigInteger)
+ * @see Database#getEntryUpdn(java.math.BigInteger)
*/
- public String getEntryUpdn( BigInteger a_id )
+ public String getEntryUpdn( BigInteger id )
throws NamingException
{
- return ( String ) m_updnIdx.reverseLookup( a_id ) ;
+ return ( String ) updnIdx.reverseLookup( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#getEntryUpdn(java.lang.String)
+ * @see Database#getEntryUpdn(String)
*/
- public String getEntryUpdn( String a_dn )
+ public String getEntryUpdn( String dn )
throws NamingException
{
- BigInteger l_id = m_ndnIdx.forwardLookup( a_dn ) ;
- return ( String ) m_updnIdx.reverseLookup( l_id ) ;
+ BigInteger id = ndnIdx.forwardLookup( dn );
+ return ( String ) updnIdx.reverseLookup( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#count()
+ * @see Database#count()
*/
- public int count()
- throws NamingException
+ public int count() throws NamingException
{
- return m_master.count() ;
+ return master.count();
}
@@ -660,41 +422,41 @@
* the master table.
*
* @todo Optimize this by walking the heirarchy index instead of the name
- * @param a_aliasId the id of the alias entry in the master table
+ * @param aliasId the id of the alias entry in the master table
* @throws NamingException if we cannot delete the indices
*/
- private void dropAliasIndices( BigInteger a_aliasId ) throws NamingException
+ private void dropAliasIndices( BigInteger aliasId ) throws NamingException
{
- String l_targetDn = ( String ) m_aliasIdx.reverseLookup( a_aliasId ) ;
- BigInteger l_targetId = getEntryId( l_targetDn ) ;
- String l_aliasDn = getEntryDn( a_aliasId ) ;
- Name l_ancestorDn = new LdapName( l_aliasDn ).getSuffix( 1 ) ;
- BigInteger l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+ BigInteger targetId = getEntryId( targetDn );
+ String aliasDn = getEntryDn( aliasId );
+ Name ancestorDn = new LdapName( aliasDn ).getSuffix( 1 );
+ BigInteger ancestorId = getEntryId( ancestorDn.toString() );
/*
* We cannot just drop all tuples in the one level and subtree indices
- * linking baseIds to the l_targetId. If more than one alias refers to
+ * linking baseIds to the targetId. If more than one alias refers to
* the target then droping all tuples with a value of targetId would
* make all other aliases to the target inconsistent.
*
* We need to walk up the path of alias ancestors until we reach the
- * suffix, deleting each ( l_ancestorId, l_targetId ) tuple in the
+ * suffix, deleting each ( ancestorId, targetId ) tuple in the
* subtree scope alias. We only need to do this for the direct parent
* of the alias on the one level subtree.
*/
- m_oneAliasIdx.drop( l_ancestorId, l_targetId ) ;
- m_subAliasIdx.drop( l_ancestorId, l_targetId ) ;
+ oneAliasIdx.drop( ancestorId, targetId );
+ subAliasIdx.drop( ancestorId, targetId );
- while ( ! l_ancestorDn.equals( m_suffix ) )
+ while ( ! ancestorDn.equals( suffix ) )
{
- l_ancestorDn = l_ancestorDn.getSuffix( 1 ) ;
- l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ ancestorDn = ancestorDn.getSuffix( 1 );
+ ancestorId = getEntryId( ancestorDn.toString() );
- m_subAliasIdx.drop( l_ancestorId, l_targetId ) ;
+ subAliasIdx.drop( ancestorId, targetId );
}
// Drops all alias tuples pointing to the id of the alias to be deleted
- m_aliasIdx.drop( a_aliasId ) ;
+ aliasIdx.drop( aliasId );
}
@@ -702,27 +464,25 @@
* Adds indices for an aliasEntry to be added to the database while checking
* for constrained alias constructs like alias cycles and chaining.
*
- * @param a_aliasDn normalized distinguished name for the alias entry
- * @param a_aliasTarget the user provided aliased entry dn as a string
- * @param a_aliasId the id of alias entry to add
+ * @param aliasDn normalized distinguished name for the alias entry
+ * @param aliasTarget the user provided aliased entry dn as a string
+ * @param aliasId the id of alias entry to add
* @throws NamingException if index addition fails, of the alias is not
* allowed due to chaining or cycle formation.
*/
- private void addAliasIndices( BigInteger a_aliasId, Name a_aliasDn,
- String a_aliasTarget ) throws NamingException
- // Attributes a_aliasEntry ) throws NamingException
- {
- Name l_targetDn = null ; // Name value of aliasedObjectName
- Attributes l_target = null ; // Attributes of the target entry
- BigInteger l_targetId = null ; // Id of the aliasedObjectName
- Normalizer l_normalizer = null ; // Temporary handle for Dn's
- Name l_ancestorDn = null ; // Name of an alias entry relative
- BigInteger l_ancestorId = null ; // Id of an alias entry relative
+ private void addAliasIndices( BigInteger aliasId, Name aliasDn,
+ String aliasTarget ) throws NamingException
+ // Attributes aliasEntry ) throws NamingException
+ {
+ Name targetDn = null; // Name value of aliasedObjectName
+ BigInteger targetId = null; // Id of the aliasedObjectName
+ Normalizer normalizer = null; // Temporary handle for Dn's
+ Name ancestorDn = null; // Name of an alias entry relative
+ BigInteger ancestorId = null; // Id of an alias entry relative
// Access aliasedObjectName, normalize it and generate the Name
- l_normalizer = m_oneAliasIdx.getAttribute().getNormalizer() ;
- l_targetDn = new LdapName( ( String )
- l_normalizer.normalize( a_aliasTarget ) ) ;
+ normalizer = oneAliasIdx.getAttribute().getNormalizer();
+ targetDn = new LdapName( ( String ) normalizer.normalize( aliasTarget ) );
/*
* Check For Cycles
@@ -734,39 +494,39 @@
* entry Dn starts with the target Dn. If it does then we know the
* aliased target is a relative and we have a perspecitive cycle.
*/
- if ( a_aliasDn.startsWith( l_targetDn ) )
+ if ( aliasDn.startsWith( targetDn ) )
{
- if ( a_aliasDn.equals( l_targetDn ) )
+ if ( aliasDn.equals( targetDn ) )
{
throw new NamingException( "[36] aliasDereferencingProblem - "
- + "attempt to create alias to itself." ) ;
+ + "attempt to create alias to itself." );
}
throw new NamingException( "[36] aliasDereferencingProblem - "
+ "attempt to create alias with cycle to relative "
- + a_aliasTarget + " not allowed from descendent alias "
- + a_aliasDn ) ;
+ + aliasTarget + " not allowed from descendent alias "
+ + aliasDn );
}
/*
* Check For Aliases External To Naming Context
*
- * l_id may be null but the alias may be to a valid entry in
+ * id may be null but the alias may be to a valid entry in
* another namingContext. Such aliases are not allowed and we
* need to point it out to the user instead of saying the target
* does not exist when it potentially could outside of this suffix.
*/
- if ( ! l_targetDn.startsWith( m_suffix ) )
+ if ( ! targetDn.startsWith( suffix ) )
{
// Complain specifically about aliases to outside naming contexts
throw new NamingException( "[36] aliasDereferencingProblem -"
- + " the alias points to an entry outside of the " + m_suffix
+ + " the alias points to an entry outside of the " + suffix
+ " namingContext to an object whose existance cannot be"
- + " determined." ) ;
+ + " determined." );
}
// L O O K U P T A R G E T I D
- l_targetId = m_ndnIdx.forwardLookup( l_targetDn.toString() ) ;
+ targetId = ndnIdx.forwardLookup( targetDn.toString() );
/*
* Check For Target Existance
@@ -774,13 +534,13 @@
* We do not allow the creation of inconsistant aliases. Aliases should
* not be broken links. If the target does not exist we start screaming
*/
- if ( null == l_targetId )
+ if ( null == targetId )
{
// Complain about target not existing
throw new NamingException( "[33] aliasProblem - "
+ "the alias when dereferenced would not name a known object "
+ "the aliasedObjectName must be set to a valid existing "
- + "entry." ) ;
+ + "entry." );
}
/*
@@ -793,16 +553,16 @@
* then we have a situation where an alias chain is being created.
* Alias chaining is not allowed so we throw and exception.
*/
- if ( null != m_aliasIdx.reverseLookup( l_targetId ) )
+ if ( null != aliasIdx.reverseLookup( targetId ) )
{
// Complain about illegal alias chain
throw new NamingException( "[36] aliasDereferencingProblem -"
+ " the alias points to another alias. Alias chaining is"
- + " not supported by this backend." ) ;
+ + " not supported by this backend." );
}
// Add the alias to the simple alias index
- m_aliasIdx.add( a_aliasTarget, a_aliasId ) ;
+ aliasIdx.add( aliasTarget, aliasId );
/*
* Handle One Level Scope Alias Index
@@ -811,12 +571,12 @@
* index. If the target is not a sibling of the alias then we add the
* index entry maping the parent's id to the aliased target id.
*/
- l_ancestorDn = a_aliasDn.getSuffix( 1 ) ;
- l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ ancestorDn = aliasDn.getSuffix( 1 );
+ ancestorId = getEntryId( ancestorDn.toString() );
- if ( ! NamespaceTools.isSibling( l_targetDn, a_aliasDn ) )
+ if ( ! NamespaceTools.isSibling( targetDn, aliasDn ) )
{
- m_oneAliasIdx.add( l_ancestorId, l_targetId ) ;
+ oneAliasIdx.add( ancestorId, targetId );
}
/*
@@ -829,28 +589,27 @@
* ignored since everything is under its scope. The first loop
* iteration shall handle the parents.
*/
- while ( ! l_ancestorDn.equals( m_suffix ) && null != l_ancestorId )
+ while ( ! ancestorDn.equals( suffix ) && null != ancestorId )
{
- if ( ! NamespaceTools.isDescendant( l_ancestorDn, l_targetDn ) )
+ if ( ! NamespaceTools.isDescendant( ancestorDn, targetDn ) )
{
- m_subAliasIdx.add( l_ancestorId, l_targetId ) ;
+ subAliasIdx.add( ancestorId, targetId );
}
- l_ancestorDn = l_ancestorDn.getSuffix( 1 ) ;
- l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ ancestorDn = ancestorDn.getSuffix( 1 );
+ ancestorId = getEntryId( ancestorDn.toString() );
}
}
/**
- * @see org.apache.ldap.server.backend.Database#add(javax.naming.Name,
- * javax.naming.directory.Attributes)
+ * @see Database#add(String,Name,Attributes)
*/
- public void add( String a_updn, Name a_dn, Attributes an_entry )
+ public void add( String updn, Name dn, Attributes entry )
throws NamingException
{
- BigInteger l_id = m_master.getNextId() ;
- BigInteger l_parentId = null ;
+ BigInteger id = master.getNextId();
+ BigInteger parentId = null;
//
// Suffix entry cannot have a parent since it is the root so it is
@@ -858,395 +617,391 @@
// entry sequences start at 1.
//
- if ( a_dn.equals( m_suffix ) )
+ if ( dn.equals( suffix ) )
{
- l_parentId = BigInteger.ZERO ;
+ parentId = BigInteger.ZERO;
}
else
{
- l_parentId = getEntryId( a_dn.getSuffix( 1 ).toString() ) ;
+ parentId = getEntryId( dn.getSuffix( 1 ).toString() );
}
// Start adding the system indices
// Why bother doing a lookup if this is not an alias.
- if ( an_entry.get( "objectClass" ).contains( ALIAS_OBJECT ) )
+ if ( entry.get( "objectClass" ).contains( ALIAS_OBJECT ) )
{
- addAliasIndices( l_id, a_dn,
- ( String ) an_entry.get( ALIAS_ATTRIBUTE ).get() ) ;
+ addAliasIndices( id, dn, ( String ) entry.get( ALIAS_ATTRIBUTE ).get() );
}
- m_ndnIdx.add( a_dn.toString(), l_id ) ;
- m_updnIdx.add( a_updn, l_id ) ;
- m_heirarchyIdx.add( l_parentId, l_id ) ;
+ ndnIdx.add( dn.toString(), id );
+ updnIdx.add( updn, id );
+ heirarchyIdx.add( parentId, id );
// Now work on the user defined indices
- NamingEnumeration l_list = an_entry.getIDs() ;
- while ( l_list.hasMore() )
+ NamingEnumeration list = entry.getIDs();
+ while ( list.hasMore() )
{
- String l_attribute = ( String ) l_list.next() ;
+ String attribute = ( String ) list.next();
- if ( hasUserIndexOn( l_attribute ) )
+ if ( hasUserIndexOn( attribute ) )
{
- Index l_idx = getUserIndex( l_attribute ) ;
- NamingEnumeration l_values =
- an_entry.get( l_attribute ).getAll() ;
+ Index idx = getUserIndex( attribute );
+ NamingEnumeration values = entry.get( attribute ).getAll();
- while ( l_values.hasMore() )
+ while ( values.hasMore() )
{
- l_idx.add( l_values.next(), l_id ) ;
+ idx.add( values.next(), id );
}
// Adds only those attributes that are indexed
- m_existanceIdx.add( l_attribute.toLowerCase(), l_id ) ;
+ existanceIdx.add( attribute.toLowerCase(), id );
}
}
- m_master.put( an_entry, l_id ) ;
+ master.put( entry, id );
}
/**
- * @see org.apache.ldap.server.backend.Database#lookup(java.math.BigInteger)
+ * @see Database#lookup(java.math.BigInteger)
*/
- public Attributes lookup( BigInteger a_id ) throws NamingException
+ public Attributes lookup( BigInteger id ) throws NamingException
{
- return m_master.get( a_id ) ;
+ return master.get( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#delete(java.math.BigInteger)
+ * @see Database#delete(java.math.BigInteger)
*/
- public void delete( BigInteger a_id )
+ public void delete( BigInteger id )
throws NamingException
{
- Attributes l_entry = lookup( a_id ) ;
- BigInteger l_parentId = getParentId( a_id ) ;
- String l_dn = getEntryDn( a_id ) ;
- NamingEnumeration l_attrs = l_entry.getIDs() ;
+ Attributes entry = lookup( id );
+ BigInteger parentId = getParentId( id );
+ NamingEnumeration attrs = entry.getIDs();
- if ( l_entry.get( "objectClass" ).contains( ALIAS_OBJECT ) )
+ if ( entry.get( "objectClass" ).contains( ALIAS_OBJECT ) )
{
- dropAliasIndices( a_id ) ;
+ dropAliasIndices( id );
}
- m_ndnIdx.drop( a_id ) ;
- m_updnIdx.drop( a_id ) ;
- m_heirarchyIdx.drop( a_id ) ;
+ ndnIdx.drop( id );
+ updnIdx.drop( id );
+ heirarchyIdx.drop( id );
// Remove parent's reference to entry only if entry is not the suffix
- if ( ! l_parentId.equals( BigInteger.ZERO ) )
+ if ( ! parentId.equals( BigInteger.ZERO ) )
{
- m_heirarchyIdx.drop( l_parentId, a_id ) ;
+ heirarchyIdx.drop( parentId, id );
}
- while ( l_attrs.hasMore() )
+ while ( attrs.hasMore() )
{
- String l_attr = ( ( String ) l_attrs.next() ) ;
+ String attr = ( ( String ) attrs.next() );
- if ( hasUserIndexOn( l_attr ) )
+ if ( hasUserIndexOn( attr ) )
{
- Index l_index = ( Index ) getUserIndex( l_attr ) ;
- NamingEnumeration l_values = l_entry.get( l_attr ).getAll() ;
+ Index index = ( Index ) getUserIndex( attr );
+ NamingEnumeration values = entry.get( attr ).getAll();
- while ( l_values.hasMore() )
+ while ( values.hasMore() )
{
- l_index.drop( l_values.next(), a_id ) ;
+ index.drop( values.next(), id );
}
- m_existanceIdx.drop( l_attr.toLowerCase(), a_id ) ;
+ existanceIdx.drop( attr.toLowerCase(), id );
}
}
- m_master.delete( a_id ) ;
+ master.delete( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#list(java.math.BigInteger)
+ * @see Database#list(java.math.BigInteger)
*/
- public NamingEnumeration list( BigInteger a_id )
+ public NamingEnumeration list( BigInteger id )
throws NamingException
{
- return m_heirarchyIdx.listIndices( a_id ) ;
+ return heirarchyIdx.listIndices( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#getChildCount(java.math.BigInteger)
+ * @see Database#getChildCount(java.math.BigInteger)
*/
- public int getChildCount( BigInteger a_id )
+ public int getChildCount( BigInteger id )
throws NamingException
{
- return m_heirarchyIdx.count( a_id ) ;
+ return heirarchyIdx.count( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#getSuffix()
+ * @see Database#getSuffix()
*/
public Name getSuffix()
{
- return m_suffix ;
+ return suffix;
}
/**
- * @see org.apache.ldap.server.backend.Database#getSuffixEntry()
+ * @see Database#getSuffixEntry()
*/
public Attributes getSuffixEntry()
throws NamingException
{
- BigInteger l_id = getEntryId( m_suffix.toString() ) ;
+ BigInteger id = getEntryId( suffix.toString() );
- if ( null == l_id )
+ if ( null == id )
{
- return null ;
+ return null;
}
- return lookup( l_id ) ;
+ return lookup( id );
}
/**
- * @see org.apache.ldap.server.backend.Database#sync()
+ * @see Database#sync()
*/
public void sync()
throws NamingException
{
- ArrayList l_array = new ArrayList() ;
- l_array.addAll( m_indices.values() ) ;
- l_array.add( m_ndnIdx ) ;
- l_array.add( m_updnIdx ) ;
- l_array.add( m_aliasIdx ) ;
- l_array.add( m_oneAliasIdx ) ;
- l_array.add( m_subAliasIdx ) ;
- l_array.add( m_heirarchyIdx ) ;
- l_array.add( m_existanceIdx ) ;
+ ArrayList array = new ArrayList();
+ array.addAll( indices.values() );
+ array.add( ndnIdx );
+ array.add( updnIdx );
+ array.add( aliasIdx );
+ array.add( oneAliasIdx );
+ array.add( subAliasIdx );
+ array.add( heirarchyIdx );
+ array.add( existanceIdx );
- Iterator l_list = l_array.iterator() ;
- MultiException l_rootCause = null ;
+ Iterator list = array.iterator();
+ MultiException rootCause = null;
// Sync all user defined indices
- while ( l_list.hasNext() )
+ while ( list.hasNext() )
{
- Index l_idx = ( Index ) l_list.next() ;
+ Index idx = ( Index ) list.next();
try
{
- l_idx.sync() ;
+ idx.sync();
}
catch ( Throwable t )
{
- if ( null == l_rootCause )
+ if ( null == rootCause )
{
- l_rootCause = new MultiException() ;
+ rootCause = new MultiException();
}
- l_rootCause.addThrowable( t ) ;
+ rootCause.addThrowable( t );
}
}
try
{
- m_master.sync() ;
+ master.sync();
}
catch ( Throwable t )
{
- if ( null == l_rootCause )
+ if ( null == rootCause )
{
- l_rootCause = new MultiException() ;
+ rootCause = new MultiException();
}
- l_rootCause.addThrowable( t ) ;
+ rootCause.addThrowable( t );
}
- if ( null != l_rootCause )
+ if ( null != rootCause )
{
- NamingException l_ne = new NamingException( "Failed to sync all" ) ;
- l_ne.setRootCause( l_rootCause ) ;
- throw l_ne ;
+ NamingException ne = new NamingException( "Failed to sync all" );
+ ne.setRootCause( rootCause );
+ throw ne;
}
}
/**
- * @see org.apache.ldap.server.backend.Database#close()
+ * @see Database#close()
*/
public void close()
throws NamingException
{
- ArrayList l_array = new ArrayList() ;
- l_array.addAll( m_indices.values() ) ;
+ ArrayList array = new ArrayList();
+ array.addAll( indices.values() );
- if ( null != m_ndnIdx )
+ if ( null != ndnIdx )
{
- l_array.add( m_ndnIdx ) ;
+ array.add( ndnIdx );
}
- if ( null != m_updnIdx )
+ if ( null != updnIdx )
{
- l_array.add( m_updnIdx ) ;
+ array.add( updnIdx );
}
- if ( null != m_aliasIdx )
+ if ( null != aliasIdx )
{
- l_array.add( m_aliasIdx ) ;
+ array.add( aliasIdx );
}
- if ( null != m_oneAliasIdx )
+ if ( null != oneAliasIdx )
{
- l_array.add( m_oneAliasIdx ) ;
+ array.add( oneAliasIdx );
}
- if ( null != m_subAliasIdx )
+ if ( null != subAliasIdx )
{
- l_array.add( m_subAliasIdx ) ;
+ array.add( subAliasIdx );
}
- if ( null != m_heirarchyIdx )
+ if ( null != heirarchyIdx )
{
- l_array.add( m_heirarchyIdx ) ;
+ array.add( heirarchyIdx );
}
- if ( null != m_existanceIdx )
+ if ( null != existanceIdx )
{
- l_array.add( m_existanceIdx ) ;
+ array.add( existanceIdx );
}
- Iterator l_list = l_array.iterator() ;
- MultiException l_rootCause = null ;
+ Iterator list = array.iterator();
+ MultiException rootCause = null;
- while ( l_list.hasNext() )
+ while ( list.hasNext() )
{
- Index l_index = ( Index ) l_list.next() ;
+ Index index = ( Index ) list.next();
try
{
- l_index.close() ;
+ index.close();
}
catch ( Throwable t )
{
- if ( null == l_rootCause )
+ if ( null == rootCause )
{
- l_rootCause = new MultiException() ;
+ rootCause = new MultiException();
}
- l_rootCause.addThrowable( t ) ;
+ rootCause.addThrowable( t );
}
}
try
{
- m_master.close() ;
+ master.close();
}
catch ( Throwable t )
{
- if ( null == l_rootCause )
+ if ( null == rootCause )
{
- l_rootCause = new MultiException() ;
+ rootCause = new MultiException();
}
- l_rootCause.addThrowable( t ) ;
+ rootCause.addThrowable( t );
}
try
{
- m_recMan.close() ;
+ recMan.close();
}
catch ( Throwable t )
{
- if ( null == l_rootCause )
+ if ( null == rootCause )
{
- l_rootCause = new MultiException() ;
+ rootCause = new MultiException();
}
- l_rootCause.addThrowable( t ) ;
+ rootCause.addThrowable( t );
}
- if ( null != l_rootCause )
+ if ( null != rootCause )
{
- NamingException l_ne =
- new NamingException( "Failed to close all" ) ;
- l_ne.setRootCause( l_rootCause ) ;
- throw l_ne ;
+ NamingException ne =
+ new NamingException( "Failed to close all" );
+ ne.setRootCause( rootCause );
+ throw ne;
}
}
/**
- * @see org.apache.ldap.server.backend.Database#setProperty(java.lang.String,
- * java.lang.String)
+ * @see Database#setProperty(String,
+ * String)
*/
- public void setProperty( String a_propertyName, String a_propertyValue )
+ public void setProperty( String propertyName, String propertyValue )
throws NamingException
{
- m_master.setProperty( a_propertyName, a_propertyValue ) ;
+ master.setProperty( propertyName, propertyValue );
}
/**
- * @see org.apache.ldap.server.backend.Database#getProperty(java.lang.String)
+ * @see Database#getProperty(String)
*/
- public String getProperty( String a_propertyName )
+ public String getProperty( String propertyName )
throws NamingException
{
- return m_master.getProperty( a_propertyName ) ;
+ return master.getProperty( propertyName );
}
/**
- * @see org.apache.ldap.server.backend.Database#getIndices(java.math.BigInteger)
+ * @see Database#getIndices(java.math.BigInteger)
*/
- public Attributes getIndices( BigInteger a_id )
- throws NamingException
+ public Attributes getIndices( BigInteger id ) throws NamingException
{
- Attributes l_attributes = new LockableAttributesImpl() ;
+ Attributes attributes = new LockableAttributesImpl();
// Get the distinguishedName to id mapping
- l_attributes.put( "_nDn", getEntryDn( a_id ) ) ;
- l_attributes.put( "_upDn", getEntryUpdn( a_id ) ) ;
- l_attributes.put( "_parent", getParentId( a_id ) ) ;
+ attributes.put( "_nDn", getEntryDn( id ) );
+ attributes.put( "_upDn", getEntryUpdn( id ) );
+ attributes.put( "_parent", getParentId( id ) );
// Get all standard index attribute to value mappings
- Iterator l_indices = m_indices.values().iterator() ;
- while ( l_indices.hasNext() )
+ Iterator idxList = this.indices.values().iterator();
+ while ( idxList.hasNext() )
{
- Index l_index = ( Index ) l_indices.next() ;
- NamingEnumeration l_list = l_index.listReverseIndices( a_id ) ;
- while ( l_list.hasMore() )
- {
- IndexRecord l_rec = ( IndexRecord ) l_list.next() ;
- Object l_val = l_rec.getIndexKey() ;
- l_attributes.put( l_index.getAttribute().getName(), l_val ) ;
+ Index index = ( Index ) idxList.next();
+ NamingEnumeration list = index.listReverseIndices( id );
+ while ( list.hasMore() )
+ {
+ IndexRecord rec = ( IndexRecord ) list.next();
+ Object val = rec.getIndexKey();
+ attributes.put( index.getAttribute().getName(), val );
}
}
// Get all existance mappings for this id creating a special key
// that looks like so 'existance[attribute]' and the value is set to id
- NamingEnumeration l_list = m_existanceIdx.listReverseIndices( a_id ) ;
- StringBuffer l_val = new StringBuffer() ;
- while ( l_list.hasMore() )
- {
- IndexRecord l_rec = ( IndexRecord ) l_list.next() ;
- l_val.append( "_existance[" ) ;
- l_val.append( l_rec.getIndexKey() ) ;
- l_val.append( ']' ) ;
- l_attributes.put( l_val.toString(), l_rec.getEntryId() ) ;
- l_val.setLength( 0 ) ;
+ NamingEnumeration list = existanceIdx.listReverseIndices( id );
+ StringBuffer val = new StringBuffer();
+ while ( list.hasMore() )
+ {
+ IndexRecord rec = ( IndexRecord ) list.next();
+ val.append( "_existance[" );
+ val.append( rec.getIndexKey() );
+ val.append( ']' );
+ attributes.put( val.toString(), rec.getEntryId() );
+ val.setLength( 0 );
}
// Get all parent child mappings for this entry as the parent using the
// key 'child' with many entries following it.
- l_list = m_heirarchyIdx.listIndices( a_id ) ;
- while ( l_list.hasMore() )
+ list = heirarchyIdx.listIndices( id );
+ while ( list.hasMore() )
{
- IndexRecord l_rec = ( IndexRecord ) l_list.next() ;
- l_attributes.put( "_child", l_rec.getEntryId() ) ;
+ IndexRecord rec = ( IndexRecord ) list.next();
+ attributes.put( "_child", rec.getEntryId() );
}
- return l_attributes ;
+ return attributes;
}
@@ -1255,34 +1010,34 @@
* The entry is not persisted: it is only changed in anticipation for a put
* into the master table.
*
- * @param a_id the primary key of the entry
- * @param a_entry the entry to alter
- * @param a_mods the attribute and values to add
+ * @param id the primary key of the entry
+ * @param entry the entry to alter
+ * @param mods the attribute and values to add
* @throws NamingException if index alteration or attribute addition
* fails.
*/
- private void add( BigInteger a_id, Attributes a_entry, Attribute a_mods )
+ private void add( BigInteger id, Attributes entry, Attribute mods )
throws NamingException
{
- if ( hasUserIndexOn( a_mods.getID() ) )
+ if ( hasUserIndexOn( mods.getID() ) )
{
- Index l_idx = getUserIndex( a_mods.getID() ) ;
- l_idx.add( a_mods, a_id ) ;
+ Index idx = getUserIndex( mods.getID() );
+ idx.add( mods, id );
// If the attr didn't exist for this id add it to existance index
- if ( ! m_existanceIdx.hasValue( a_mods.getID(), a_id ) )
+ if ( ! existanceIdx.hasValue( mods.getID(), id ) )
{
- l_idx.add( a_mods.getID(), a_id ) ;
+ idx.add( mods.getID(), id );
}
}
- a_entry.put( a_mods ) ;
+ entry.put( mods );
- if ( a_mods.getID().equals( ALIAS_ATTRIBUTE ) )
+ if ( mods.getID().equals( ALIAS_ATTRIBUTE ) )
{
- String l_ndnStr = ( String ) m_ndnIdx.reverseLookup( a_id ) ;
- addAliasIndices( a_id, new LdapName( l_ndnStr ),
- ( String ) a_mods.get() ) ;
+ String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+ addAliasIndices( id, new LdapName( ndnStr ),
+ ( String ) mods.get() );
}
}
@@ -1295,54 +1050,54 @@
* values within the entry where as an attribute w/ values will remove those
* attribute values it contains.
*
- * @param a_id the primary key of the entry
- * @param a_entry the entry to alter
- * @param a_mods the attribute and its values to delete
+ * @param id the primary key of the entry
+ * @param entry the entry to alter
+ * @param mods the attribute and its values to delete
* @throws NamingException if index alteration or attribute modification
* fails.
*/
- private void remove( BigInteger a_id, Attributes a_entry, Attribute a_mods )
+ private void remove( BigInteger id, Attributes entry, Attribute mods )
throws NamingException
{
- if ( hasUserIndexOn( a_mods.getID() ) )
+ if ( hasUserIndexOn( mods.getID() ) )
{
- Index l_idx = getUserIndex( a_mods.getID() ) ;
- l_idx.drop( a_mods, a_id ) ;
+ Index idx = getUserIndex( mods.getID() );
+ idx.drop( mods, id );
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
*/
- if ( null == l_idx.reverseLookup( a_id ) )
+ if ( null == idx.reverseLookup( id ) )
{
- m_existanceIdx.drop( a_mods.getID(), a_id ) ;
+ existanceIdx.drop( mods.getID(), id );
}
}
/*
* If there are no attribute values in the modifications then this
* implies the compelete removal of the attribute from the entry. Else
- * we remove individual attribute values from the entry in a_mods one
+ * we remove individual attribute values from the entry in mods one
* at a time.
*/
- if ( a_mods.size() == 0 )
+ if ( mods.size() == 0 )
{
- a_entry.remove( a_mods.getID() ) ;
+ entry.remove( mods.getID() );
}
else
{
- Attribute l_entryAttr = a_entry.get( a_mods.getID() ) ;
- NamingEnumeration l_values = a_mods.getAll() ;
- while ( l_values.hasMore() )
+ Attribute entryAttr = entry.get( mods.getID() );
+ NamingEnumeration values = mods.getAll();
+ while ( values.hasMore() )
{
- l_entryAttr.remove( l_values.next() ) ;
+ entryAttr.remove( values.next() );
}
}
// Aliases->single valued comp/partial attr removal is not relevant here
- if ( a_mods.getID().equals( ALIAS_ATTRIBUTE ) )
+ if ( mods.getID().equals( ALIAS_ATTRIBUTE ) )
{
- dropAliasIndices( a_id ) ;
+ dropAliasIndices( id );
}
}
@@ -1353,138 +1108,137 @@
* is not persisted: it is only changed in anticipation for a put into the
* master table.
*
- * @param a_id the primary key of the entry
- * @param a_entry the entry to alter
- * @param a_mods the replacement attribute and values
+ * @param id the primary key of the entry
+ * @param entry the entry to alter
+ * @param mods the replacement attribute and values
* @throws NamingException if index alteration or attribute modification
* fails.
*/
- private void replace( BigInteger a_id, Attributes a_entry,
- Attribute a_mods ) throws NamingException
+ private void replace( BigInteger id, Attributes entry,
+ Attribute mods ) throws NamingException
{
- if ( hasUserIndexOn( a_mods.getID() ) )
+ if ( hasUserIndexOn( mods.getID() ) )
{
- Index l_idx = getUserIndex( a_mods.getID() ) ;
+ Index idx = getUserIndex( mods.getID() );
// Drop all existing attribute value index entries and add new ones
- l_idx.drop( a_id ) ;
- l_idx.add( a_mods, a_id ) ;
+ idx.drop( id );
+ idx.add( mods, id );
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
*/
- if ( null == l_idx.reverseLookup( a_id ) )
+ if ( null == idx.reverseLookup( id ) )
{
- m_existanceIdx.drop( a_mods.getID(), a_id ) ;
+ existanceIdx.drop( mods.getID(), id );
}
}
- if ( a_mods.getID().equals( ALIAS_ATTRIBUTE ) )
+ if ( mods.getID().equals( ALIAS_ATTRIBUTE ) )
{
- dropAliasIndices( a_id ) ;
+ dropAliasIndices( id );
}
// Automatically replaces old attributes with new modified ones
- a_entry.put( a_mods ) ;
+ entry.put( mods );
- if ( a_mods.getID().equals( ALIAS_ATTRIBUTE ) )
+ if ( mods.getID().equals( ALIAS_ATTRIBUTE ) )
{
- String l_ndnStr = ( String ) m_ndnIdx.reverseLookup( a_id ) ;
- addAliasIndices( a_id, new LdapName( l_ndnStr ),
- ( String ) a_mods.get() ) ;
+ String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+ addAliasIndices( id, new LdapName( ndnStr ),
+ ( String ) mods.get() );
}
}
/**
- * @see org.apache.ldap.server.backend.Database#modify(javax.naming.Name, int,
+ * @see Database#modify(javax.naming.Name, int,
* javax.naming.directory.Attributes)
*/
- public void modify( Name a_dn, int a_modOp, Attributes a_mods )
+ public void modify( Name dn, int modOp, Attributes mods )
throws NamingException
{
- NamingEnumeration l_attrs = null ;
- BigInteger l_id = getEntryId( a_dn.toString() ) ;
- Attributes l_entry = m_master.get( l_id ) ;
+ NamingEnumeration attrs = null;
+ BigInteger id = getEntryId( dn.toString() );
+ Attributes entry = master.get( id );
- switch ( a_modOp )
+ switch ( modOp )
{
case( DirContext.ADD_ATTRIBUTE ):
- l_attrs = a_mods.getIDs() ;
+ attrs = mods.getIDs();
- while ( l_attrs.hasMore() )
+ while ( attrs.hasMore() )
{
- String l_attrId = ( String ) l_attrs.next() ;
- Attribute l_attr = a_mods.get( l_attrId ) ;
- add( l_id, l_entry, l_attr ) ;
+ String attrId = ( String ) attrs.next();
+ Attribute attr = mods.get( attrId );
+ add( id, entry, attr );
}
- break ;
+ break;
case( DirContext.REMOVE_ATTRIBUTE ):
- l_attrs = a_mods.getIDs() ;
+ attrs = mods.getIDs();
- while ( l_attrs.hasMore() )
+ while ( attrs.hasMore() )
{
- String l_attrId = ( String ) l_attrs.next() ;
- Attribute l_attr = a_mods.get( l_attrId ) ;
- remove( l_id, l_entry, l_attr ) ;
+ String attrId = ( String ) attrs.next();
+ Attribute attr = mods.get( attrId );
+ remove( id, entry, attr );
}
- break ;
+ break;
case( DirContext.REPLACE_ATTRIBUTE ):
- l_attrs = a_mods.getIDs() ;
+ attrs = mods.getIDs();
- while ( l_attrs.hasMore() )
+ while ( attrs.hasMore() )
{
- String l_attrId = ( String ) l_attrs.next() ;
- Attribute l_attr = a_mods.get( l_attrId ) ;
- replace( l_id, l_entry, l_attr ) ;
+ String attrId = ( String ) attrs.next();
+ Attribute attr = mods.get( attrId );
+ replace( id, entry, attr );
}
- break ;
+ break;
default:
throw new NamingException(
- "Unidentified modification operation" ) ;
+ "Unidentified modification operation" );
}
- m_master.put( l_entry, l_id ) ;
+ master.put( entry, id );
}
/**
- * @see org.apache.ldap.server.backend.Database#modify(javax.naming.Name,
+ * @see Database#modify(javax.naming.Name,
* javax.naming.directory.ModificationItem[])
*/
- public void modify( Name a_dn, ModificationItem [] a_mods )
+ public void modify( Name dn, ModificationItem [] mods )
throws NamingException
{
- NamingEnumeration l_attrs = null ;
- BigInteger l_id = getEntryId( a_dn.toString() ) ;
- Attributes l_entry = m_master.get( l_id ) ;
+ BigInteger id = getEntryId( dn.toString() );
+ Attributes entry = master.get( id );
- for ( int ii = 0; ii < a_mods.length ; ii++ )
+ for ( int ii = 0; ii < mods.length; ii++ )
{
- Attribute l_attrMods = a_mods[ii].getAttribute() ;
+ Attribute attrMods = mods[ii].getAttribute();
- switch ( a_mods[ ii ].getModificationOp() )
+ switch ( mods[ ii ].getModificationOp() )
{
case( DirContext.ADD_ATTRIBUTE ):
- add( l_id, l_entry, l_attrMods ) ;
- break ;
+ add( id, entry, attrMods );
+ break;
case( DirContext.REMOVE_ATTRIBUTE ):
- remove( l_id, l_entry, l_attrMods ) ;
- break ;
+ remove( id, entry, attrMods );
+ break;
case( DirContext.REPLACE_ATTRIBUTE ):
- replace( l_id, l_entry, l_attrMods ) ;
- break ;
+ replace( id, entry, attrMods );
+ break;
default:
throw new NamingException(
- "Unidentified modification operation" ) ;
+ "Unidentified modification operation" );
}
}
- m_master.put( l_entry, l_id ) ;
+ master.put( entry, id );
}
@@ -1499,22 +1253,22 @@
* changed. The change propagates down the subtree rooted at the
* distinguished name specified.
*
- * @param a_dn the normalized distinguished name of the entry to alter
- * @param a_newRdn the new Rdn to set
- * @param a_deleteOldRdn whether or not to remove the old Rdn attr/val
+ * @param dn the normalized distinguished name of the entry to alter
+ * @param newRdn the new Rdn to set
+ * @param deleteOldRdn whether or not to remove the old Rdn attr/val
* @throws NamingException if there are any errors propagating the name
* changes.
- * @see org.apache.ldap.server.backend.Database#modifyRdn(javax.naming.Name,
- * java.lang.String, boolean)
+ * @see Database#modifyRdn(javax.naming.Name,
+ * String, boolean)
*/
- public void modifyRdn( Name a_dn, String a_newRdn, boolean a_deleteOldRdn )
+ public void modifyRdn( Name dn, String newRdn, boolean deleteOldRdn )
throws NamingException
{
- String l_newRdnAttr = NamespaceTools.getRdnAttribute( a_newRdn ) ;
- String l_newRdnValue = NamespaceTools.getRdnValue( a_newRdn ) ;
- BigInteger l_id = getEntryId( a_dn.toString() ) ;
- Attributes l_entry = lookup( l_id ) ;
- Name l_updn = new LdapName( getEntryUpdn( l_id ) ) ;
+ String newRdnAttr = NamespaceTools.getRdnAttribute( newRdn );
+ String newRdnValue = NamespaceTools.getRdnValue( newRdn );
+ BigInteger id = getEntryId( dn.toString() );
+ Attributes entry = lookup( id );
+ Name updn = new LdapName( getEntryUpdn( id ) );
/*
* H A N D L E N E W R D N
@@ -1525,17 +1279,17 @@
* new Rdn attribute within this entry.
*/
- l_entry.put( l_newRdnAttr, l_newRdnValue ) ;
+ entry.put( newRdnAttr, newRdnValue );
- if ( hasUserIndexOn( l_newRdnAttr ) )
+ if ( hasUserIndexOn( newRdnAttr ) )
{
- Index l_idx = getUserIndex( l_newRdnAttr ) ;
- l_idx.add( l_newRdnValue, l_id ) ;
+ Index idx = getUserIndex( newRdnAttr );
+ idx.add( newRdnValue, id );
// Make sure the altered entry shows the existance of the new attrib
- if ( ! m_existanceIdx.hasValue( l_newRdnAttr, l_id ) )
+ if ( ! existanceIdx.hasValue( newRdnAttr, id ) )
{
- m_existanceIdx.add( l_newRdnAttr, l_id ) ;
+ existanceIdx.add( newRdnAttr, id );
}
}
@@ -1553,26 +1307,26 @@
* tuple from the existance index.
*/
- if ( a_deleteOldRdn )
+ if ( deleteOldRdn )
{
- String l_oldRdn = l_updn.get( l_updn.size() - 1 ) ;
- String l_oldRdnAttr = NamespaceTools.getRdnAttribute( l_oldRdn ) ;
- String l_oldRdnValue = NamespaceTools.getRdnAttribute( l_oldRdn ) ;
+ String oldRdn = updn.get( updn.size() - 1 );
+ String oldRdnAttr = NamespaceTools.getRdnAttribute( oldRdn );
+ String oldRdnValue = NamespaceTools.getRdnAttribute( oldRdn );
- l_entry.get( l_oldRdnAttr ).remove( l_oldRdnValue ) ;
+ entry.get( oldRdnAttr ).remove( oldRdnValue );
- if ( hasUserIndexOn( l_oldRdnAttr ) )
+ if ( hasUserIndexOn( oldRdnAttr ) )
{
- Index l_idx = getUserIndex( l_oldRdnAttr ) ;
- l_idx.drop( l_oldRdnValue, l_id ) ;
+ Index idx = getUserIndex( oldRdnAttr );
+ idx.drop( oldRdnValue, id );
/*
- * If there is no value for l_id in this index due to our
- * drop above we remove the l_oldRdnAttr from the existance idx
+ * If there is no value for id in this index due to our
+ * drop above we remove the oldRdnAttr from the existance idx
*/
- if ( null == l_idx.reverseLookup( l_id ) )
+ if ( null == idx.reverseLookup( id ) )
{
- m_existanceIdx.drop( l_oldRdnAttr, l_id ) ;
+ existanceIdx.drop( oldRdnAttr, id );
}
}
}
@@ -1588,10 +1342,10 @@
* entry and its descendants
*/
- Name l_newUpdn = ( Name ) l_updn.clone() ; // copy da old updn
- l_newUpdn.remove( l_newUpdn.size() - 1 ) ; // remove old upRdn
- l_newUpdn.add( l_newUpdn.size(), a_newRdn ) ; // add da new upRdn
- modifyDn( l_id, l_newUpdn, false ) ; // propagate dn changes
+ Name newUpdn = ( Name ) updn.clone(); // copy da old updn
+ newUpdn.remove( newUpdn.size() - 1 ); // remove old upRdn
+ newUpdn.add( newUpdn.size(), newRdn ); // add da new upRdn
+ modifyDn( id, newUpdn, false ); // propagate dn changes
}
@@ -1606,23 +1360,23 @@
* Recursively modifies the distinguished name of an entry and the names of
* its descendants calling itself in the recursion.
*
- * @param a_id the primary key of the entry
- * @param a_updn User provided distinguished name to set as the new DN
- * @param a_isMove whether or not the name change is due to a move operation
+ * @param id the primary key of the entry
+ * @param updn User provided distinguished name to set as the new DN
+ * @param isMove whether or not the name change is due to a move operation
* which affects alias indices.
* @throws NamingException if something goes wrong
*/
- private void modifyDn( BigInteger a_id, Name a_updn, boolean a_isMove )
+ private void modifyDn( BigInteger id, Name updn, boolean isMove )
throws NamingException
{
- String l_aliasTarget = null ;
+ String aliasTarget = null;
// Now we can handle the appropriate name indices for all cases
- m_ndnIdx.drop( a_id ) ;
- m_ndnIdx.add( m_ndnIdx.getNormalized( a_updn.toString() ), a_id ) ;
+ ndnIdx.drop( id );
+ ndnIdx.add( ndnIdx.getNormalized( updn.toString() ), id );
- m_updnIdx.drop( a_id ) ;
- m_updnIdx.add( a_updn.toString(), a_id ) ;
+ updnIdx.drop( id );
+ updnIdx.add( updn.toString(), id );
/*
* Read Alias Index Tuples
@@ -1631,51 +1385,51 @@
* subtree indices for aliases were purged before the aliases were
* moved. Now we must add them for each alias entry we have moved.
*
- * l_aliasTarget is used as a marker to tell us if we're moving an
+ * aliasTarget is used as a marker to tell us if we're moving an
* alias. If it is null then the moved entry is not an alias.
*/
- if ( a_isMove )
+ if ( isMove )
{
- l_aliasTarget = ( String ) m_aliasIdx.reverseLookup( a_id ) ;
+ aliasTarget = ( String ) aliasIdx.reverseLookup( id );
- if ( null != l_aliasTarget )
+ if ( null != aliasTarget )
{
- addAliasIndices( a_id, new LdapName( getEntryDn( a_id ) ),
- l_aliasTarget ) ;
+ addAliasIndices( id, new LdapName( getEntryDn( id ) ),
+ aliasTarget );
}
}
- NamingEnumeration l_children = list( a_id ) ;
- while ( l_children.hasMore() )
+ NamingEnumeration children = list( id );
+ while ( children.hasMore() )
{
// Get the child and its id
- IndexRecord l_rec = ( IndexRecord ) l_children.next() ;
- BigInteger l_childId = l_rec.getEntryId() ;
+ IndexRecord rec = ( IndexRecord ) children.next();
+ BigInteger childId = rec.getEntryId();
/*
* Calculate the Dn for the child's new name by copying the parents
* new name and adding the child's old upRdn to new name as its Rdn
*/
- Name l_childUpdn = ( Name ) a_updn.clone() ;
- Name l_oldUpdn = new LdapName( getEntryUpdn( l_childId ) ) ;
- String l_rdn = LdapName.getRdn( l_oldUpdn ) ;
- l_childUpdn.add( l_childUpdn.size(), l_rdn ) ;
+ Name childUpdn = ( Name ) updn.clone();
+ Name oldUpdn = new LdapName( getEntryUpdn( childId ) );
+ String rdn = LdapName.getRdn( oldUpdn );
+ childUpdn.add( childUpdn.size(), rdn );
// Recursively change the names of the children below
- modifyDn( l_childId, l_childUpdn, a_isMove ) ;
+ modifyDn( childId, childUpdn, isMove );
}
}
/**
- * @see org.apache.ldap.server.backend.Database#move(javax.naming.Name,
- * javax.naming.Name, java.lang.String, boolean)
+ * @see Database#move(javax.naming.Name,
+ * javax.naming.Name, String, boolean)
*/
- public void move( Name a_oldChildDn, Name a_newParentDn, String a_newRdn,
- boolean a_deleteOldRdn ) throws NamingException
+ public void move( Name oldChildDn, Name newParentDn, String newRdn,
+ boolean deleteOldRdn ) throws NamingException
{
- modifyRdn( a_oldChildDn, a_newRdn, a_deleteOldRdn ) ;
- move( a_oldChildDn, a_newParentDn ) ;
+ modifyRdn( oldChildDn, newRdn, deleteOldRdn );
+ move( oldChildDn, newParentDn );
}
@@ -1688,50 +1442,50 @@
* parent a modifyDn operation is conducted to handle name changes
* propagating down through the moved child and its descendants.
*
- * @param a_oldChildDn the normalized dn of the child to be moved
- * @param a_newParentDn the normalized dn of the new parent for the child
+ * @param oldChildDn the normalized dn of the child to be moved
+ * @param newParentDn the normalized dn of the new parent for the child
* @throws NamingException if something goes wrong
*
- * @see org.apache.ldap.server.backend.Database#move(javax.naming.Name,
+ * @see Database#move(javax.naming.Name,
* javax.naming.Name)
*/
- public void move( Name a_oldChildDn, Name a_newParentDn )
+ public void move( Name oldChildDn, Name newParentDn )
throws NamingException
{
// Get the child and the new parent to be entries and Ids
- BigInteger l_childId = getEntryId( a_oldChildDn.toString() ) ;
- BigInteger l_newParentId = getEntryId( a_newParentDn.toString() ) ;
- BigInteger l_oldParentId = getParentId( l_childId ) ;
+ BigInteger childId = getEntryId( oldChildDn.toString() );
+ BigInteger newParentId = getEntryId( newParentDn.toString() );
+ BigInteger oldParentId = getParentId( childId );
/*
- * All aliases including and below a_oldChildDn, will be affected by
+ * All aliases including and below oldChildDn, will be affected by
* the move operation with respect to one and subtree indices since
- * their relationship to ancestors above a_oldChildDn will be
- * destroyed. For each alias below and including a_oldChildDn we will
- * drop the index tuples mapping ancestor ids above a_oldChildDn to the
+ * their relationship to ancestors above oldChildDn will be
+ * destroyed. For each alias below and including oldChildDn we will
+ * drop the index tuples mapping ancestor ids above oldChildDn to the
* respective target ids of the aliases.
*/
- dropMovedAliasIndices( a_oldChildDn ) ;
+ dropMovedAliasIndices( oldChildDn );
/*
* Drop the old parent child relationship and add the new one
* Set the new parent id for the child replacing the old parent id
*/
- m_heirarchyIdx.drop( l_oldParentId, l_childId ) ;
- m_heirarchyIdx.add( l_newParentId, l_childId ) ;
+ heirarchyIdx.drop( oldParentId, childId );
+ heirarchyIdx.add( newParentId, childId );
/*
* Build the new user provided DN (updn) for the child using the child's
* user provided RDN & the new parent's UPDN. Basically add the child's
* UpRdn String to the tail of the new parent's Updn Name.
*/
- Name l_childUpdn = new LdapName( getEntryUpdn( l_childId ) ) ;
- String l_childRdn = l_childUpdn.get( l_childUpdn.size() - 1 ) ;
- Name l_newUpdn = new LdapName( getEntryUpdn( l_newParentId ) ) ;
- l_newUpdn.add( l_newUpdn.size(), l_childRdn ) ;
+ Name childUpdn = new LdapName( getEntryUpdn( childId ) );
+ String childRdn = childUpdn.get( childUpdn.size() - 1 );
+ Name newUpdn = new LdapName( getEntryUpdn( newParentId ) );
+ newUpdn.add( newUpdn.size(), childRdn );
// Call the modifyDn operation with the new updn
- modifyDn( l_childId, l_newUpdn, true ) ;
+ modifyDn( childId, newUpdn, true );
}
@@ -1740,41 +1494,41 @@
* one and subtree alias index tuples for old ancestors above the moved base
* that will no longer be ancestors after the move.
*
- * @param a_movedBase the base at which the move occured - the moved node
+ * @param movedBase the base at which the move occured - the moved node
* @throws NamingException if system indices fail
*/
- private void dropMovedAliasIndices( final Name a_movedBase )
+ private void dropMovedAliasIndices( final Name movedBase )
throws NamingException
{
- // Find all the aliases from a_movedBase down
- IndexAssertion l_isBaseDescendant = new IndexAssertion()
+ // Find all the aliases from movedBase down
+ IndexAssertion isBaseDescendant = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord a_rec )
+ public boolean assertCandidate( IndexRecord rec )
throws NamingException
{
- String l_dn = getEntryDn( a_rec.getEntryId() ) ;
- if ( l_dn.endsWith( a_movedBase.toString() ) )
+ String dn = getEntryDn( rec.getEntryId() );
+ if ( dn.endsWith( movedBase.toString() ) )
{
- return true ;
+ return true;
}
- return false ;
+ return false;
}
- } ;
+ };
- BigInteger l_movedBaseId = getEntryId( a_movedBase.toString() ) ;
- if ( m_aliasIdx.reverseLookup( l_movedBaseId ) != null )
+ BigInteger movedBaseId = getEntryId( movedBase.toString() );
+ if ( aliasIdx.reverseLookup( movedBaseId ) != null )
{
- dropAliasIndices( l_movedBaseId, a_movedBase ) ;
+ dropAliasIndices( movedBaseId, movedBase );
}
- NamingEnumeration l_aliases = new IndexAssertionEnumeration(
- m_aliasIdx.listIndices( a_movedBase.toString(), true ),
- l_isBaseDescendant ) ;
- while ( l_aliases.hasMore() )
+ NamingEnumeration aliases = new IndexAssertionEnumeration(
+ aliasIdx.listIndices( movedBase.toString(), true ),
+ isBaseDescendant );
+ while ( aliases.hasMore() )
{
- IndexRecord l_entry = ( IndexRecord ) l_aliases.next() ;
- dropAliasIndices( l_entry.getEntryId(), a_movedBase ) ;
+ IndexRecord entry = ( IndexRecord ) aliases.next();
+ dropAliasIndices( entry.getEntryId(), movedBase );
}
}
@@ -1783,49 +1537,49 @@
* For the alias id all ancestor one and subtree alias tuples are moved
* above the moved base.
*
- * @param a_aliasId the id of the alias
- * @param a_movedBase the base where the move occured
+ * @param aliasId the id of the alias
+ * @param movedBase the base where the move occured
* @throws NamingException if indices fail
*/
- private void dropAliasIndices( BigInteger a_aliasId, Name a_movedBase )
+ private void dropAliasIndices( BigInteger aliasId, Name movedBase )
throws NamingException
{
- String l_targetDn = ( String ) m_aliasIdx.reverseLookup( a_aliasId ) ;
- BigInteger l_targetId = getEntryId( l_targetDn ) ;
- String l_aliasDn = getEntryDn( a_aliasId ) ;
+ String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+ BigInteger targetId = getEntryId( targetDn );
+ String aliasDn = getEntryDn( aliasId );
/*
* Start droping index tuples with the first ancestor right above the
* moved base. This is the first ancestor effected by the move.
*/
- Name l_ancestorDn = a_movedBase.getSuffix( 1 ) ;
- BigInteger l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ Name ancestorDn = movedBase.getSuffix( 1 );
+ BigInteger ancestorId = getEntryId( ancestorDn.toString() );
/*
* We cannot just drop all tuples in the one level and subtree indices
- * linking baseIds to the l_targetId. If more than one alias refers to
+ * linking baseIds to the targetId. If more than one alias refers to
* the target then droping all tuples with a value of targetId would
* make all other aliases to the target inconsistent.
*
* We need to walk up the path of alias ancestors right above the moved
- * base until we reach the suffix, deleting each ( l_ancestorId,
- * l_targetId ) tuple in the subtree scope alias. We only need to do
+ * base until we reach the suffix, deleting each ( ancestorId,
+ * targetId ) tuple in the subtree scope alias. We only need to do
* this for the direct parent of the alias on the one level subtree if
* the moved base is the alias.
*/
- if ( l_aliasDn.equals( a_movedBase.toString() ) )
+ if ( aliasDn.equals( movedBase.toString() ) )
{
- m_oneAliasIdx.drop( l_ancestorId, l_targetId ) ;
+ oneAliasIdx.drop( ancestorId, targetId );
}
- m_subAliasIdx.drop( l_ancestorId, l_targetId ) ;
+ subAliasIdx.drop( ancestorId, targetId );
- while ( ! l_ancestorDn.equals( m_suffix ) )
+ while ( ! ancestorDn.equals( suffix ) )
{
- l_ancestorDn = l_ancestorDn.getSuffix( 1 ) ;
- l_ancestorId = getEntryId( l_ancestorDn.toString() ) ;
+ ancestorDn = ancestorDn.getSuffix( 1 );
+ ancestorId = getEntryId( ancestorDn.toString() );
- m_subAliasIdx.drop( l_ancestorId, l_targetId ) ;
+ subAliasIdx.drop( ancestorId, targetId );
}
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultIndex.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/index/DefaultIndex.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/index/DefaultIndex.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultIndex.java Wed Sep 29 19:00:03 2004
@@ -1,207 +1,207 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright [yyyy] [name of copyright owner]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
/*
* $Id: DefaultIndex.java,v 1.5 2003/10/08 16:46:11 akarasulu Exp $
@@ -211,60 +211,57 @@
* -- any LDAPd project for copyright and distribution information. --
*
*/
-package org.apache.ldap.server.backend.db.index ;
+package org.apache.eve.db.jdbm;
-import java.io.File ;
-import java.io.IOException ;
+import java.io.File;
+import java.io.IOException;
-import java.math.BigInteger ;
+import java.math.BigInteger;
import java.util.Comparator;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.Attributes ;
-
-import org.apache.ldap.server.backend.db.table.DefaultTable ;
-import org.apache.ldap.server.schema.attribute.AttributeType ;
-
-import jdbm.helper.MRU ;
-import jdbm.RecordManager ;
-import jdbm.recman.BaseRecordManager ;
-import jdbm.recman.CacheRecordManager ;
-
-import org.apache.regexp.RE ;
-import org.apache.commons.collections.LRUMap ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.regexp.RE;
+import org.apache.eve.db.Index;
+import org.apache.eve.db.IndexComparator;
+import org.apache.eve.db.IndexEnumeration;
+import org.apache.ldap.common.util.LRUMap;
+import org.apache.ldap.common.schema.AttributeType;
+
+import jdbm.helper.MRU;
+import jdbm.RecordManager;
+import jdbm.recman.BaseRecordManager;
+import jdbm.recman.CacheRecordManager;
/**
- * TODO Do me
+ * @todo rename to JdbmIndex
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.5 $
*/
-public class DefaultIndex
- implements Index
+public class DefaultIndex implements Index
{
- /** TODO */
- public static final String FORWARD_BTREE = "_forward" ;
- /** TODO */
- public static final String REVERSE_BTREE = "_reverse" ;
-
- /** TODO */
- private AttributeType m_attribute ;
- /** TODO */
- private DefaultTable m_forward = null ;
- /** TODO */
- private DefaultTable m_reverse = null ;
- /** TODO */
- private RecordManager m_recMan = null ;
+ /** */
+ public static final String FORWARD_BTREE = "_forward";
+ /** */
+ public static final String REVERSE_BTREE = "_reverse";
+
+ /** */
+ private AttributeType attribute;
+ /** */
+ private DefaultTable forward = null;
+ /** */
+ private DefaultTable reverse = null;
+ /** */
+ private RecordManager recMan = null;
/**
* @todo I don't think the keyCache is required anymore since the normalizer
* will cache values for us.
*/
- private LRUMap m_keyCache = null ;
+ private LRUMap keyCache = null;
// ------------------------------------------------------------------------
@@ -277,51 +274,51 @@
* index table B+Tree are created and saved within this file rather than
* creating a new file.
*
- * @param a_attribute the attribute specification to base this index on
- * @param a_recMan the record manager
- * @throws NamingException if we fail to create B+Trees using a_recMan
+ * @param attribute the attribute specification to base this index on
+ * @param recMan the record manager
+ * @throws NamingException if we fail to create B+Trees using recMan
*/
- public DefaultIndex( AttributeType a_attribute, RecordManager a_recMan )
+ public DefaultIndex( AttributeType attribute, RecordManager recMan )
throws NamingException
{
- m_attribute = a_attribute ;
- m_keyCache = new LRUMap( 1000 ) ;
- m_recMan = a_recMan ;
- initTables() ;
+ this.attribute = attribute;
+ keyCache = new LRUMap( 1000 );
+ this.recMan = recMan;
+ initTables();
}
/**
* TODO Document me!
*
- * @param a_attribute TODO
- * @param a_wkDirPath TODO
+ * @param attribute TODO
+ * @param wkDirPath TODO
* @throws NamingException TODO
*/
- public DefaultIndex( AttributeType a_attribute, String a_wkDirPath )
+ public DefaultIndex( AttributeType attribute, String wkDirPath )
throws NamingException
{
- File l_file = new File( a_wkDirPath + File.separator
- + a_attribute.getName() ) ;
- m_attribute = a_attribute ;
- m_keyCache = new LRUMap( 1000 ) ;
+ File file = new File( wkDirPath + File.separator
+ + attribute.getName() );
+ this.attribute = attribute;
+ keyCache = new LRUMap( 1000 );
try
{
- String l_path = l_file.getAbsolutePath() ;
- BaseRecordManager l_base = new BaseRecordManager( l_path ) ;
- l_base.disableTransactions() ;
- m_recMan = new CacheRecordManager( l_base , new MRU( 1000 ) ) ;
+ String path = file.getAbsolutePath();
+ BaseRecordManager base = new BaseRecordManager( path );
+ base.disableTransactions();
+ recMan = new CacheRecordManager( base , new MRU( 1000 ) );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException(
- "Could not initialize the record manager" ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException(
+ "Could not initialize the record manager" );
+ ne.setRootCause( e );
+ throw ne;
}
- initTables() ;
+ initTables();
}
@@ -331,18 +328,17 @@
* @throws NamingException if we cannot initialize the forward and reverse
* tables
*/
- private void initTables()
- throws NamingException
+ private void initTables() throws NamingException
{
- Comparator l_comp = m_attribute.getComparator() ;
+ Comparator comp = attribute.getComparator();
/*
* The forward key/value map stores attribute values to master table
* primary keys. A value for an attribute can occur several times in
* different entries so the forward map can have more than one value.
*/
- m_forward = new DefaultTable( m_attribute.getName() + FORWARD_BTREE,
- true, m_recMan, new IndexComparator( l_comp, true ) ) ;
+ forward = new DefaultTable( attribute.getName() + FORWARD_BTREE,
+ true, recMan, new IndexComparator( comp, true ) );
/*
* Now the reverse map stores the primary key into the master table as
@@ -350,18 +346,18 @@
* is single valued according to its specification based on a schema
* then duplicate keys should not be allowed within the reverse table.
*/
- m_reverse = new DefaultTable( m_attribute.getName() + REVERSE_BTREE,
- ! m_attribute.isSingleValue(), m_recMan,
- new IndexComparator( l_comp, false ) ) ;
+ reverse = new DefaultTable( attribute.getName() + REVERSE_BTREE,
+ ! attribute.isSingleValue(), recMan,
+ new IndexComparator( comp, false ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#getAttribute()
+ * @see Index#getAttribute()
*/
public AttributeType getAttribute()
{
- return m_attribute ;
+ return attribute;
}
@@ -371,32 +367,32 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#count()
+ * @see Index#count()
*/
public int count()
throws NamingException
{
- return m_forward.count() ;
+ return forward.count();
}
/**
- * @see org.apache.ldap.server.backend.index.Index#count(java.lang.Object)
+ * @see Index#count(java.lang.Object)
*/
- public int count( Object an_attrVal )
+ public int count( Object attrVal )
throws NamingException
{
- return m_forward.count( getNormalized( an_attrVal ) ) ;
+ return forward.count( getNormalized( attrVal ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#count(java.lang.Object, boolean)
+ * @see Index#count(java.lang.Object, boolean)
*/
- public int count( Object an_attrVal, boolean a_isGreaterThan )
+ public int count( Object attrVal, boolean isGreaterThan )
throws NamingException
{
- return m_forward.count( getNormalized( an_attrVal ), a_isGreaterThan ) ;
+ return forward.count( getNormalized( attrVal ), isGreaterThan );
}
@@ -406,22 +402,22 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#forwardLookup(java.lang.Object)
+ * @see Index#forwardLookup(java.lang.Object)
*/
- public BigInteger forwardLookup( Object an_attrVal )
+ public BigInteger forwardLookup( Object attrVal )
throws NamingException
{
- return ( BigInteger ) m_forward.get( getNormalized( an_attrVal ) ) ;
+ return ( BigInteger ) forward.get( getNormalized( attrVal ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#reverseLookup(java.math.BigInteger)
+ * @see Index#reverseLookup(java.math.BigInteger)
*/
- public Object reverseLookup( BigInteger a_id )
+ public Object reverseLookup( BigInteger id )
throws NamingException
{
- return m_reverse.get( a_id ) ;
+ return reverse.get( id );
}
@@ -431,113 +427,113 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#add(java.lang.Object,
+ * @see Index#add(java.lang.Object,
* java.math.BigInteger)
*/
- public synchronized void add( Object an_attrVal, BigInteger a_id )
+ public synchronized void add( Object attrVal, BigInteger id )
throws NamingException
{
- m_forward.put( getNormalized( an_attrVal ), a_id ) ;
- m_reverse.put( a_id, getNormalized( an_attrVal ) ) ;
+ forward.put( getNormalized( attrVal ), id );
+ reverse.put( id, getNormalized( attrVal ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#add(
+ * @see Index#add(
* javax.naming.directory.Attribute, java.math.BigInteger)
*/
- public synchronized void add( Attribute a_attr, BigInteger a_id )
+ public synchronized void add( Attribute attr, BigInteger id )
throws NamingException
{
// Can efficiently batch add to the reverse table
- NamingEnumeration l_values = a_attr.getAll() ;
- m_reverse.put( a_id, l_values ) ;
+ NamingEnumeration values = attr.getAll();
+ reverse.put( id, values );
// Have no choice but to add each value individually to forward table
- l_values = a_attr.getAll() ;
- while ( l_values.hasMore() )
+ values = attr.getAll();
+ while ( values.hasMore() )
{
- m_forward.put( l_values.next(), a_id ) ;
+ forward.put( values.next(), id );
}
}
/**
- * @see org.apache.ldap.server.backend.index.Index#add(
+ * @see Index#add(
* javax.naming.directory.Attributes, java.math.BigInteger)
*/
- public synchronized void add( Attributes a_attrs, BigInteger a_id )
+ public synchronized void add( Attributes attrs, BigInteger id )
throws NamingException
{
- add( a_attrs.get( m_attribute.getName() ), a_id ) ;
+ add( attrs.get( attribute.getName() ), id );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#drop(java.lang.Object,
+ * @see Index#drop(java.lang.Object,
* java.math.BigInteger)
*/
- public synchronized void drop( Object an_attrVal, BigInteger a_id )
+ public synchronized void drop( Object attrVal, BigInteger id )
throws NamingException
{
- m_forward.remove( getNormalized( an_attrVal ), a_id ) ;
- m_reverse.remove( a_id, getNormalized( an_attrVal ) ) ;
+ forward.remove( getNormalized( attrVal ), id );
+ reverse.remove( id, getNormalized( attrVal ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#drop(java.math.BigInteger)
+ * @see Index#drop(java.math.BigInteger)
*/
- public void drop( BigInteger a_entryId )
+ public void drop( BigInteger entryId )
throws NamingException
{
- NamingEnumeration l_values = m_reverse.listValues( a_entryId ) ;
+ NamingEnumeration values = reverse.listValues( entryId );
- while ( l_values.hasMore() )
+ while ( values.hasMore() )
{
- m_forward.remove( l_values.next(), a_entryId ) ;
+ forward.remove( values.next(), entryId );
}
- m_reverse.remove( a_entryId ) ;
+ reverse.remove( entryId );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#drop(
+ * @see Index#drop(
* javax.naming.directory.Attribute, java.math.BigInteger)
*/
- public void drop( Attribute a_attr, BigInteger a_id )
+ public void drop( Attribute attr, BigInteger id )
throws NamingException
{
// Can efficiently batch remove from the reverse table
- NamingEnumeration l_values = a_attr.getAll() ;
+ NamingEnumeration values = attr.getAll();
- // If their are no values in a_attr this is a request to drop all
- if ( ! l_values.hasMore() )
+ // If their are no values in attr this is a request to drop all
+ if ( ! values.hasMore() )
{
- drop( a_id ) ;
- return ;
+ drop( id );
+ return;
}
- m_reverse.remove( a_id, l_values ) ;
+ reverse.remove( id, values );
// Have no choice but to remove values individually from forward table
- l_values = a_attr.getAll() ;
- while ( l_values.hasMore() )
+ values = attr.getAll();
+ while ( values.hasMore() )
{
- m_forward.remove( l_values.next(), a_id ) ;
+ forward.remove( values.next(), id );
}
}
/**
- * @see org.apache.ldap.server.backend.index.Index#drop(
+ * @see Index#drop(
* javax.naming.directory.Attributes, java.math.BigInteger)
*/
- public void drop( Attributes a_attrs, BigInteger a_id )
+ public void drop( Attributes attrs, BigInteger id )
throws NamingException
{
- drop( a_attrs.get( m_attribute.getName() ), a_id ) ;
+ drop( attrs.get( attribute.getName() ), id );
}
@@ -547,68 +543,67 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#getReverseCursor(
- * java.math.BigInteger)
+ * @see Index#listReverseIndices(BigInteger)
*/
- public IndexEnumeration listReverseIndices( BigInteger a_id )
+ public IndexEnumeration listReverseIndices( BigInteger id )
throws NamingException
{
- return new IndexEnumeration( m_reverse.listTuples( a_id ), true ) ;
+ return new IndexEnumeration( reverse.listTuples( id ), true );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#listIndices()
+ * @see Index#listIndices()
*/
public IndexEnumeration listIndices()
throws NamingException
{
- return new IndexEnumeration( m_forward.listTuples() ) ;
+ return new IndexEnumeration( forward.listTuples() );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#listIndices(java.lang.Object)
+ * @see Index#listIndices(java.lang.Object)
*/
- public IndexEnumeration listIndices( Object an_attrVal )
+ public IndexEnumeration listIndices( Object attrVal )
throws NamingException
{
- return new IndexEnumeration( m_forward.listTuples(
- getNormalized( an_attrVal ) ) ) ;
+ return new IndexEnumeration( forward.listTuples(
+ getNormalized( attrVal ) ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#listIndices(java.lang.Object,
+ * @see Index#listIndices(java.lang.Object,
* boolean)
*/
- public IndexEnumeration listIndices( Object an_attrVal,
- boolean a_isGreaterThan ) throws NamingException
+ public IndexEnumeration listIndices( Object attrVal,
+ boolean isGreaterThan ) throws NamingException
{
- return new IndexEnumeration( m_forward.listTuples(
- getNormalized( an_attrVal ), a_isGreaterThan ) ) ;
+ return new IndexEnumeration( forward.listTuples(
+ getNormalized( attrVal ), isGreaterThan ) );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#listIndices(org.apache.regexp.RE)
+ * @see Index#listIndices(org.apache.regexp.RE)
*/
- public IndexEnumeration listIndices( RE a_regex )
+ public IndexEnumeration listIndices( RE regex )
throws NamingException
{
- return new IndexEnumeration( m_forward.listTuples(), false, a_regex ) ;
+ return new IndexEnumeration( forward.listTuples(), false, regex );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#listIndices(org.apache.regexp.RE,
+ * @see Index#listIndices(org.apache.regexp.RE,
* java.lang.String)
*/
- public IndexEnumeration listIndices( RE a_regex, String a_prefix )
+ public IndexEnumeration listIndices( RE regex, String prefix )
throws NamingException
{
- return new IndexEnumeration( m_forward.listTuples(
- getNormalized( a_prefix ), true ), false, a_regex ) ;
+ return new IndexEnumeration( forward.listTuples(
+ getNormalized( prefix ), true ), false, regex );
}
@@ -618,41 +613,41 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#hasValue(java.lang.Object,
+ * @see Index#hasValue(java.lang.Object,
* java.math.BigInteger)
*/
- public boolean hasValue( Object an_attrVal, BigInteger a_id )
+ public boolean hasValue( Object attrVal, BigInteger id )
throws NamingException
{
- return m_forward.has( getNormalized( an_attrVal ), a_id ) ;
+ return forward.has( getNormalized( attrVal ), id );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#hasValue(java.lang.Object,
+ * @see Index#hasValue(java.lang.Object,
* java.math.BigInteger, boolean)
*/
- public boolean hasValue( Object an_attrVal, BigInteger a_id,
- boolean a_isGreaterThan )
+ public boolean hasValue( Object attrVal, BigInteger id,
+ boolean isGreaterThan )
throws NamingException
{
- return m_forward.has( getNormalized( an_attrVal ),
- a_id, a_isGreaterThan ) ;
+ return forward.has( getNormalized( attrVal ),
+ id, isGreaterThan );
}
/**
- * @see org.apache.ldap.server.backend.index.Index#hasValue(org.apache.regexp.RE,
+ * @see Index#hasValue(org.apache.regexp.RE,
* java.math.BigInteger)
*/
- public boolean hasValue( RE a_regex, BigInteger a_id )
+ public boolean hasValue( RE regex, BigInteger id )
throws NamingException
{
- IndexEnumeration l_list = new IndexEnumeration(
- m_reverse.listTuples( a_id ), true, a_regex ) ;
- boolean l_hasValue = l_list.hasMore() ;
- l_list.close() ;
- return l_hasValue ;
+ IndexEnumeration list = new IndexEnumeration(
+ reverse.listTuples( id ), true, regex );
+ boolean hasValue = list.hasMore();
+ list.close();
+ return hasValue;
}
@@ -662,46 +657,46 @@
/**
- * @see org.apache.ldap.server.backend.index.Index#close()
+ * @see Index#close()
*/
public synchronized void close()
throws NamingException
{
try
{
- m_forward.close() ;
- m_reverse.close() ;
- m_recMan.commit() ;
- m_recMan.close() ;
+ forward.close();
+ reverse.close();
+ recMan.commit();
+ recMan.close();
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException(
+ NamingException ne = new NamingException(
"Exception while closing backend index file for attribute "
- + m_attribute.getName() ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ + attribute.getName() );
+ ne.setRootCause( e );
+ throw ne;
}
}
/**
- * @see org.apache.ldap.server.backend.index.Index#sync()
+ * @see Index#sync()
*/
public synchronized void sync()
throws NamingException
{
try
{
- m_recMan.commit() ;
+ recMan.commit();
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException(
+ NamingException ne = new NamingException(
"Exception while syncing backend index file for attribute "
- + m_attribute.getName() ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ + attribute.getName() );
+ ne.setRootCause( e );
+ throw ne;
}
}
@@ -712,26 +707,26 @@
* @todo I don't think the keyCache is required anymore since the normalizer
* will cache values for us.
*
- * @param an_attrVal TODO
+ * @param attrVal TODO
* @return TODO
* @throws NamingException TODO
*/
- public Object getNormalized( Object an_attrVal )
+ public Object getNormalized( Object attrVal )
throws NamingException
{
- Object l_normalized = m_keyCache.get( an_attrVal ) ;
+ Object normalized = keyCache.get( attrVal );
- if ( null == l_normalized )
+ if ( null == normalized )
{
- l_normalized = m_attribute.getNormalizer().normalize( an_attrVal ) ;
+ normalized = attribute.getNormalizer().normalize( attrVal );
// Double map it so if we use an already normalized
// value we can get back the same normalized value.
// and not have to regenerate a second time.
- m_keyCache.put( an_attrVal, l_normalized ) ;
- m_keyCache.put( l_normalized, l_normalized ) ;
+ keyCache.put( attrVal, normalized );
+ keyCache.put( normalized, normalized );
}
- return l_normalized ;
+ return normalized;
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultMasterTable.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultMasterTable.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultMasterTable.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultMasterTable.java Wed Sep 29 19:00:03 2004
@@ -1,260 +1,44 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+package org.apache.eve.db.jdbm;
-/*
- * $Id: DefaultMasterTable.java,v 1.3 2003/09/16 05:29:25 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-package org.apache.ldap.server.backend.db.table ;
+import java.math.BigInteger;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
-import java.math.BigInteger ;
-import javax.naming.NamingException ;
-import javax.naming.directory.Attributes ;
+import jdbm.RecordManager;
+import jdbm.helper.StringComparator;
-import jdbm.RecordManager ;
-import jdbm.helper.StringComparator ;
-import org.apache.ldap.common.util.BigIntegerComparator ;
+import org.apache.ldap.common.util.BigIntegerComparator;
+import org.apache.eve.db.MasterTable;
/**
* The master table used to store the Attributes of entries.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.3 $
- * @testcase org.apache.ldap.server.backend.berkeley.table.TestMasterTable
+ * @todo rename to JdbmMasterTable
*/
-public class DefaultMasterTable
- extends DefaultTable implements MasterTable
+public class DefaultMasterTable extends DefaultTable implements MasterTable
{
- /** TODO */
- private DefaultTable m_adminTbl = null ;
+ /** */
+ private DefaultTable adminTbl = null;
/**
* Creates the master entry table using a Berkeley Db for the backing store.
*
- * @param a_recMan TODO
+ * @param recMan the jdbm record manager
* @throws NamingException if there is an error opening the Db file.
*/
- public DefaultMasterTable( RecordManager a_recMan )
+ public DefaultMasterTable( RecordManager recMan )
throws NamingException
{
- super( DBF, a_recMan, new BigIntegerComparator() ) ;
- m_adminTbl = new DefaultTable( "admin", a_recMan,
- new StringComparator() ) ;
- String l_seqValue = ( String ) m_adminTbl.get( SEQPROP_KEY ) ;
+ super( DBF, recMan, new BigIntegerComparator() );
+ adminTbl = new DefaultTable( "admin", recMan, new StringComparator() );
+ String seqValue = ( String ) adminTbl.get( SEQPROP_KEY );
- if ( null == l_seqValue )
+ if ( null == seqValue )
{
- m_adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ) ;
+ adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() );
}
}
@@ -262,45 +46,42 @@
/**
* Gets the Attributes of an entry from this MasterTable.
*
- * @param an_id the BigInteger id of the entry to retrieve.
+ * @param id the BigInteger id of the entry to retrieve.
* @return the Attributes of the entry with operational attributes and all.
* @throws NamingException if there is a read error on the underlying Db.
*/
- public Attributes get( BigInteger an_id )
- throws NamingException
+ public Attributes get( BigInteger id ) throws NamingException
{
- return ( Attributes ) super.get( an_id ) ;
+ return ( Attributes ) super.get( id );
}
/**
* Puts the Attributes of an entry into this master table at an index
- * specified by an_id. Used both to create new entries and update existing
+ * specified by id. Used both to create new entries and update existing
* ones.
*
- * @param a_entry the Attributes of entry w/ operational attributes
- * @param an_id the BigInteger id of the entry to put
- * @return TODO
+ * @param entry the Attributes of entry w/ operational attributes
+ * @param id the BigInteger id of the entry to put
+ * @return the Attributes of the entry put
* @throws NamingException if there is a write error on the underlying Db.
*/
- public Attributes put( Attributes a_entry, BigInteger an_id )
- throws NamingException
+ public Attributes put( Attributes entry, BigInteger id ) throws NamingException
{
- return ( Attributes ) super.put( an_id, a_entry ) ;
+ return ( Attributes ) super.put( id, entry );
}
/**
- * Deletes a entry from the master table at an index specified by an_id.
+ * Deletes a entry from the master table at an index specified by id.
*
- * @param an_id the BigInteger id of the entry to delete
+ * @param id the BigInteger id of the entry to delete
* @return the Attributes of the deleted entry
* @throws NamingException if there is a write error on the underlying Db
*/
- public Attributes delete( BigInteger an_id )
- throws NamingException
+ public Attributes delete( BigInteger id ) throws NamingException
{
- return ( Attributes ) super.remove( an_id ) ;
+ return ( Attributes ) super.remove( id );
}
@@ -312,23 +93,22 @@
* @throws NamingException if the admin table storing sequences cannot be
* read.
*/
- public BigInteger getCurrentId()
- throws NamingException
+ public BigInteger getCurrentId() throws NamingException
{
- BigInteger l_id = null ;
+ BigInteger id = null;
- synchronized ( m_adminTbl )
+ synchronized ( adminTbl )
{
- l_id = new BigInteger( ( String ) m_adminTbl.get( SEQPROP_KEY ) ) ;
+ id = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) );
- if ( null == l_id )
+ if ( null == id )
{
- m_adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ) ;
- l_id = BigInteger.ZERO ;
+ adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() );
+ id = BigInteger.ZERO;
}
}
- return l_id ;
+ return id;
}
@@ -342,46 +122,44 @@
* @throws NamingException if the admin table storing sequences cannot be
* read and writen to.
*/
- public BigInteger getNextId()
- throws NamingException
+ public BigInteger getNextId() throws NamingException
{
- BigInteger l_lastVal = null ;
- BigInteger l_nextVal = null ;
+ BigInteger lastVal = null;
+ BigInteger nextVal = null;
- synchronized ( m_adminTbl )
+ synchronized ( adminTbl )
{
- l_lastVal = new BigInteger( ( String )
- m_adminTbl.get( SEQPROP_KEY ) ) ;
+ lastVal = new BigInteger( ( String )
+ adminTbl.get( SEQPROP_KEY ) );
- if ( null == l_lastVal )
+ if ( null == lastVal )
{
- m_adminTbl.put( SEQPROP_KEY, BigInteger.ONE.toString() ) ;
- return BigInteger.ONE ;
+ adminTbl.put( SEQPROP_KEY, BigInteger.ONE.toString() );
+ return BigInteger.ONE;
}
else
{
- l_nextVal = l_lastVal.add( BigInteger.ONE ) ;
- m_adminTbl.put( SEQPROP_KEY, l_nextVal.toString() ) ;
+ nextVal = lastVal.add( BigInteger.ONE );
+ adminTbl.put( SEQPROP_KEY, nextVal.toString() );
}
}
- return l_nextVal ;
+ return nextVal;
}
/**
* Gets a persistant property stored in the admin table of this MasterTable.
*
- * @param a_property the key of the property to get the value of
+ * @param property the key of the property to get the value of
* @return the value of the property
* @throws NamingException when the underlying admin table cannot be read
*/
- public String getProperty( String a_property )
- throws NamingException
+ public String getProperty( String property ) throws NamingException
{
- synchronized ( m_adminTbl )
+ synchronized ( adminTbl )
{
- return ( String ) m_adminTbl.get( a_property ) ;
+ return ( String ) adminTbl.get( property );
}
}
@@ -389,16 +167,15 @@
/**
* Sets a persistant property stored in the admin table of this MasterTable.
*
- * @param a_property the key of the property to set the value of
- * @param a_value the value of the property
+ * @param property the key of the property to set the value of
+ * @param value the value of the property
* @throws NamingException when the underlying admin table cannot be writen
*/
- public void setProperty( String a_property, String a_value )
- throws NamingException
+ public void setProperty( String property, String value ) throws NamingException
{
- synchronized ( m_adminTbl )
+ synchronized ( adminTbl )
{
- m_adminTbl.put( a_property, a_value ) ;
+ adminTbl.put( property, value );
}
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultOptimizer.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultOptimizer.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultOptimizer.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultOptimizer.java Wed Sep 29 19:00:03 2004
@@ -1,260 +1,44 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: DefaultOptimizer.java,v 1.8 2003/10/17 00:10:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
-import java.util.ArrayList ;
-import java.math.BigInteger ;
+import java.util.ArrayList;
+import java.math.BigInteger;
-import javax.naming.NamingException ;
-import javax.naming.directory.SearchControls ;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.backend.db.DatabaseEnabled ;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.LeafNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.common.filter.SimpleNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.common.filter.AssertionNode ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.LeafNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.filter.AssertionNode;
+
+import org.apache.eve.db.Index;
+import org.apache.eve.db.Database;
+import org.apache.eve.db.Optimizer;
/**
* Optimizer that annotates the filter using scan counts.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.8 $
*/
-public class DefaultOptimizer
- implements Optimizer, DatabaseEnabled
+public class DefaultOptimizer implements Optimizer
{
- /** TODO */
- private Database m_db ;
+ private static final BigInteger MAX = BigInteger.valueOf( Integer.MAX_VALUE );
+ /** the database this optimizer operates on */
+ private Database db;
/**
- * Sets up an optimizer on a database.
+ * Creates an optimizer on a database.
*
- * @param a_db the database this optimizer works for.
+ * @param db the database this optimizer works for.
*/
- public void enableDatabase( Database a_db )
+ public DefaultOptimizer( Database db )
{
- m_db = a_db ;
+ this.db = db;
}
@@ -264,14 +48,13 @@
* index on the attribute does not exist an IndexNotFoundException will be
* thrown.
*
- * @see org.apache.ldap.server.backend.search.Optimizer#annotate(null,
- * org.apache.ldap.common.filter.ExprNode)
+ * @see Optimizer#annotate(ExprNode)
*/
- public void annotate( ExprNode a_node )
+ public void annotate( ExprNode node )
throws NamingException
{
// Start off with the worst case unless scan count says otherwise.
- BigInteger l_count = MAX ;
+ BigInteger count = MAX;
/* --------------------------------------------------------------------
* H A N D L E L E A F N O D E S
@@ -286,51 +69,51 @@
* Comments on each node type explain how each scan count is arrived at.
*/
- if ( a_node instanceof ScopeNode )
+ if ( node instanceof ScopeNode )
{
- l_count = getScopeScan( ( ScopeNode ) a_node ) ;
+ count = getScopeScan( ( ScopeNode ) node );
}
- else if ( a_node instanceof AssertionNode )
+ else if ( node instanceof AssertionNode )
{
/*
* Leave it up to the assertion node to determine just how much it
* will cost us. Anyway it defaults to a maximum scan count if a
* scan count is not specified by the implementation.
*/
- ;
+ ;
}
- else if ( a_node.isLeaf() )
+ else if ( node.isLeaf() )
{
- LeafNode l_leaf = ( LeafNode ) a_node ;
+ LeafNode leaf = ( LeafNode ) node;
- switch ( l_leaf.getAssertionType() )
+ switch ( leaf.getAssertionType() )
{
case( LeafNode.APPROXIMATE ):
/** TODO Not implemented so we just use equality matching */
- l_count = getEqualityScan( ( SimpleNode ) l_leaf ) ;
- break ;
+ count = getEqualityScan( ( SimpleNode ) leaf );
+ break;
case( LeafNode.EQUALITY ):
- l_count = getEqualityScan( ( SimpleNode ) l_leaf ) ;
- break ;
+ count = getEqualityScan( ( SimpleNode ) leaf );
+ break;
case( LeafNode.EXTENSIBLE ):
/** Cannot really say so we presume the total index count */
- l_count = getFullScan( l_leaf ) ;
- break ;
+ count = getFullScan( leaf );
+ break;
case( LeafNode.GREATEREQ ):
- l_count = getGreaterLessScan( ( SimpleNode ) l_leaf, true ) ;
- break ;
+ count = getGreaterLessScan( ( SimpleNode ) leaf, true );
+ break;
case( LeafNode.LESSEQ ):
- l_count = getGreaterLessScan( ( SimpleNode ) l_leaf, false ) ;
- break ;
+ count = getGreaterLessScan( ( SimpleNode ) leaf, false );
+ break;
case( LeafNode.PRESENCE ):
- l_count = getPresenceScan( ( PresenceNode ) l_leaf ) ;
- break ;
+ count = getPresenceScan( ( PresenceNode ) leaf );
+ break;
case( LeafNode.SUBSTRING ):
/** Cannot really say so we presume the total index count */
- l_count = getFullScan( l_leaf ) ;
- break ;
+ count = getFullScan( leaf );
+ break;
default:
- throw new IllegalArgumentException( "Unrecognized leaf node" ) ;
+ throw new IllegalArgumentException( "Unrecognized leaf node" );
}
}
// --------------------------------------------------------------------
@@ -338,32 +121,32 @@
// --------------------------------------------------------------------
else
{
- BranchNode l_node = ( BranchNode ) a_node ;
+ BranchNode bnode = ( BranchNode ) node;
- switch( l_node.getOperator() )
+ switch( bnode.getOperator() )
{
case( BranchNode.AND ):
- l_count = getConjunctionScan( l_node ) ;
- break ;
+ count = getConjunctionScan( bnode );
+ break;
case( BranchNode.NOT ):
- l_count = getNegationScan( l_node ) ;
- break ;
+ count = getNegationScan( bnode );
+ break;
case( BranchNode.OR ):
- l_count = getDisjunctionScan( l_node ) ;
- break ;
+ count = getDisjunctionScan( bnode );
+ break;
default:
throw new IllegalArgumentException(
- "Unrecognized branch node type" ) ;
+ "Unrecognized branch node type" );
}
}
// Protect against overflow when counting.
- if ( l_count.compareTo( BigInteger.ZERO ) < 0 )
+ if ( count.compareTo( BigInteger.ZERO ) < 0 )
{
- l_count = MAX ;
+ count = MAX;
}
- a_node.set( "count", l_count ) ;
+ node.set( "count", count );
}
@@ -374,24 +157,24 @@
* call before accessing its count parameter making the chain recursion
* depth first.
*
- * @param a_node a AND (Conjunction) BranchNode
+ * @param node a AND (Conjunction) BranchNode
* @return the calculated scan count
* @throws NamingException if there is an error
*/
- private BigInteger getConjunctionScan( BranchNode a_node )
+ private BigInteger getConjunctionScan( BranchNode node )
throws NamingException
{
- BigInteger l_count = BigInteger.valueOf( Integer.MAX_VALUE ) ;
- ArrayList l_children = a_node.getChildren() ;
+ BigInteger count = BigInteger.valueOf( Integer.MAX_VALUE );
+ ArrayList children = node.getChildren();
- for ( int ii = 0; ii < l_children.size(); ii++ )
+ for ( int ii = 0; ii < children.size(); ii++ )
{
- ExprNode l_child = ( ExprNode ) l_children.get( ii ) ;
- annotate( l_child ) ;
- l_count = ( ( BigInteger ) l_child.get( "count" ) ).min( l_count ) ;
+ ExprNode child = ( ExprNode ) children.get( ii );
+ annotate( child );
+ count = ( ( BigInteger ) child.get( "count" ) ).min( count );
}
- return l_count ;
+ return count;
}
@@ -405,28 +188,28 @@
* cost too much to get an exact estimate on the count of a negation on a
* branch node.
*
- * @param a_node the negation node
+ * @param node the negation node
* @return the scan count
* @throws NamingException if there is an error
*/
- private BigInteger getNegationScan( BranchNode a_node )
+ private BigInteger getNegationScan( BranchNode node )
throws NamingException
{
- ExprNode l_onlyChild = ( ExprNode ) a_node.getChildren().get( 0 ) ;
+ ExprNode onlyChild = ( ExprNode ) node.getChildren().get( 0 );
- annotate( l_onlyChild ) ;
+ annotate( onlyChild );
- if ( l_onlyChild.isLeaf()
- && ! ( l_onlyChild instanceof ScopeNode )
- && ! ( l_onlyChild instanceof AssertionNode )
- && ! ( l_onlyChild instanceof PresenceNode ) )
- {
- LeafNode l_leaf = ( LeafNode ) l_onlyChild ;
- Index l_idx = m_db.getUserIndex( l_leaf.getAttribute() ) ;
- return BigInteger.valueOf( l_idx.count() ) ;
+ if ( onlyChild.isLeaf()
+ && ! ( onlyChild instanceof ScopeNode )
+ && ! ( onlyChild instanceof AssertionNode )
+ && ! ( onlyChild instanceof PresenceNode ) )
+ {
+ LeafNode leaf = ( LeafNode ) onlyChild;
+ Index idx = db.getUserIndex( leaf.getAttribute() );
+ return BigInteger.valueOf( idx.count() );
}
- return BigInteger.valueOf( m_db.count() ) ;
+ return BigInteger.valueOf( db.count() );
}
@@ -435,24 +218,24 @@
* so we add all the counts of the child nodes. Notice that we annotate the
* child node with a recursive call.
*
- * @param a_node the OR branch node
+ * @param node the OR branch node
* @return the scan count on the OR node
* @throws NamingException if there is an error
*/
- private BigInteger getDisjunctionScan( BranchNode a_node )
+ private BigInteger getDisjunctionScan( BranchNode node )
throws NamingException
{
- ArrayList l_children = a_node.getChildren() ;
- BigInteger l_total = BigInteger.ZERO ;
+ ArrayList children = node.getChildren();
+ BigInteger total = BigInteger.ZERO;
- for ( int ii = 0; ii < l_children.size(); ii++ )
+ for ( int ii = 0; ii < children.size(); ii++ )
{
- ExprNode l_child = ( ExprNode ) l_children.get( ii ) ;
- annotate( l_child ) ;
- l_total = l_total.add( ( BigInteger ) l_child.get( "count" ) ) ;
+ ExprNode child = ( ExprNode ) children.get( ii );
+ annotate( child );
+ total = total.add( ( BigInteger ) child.get( "count" ) );
}
- return l_total ;
+ return total;
}
@@ -460,45 +243,45 @@
* Gets the worst case scan count for all entries that satisfy the equality
* assertion in the SimpleNode argument.
*
- * @param a_node the node to get a scan count for
+ * @param node the node to get a scan count for
* @return the worst case
* @throws NamingException if there is an error accessing an index
*/
- private BigInteger getEqualityScan( SimpleNode a_node )
+ private BigInteger getEqualityScan( SimpleNode node )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
- return BigInteger.valueOf( l_idx.count( a_node.getValue() ) ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
+ return BigInteger.valueOf( idx.count( node.getValue() ) );
}
// count for non-indexed attribute is unknown so we presume da worst
- return MAX ;
+ return MAX;
}
/**
* Gets a scan count of the nodes that satisfy the greater or less than test
- * specified by the a_node.
+ * specified by the node.
*
- * @param a_node the greater or less than node to get a count for
- * @param a_isGreaterThan if true test is for >=, otherwise <=
+ * @param node the greater or less than node to get a count for
+ * @param isGreaterThan if true test is for >=, otherwise <=
* @return the scan count of all nodes satisfying the AVA
* @throws NamingException if there is an error accessing an index
*/
- private BigInteger getGreaterLessScan( SimpleNode a_node,
- boolean a_isGreaterThan ) throws NamingException
+ private BigInteger getGreaterLessScan( SimpleNode node,
+ boolean isGreaterThan ) throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
- int l_count = l_idx.count( a_node.getValue(), a_isGreaterThan ) ;
- return BigInteger.valueOf( l_count ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
+ int count = idx.count( node.getValue(), isGreaterThan );
+ return BigInteger.valueOf( count );
}
// count for non-indexed attribute is unknown so we presume da worst
- return MAX ;
+ return MAX;
}
@@ -507,21 +290,21 @@
* available otherwise the count of all the entries within the database is
* returned.
*
- * @param a_node the leaf node to get a full scan count for
+ * @param node the leaf node to get a full scan count for
* @return the worst case full scan count
* @throws NamingException if there is an error access database indices
*/
- private BigInteger getFullScan( LeafNode a_node )
+ private BigInteger getFullScan( LeafNode node )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
- int l_count = l_idx.count() ;
- return BigInteger.valueOf( l_count ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
+ int count = idx.count();
+ return BigInteger.valueOf( count );
}
- return MAX ;
+ return MAX;
}
@@ -529,46 +312,46 @@
* Gets the number of entries that would be returned by a presence node
* assertion. Leverages the existance system index for scan counts.
*
- * @param a_node the presence node
+ * @param node the presence node
* @return the number of entries matched for the presence of an attribute
* @throws NamingException if errors result
*/
- private BigInteger getPresenceScan( PresenceNode a_node )
+ private BigInteger getPresenceScan( PresenceNode node )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getExistanceIndex() ;
- int l_count = l_idx.count( a_node.getAttribute() ) ;
- return BigInteger.valueOf( l_count ) ;
+ Index idx = db.getExistanceIndex();
+ int count = idx.count( node.getAttribute() );
+ return BigInteger.valueOf( count );
}
- return MAX ;
+ return MAX;
}
/**
* Gets the scan count for the scope node attached to this filter.
*
- * @param a_node the ScopeNode
+ * @param node the ScopeNode
* @return the scan count for scope
* @throws NamingException if any errors result
*/
- private BigInteger getScopeScan( ScopeNode a_node )
+ private BigInteger getScopeScan( ScopeNode node )
throws NamingException
{
- switch ( a_node.getScope() )
+ switch ( node.getScope() )
{
case ( SearchControls.OBJECT_SCOPE ):
- return BigInteger.ONE ;
+ return BigInteger.ONE;
case ( SearchControls.ONELEVEL_SCOPE ):
- BigInteger l_id = m_db.getEntryId( a_node.getBaseDn() ) ;
- return BigInteger.valueOf( m_db.getChildCount( l_id ) ) ;
+ BigInteger id = db.getEntryId( node.getBaseDn() );
+ return BigInteger.valueOf( db.getChildCount( id ) );
case ( SearchControls.SUBTREE_SCOPE ):
- return BigInteger.valueOf( m_db.count() ) ;
+ return BigInteger.valueOf( db.count() );
default:
throw new IllegalArgumentException(
- "Unrecognized search scope value for filter scope node" ) ;
+ "Unrecognized search scope value for filter scope node" );
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultSearchEngine.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultSearchEngine.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DefaultSearchEngine.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultSearchEngine.java Wed Sep 29 19:00:03 2004
@@ -1,267 +1,57 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
/*
- * $Id: DefaultSearchEngine.java,v 1.23 2003/10/17 02:05:58 akarasulu Exp $
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
*/
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
-import java.util.Hashtable ;
-import java.math.BigInteger ;
+import java.util.Map;
+import java.math.BigInteger;
-import javax.naming.Name ;
-import javax.naming.ldap.Control ;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.SearchControls ;
-
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
-
-import org.apache.ldap.common.name.LdapName ;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.common.filter.AbstractExprNode ;
-import org.apache.ldap.common.message.DerefAliasesEnum ;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchControls;
+
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.ldap.common.filter.AbstractExprNode;
+import org.apache.ldap.common.message.DerefAliasesEnum;
+
+import org.apache.eve.db.*;
/**
* Given a search filter and a scope the search engine identifies valid
* candidate entries returning their ids.
*
- * @avalon.component name="search-engine" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.SearchEngine"
- * version="1.0"
- *
- * @author $Author: akarasulu $
- * @version $Revision: 1.23 $
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
*/
-public class DefaultSearchEngine extends AbstractLogEnabled
- implements SearchEngine, Serviceable
+public class DefaultSearchEngine implements SearchEngine
{
/** the Optimizer used by this DefaultSearchEngine */
- private final Optimizer m_optimizer ;
+ private final Optimizer optimizer;
/** the Database this DefaultSearchEngine operates on */
- private Database m_db ;
+ private Database db;
/** Evaluator flyweight used for filter expression assertions */
- private Evaluator m_evaluator ;
+ private Evaluator evaluator;
/** Enumerator flyweight that creates enumerations on filter expressions */
- private Enumerator m_enumerator ;
+ private Enumerator enumerator;
// ------------------------------------------------------------------------
@@ -273,23 +63,12 @@
* Creates a DefaultSearchEngine for searching a Database without setting
* up the database.
*/
- public DefaultSearchEngine()
+ public DefaultSearchEngine( Database db, Evaluator evaluator, Enumerator enumerator )
{
- m_optimizer = new DefaultOptimizer() ;
- }
-
-
- /**
- * Sets the database this SearchEngine operates on.
- *
- * @param a_db the database which this engine operates on.
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_optimizer.enableDatabase( a_db ) ;
- m_evaluator.enableDatabase( a_db ) ;
- m_enumerator.enableDatabase( a_db ) ;
+ this.db = db;
+ this.evaluator = evaluator;
+ this.enumerator = enumerator;
+ optimizer = new DefaultOptimizer( db );
}
@@ -300,107 +79,74 @@
*/
public Optimizer getOptimizer()
{
- return m_optimizer ;
+ return optimizer;
}
/**
- * @see org.apache.ldap.server.backend.db.search.SearchEngine#search(
- * javax.naming.Name, java.util.Hashtable, org.apache.ldap.common.filter.ExprNode,
- * javax.naming.ldap.Control[], javax.naming.directory.SearchControls)
+ * @see SearchEngine#search(Name, Map, ExprNode,SearchControls)
*/
- public NamingEnumeration search( Name a_base, Hashtable a_env,
- ExprNode a_filter, Control [] a_reqCtls, SearchControls a_searchCtls )
+ public NamingEnumeration search( Name base, Map env,
+ ExprNode filter, SearchControls searchCtls )
throws NamingException
{
- Name l_effectiveBase = null ;
- BigInteger l_baseId = m_db.getEntryId( a_base.toString() ) ;
- String l_aliasedBase = ( String )
- m_db.getAliasIndex().reverseLookup( l_baseId ) ;
- DerefAliasesEnum l_mode = DerefAliasesEnum.getEnum( a_env ) ;
+ Name effectiveBase = null;
+ BigInteger baseId = db.getEntryId( base.toString() );
+ String aliasedBase = ( String ) db.getAliasIndex().reverseLookup( baseId );
+ DerefAliasesEnum mode = DerefAliasesEnum.getEnum( env );
// --------------------------------------------------------------------
- // Determine the effective base with aliases
+ // Determine the eective base with aliases
// --------------------------------------------------------------------
/*
- * If the base is not an alias or if alias dereferencing does not
- * occur on finding the base then we set the effective base to the
+ * I the base is not an alias or i alias dereerencing does not
+ * occur on inding the base then we set the eective base to the
* given base.
*/
- if ( null == l_aliasedBase || ! l_mode.derefFindingBase() )
+ if ( null == aliasedBase || ! mode.derefFindingBase() )
{
- l_effectiveBase = a_base ;
+ effectiveBase = base;
}
/*
- * If the base is an alias and alias dereferencing does occur on
- * finding the base then we set the effective base to the alias target
- * gotten from the alias index.
+ * I the base is an alias and alias dereerencing does occur on
+ * inding the base then we set the eective base to the alias target
+ * gotten rom the alias index.
*/
- else if ( null != l_aliasedBase ) // mode = FINDING || ALWAYS
+ else if ( null != aliasedBase ) // mode = FINDING || ALWAYS
{
- l_effectiveBase = new LdapName( l_aliasedBase ) ;
+ effectiveBase = new LdapName( aliasedBase );
}
/*
- * If the base not an alias the we just set the base to the given base
+ * I the base not an alias the we just set the base to the given base
*/
else
{
- l_effectiveBase = a_base ;
+ effectiveBase = base;
}
- // Add the scope node using the effective base to the filter
- BranchNode l_root = new BranchNode( AbstractExprNode.AND ) ;
- ExprNode l_node = new ScopeNode( a_env, l_effectiveBase.toString(),
- a_searchCtls.getSearchScope() ) ;
- l_root.getChildren().add( l_node ) ;
- l_root.getChildren().add( a_filter ) ;
+ // Add the scope node using the eective base to the ilter
+ BranchNode root = new BranchNode( AbstractExprNode.AND );
+ ExprNode node = new ScopeNode( env, effectiveBase.toString(),
+ searchCtls.getSearchScope() );
+ root.getChildren().add( node );
+ root.getChildren().add( filter );
// Annotate the node with the optimizer and return search enumeration.
- m_optimizer.annotate( l_root ) ;
- return m_enumerator.enumerate( l_root ) ;
+ optimizer.annotate( root );
+ return enumerator.enumerate( root );
}
/**
- * @see org.apache.ldap.server.backend.db.search.SearchEngine#evaluate(
- * org.apache.ldap.common.filter.ExprNode, java.math.BigInteger)
+ * @see SearchEngine#evaluate(ExprNode, BigInteger)
*/
- public boolean evaluate( ExprNode a_filter, BigInteger a_id )
- throws NamingException
+ public boolean evaluate( ExprNode ilter, BigInteger id ) throws NamingException
{
- IndexRecord l_rec = new IndexRecord() ;
- l_rec.setEntryId( a_id ) ;
- return m_evaluator.evaluate( a_filter, l_rec ) ;
+ IndexRecord rec = new IndexRecord();
+ rec.setEntryId( id );
+ return evaluator.evaluate( ilter, rec );
}
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.Evaluator"
- * key="evaluator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.Enumerator"
- * key="enumerator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#
- * service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "looking up the evaluator" ) ;
- m_evaluator = ( EvaluatorImpl ) a_manager.lookup( "evaluator" ) ;
-
- getLogger().debug( "looking up the enumerator" ) ;
- m_enumerator = ( EnumeratorImpl ) a_manager.lookup( "enumerator" ) ;
- }
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTable.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTable.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTable.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTable.java Wed Sep 29 19:00:03 2004
@@ -1,270 +1,54 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+package org.apache.eve.db.jdbm;
-/*
- * $Id: DefaultTable.java,v 1.8 2003/10/03 16:20:32 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-package org.apache.ldap.server.backend.db.table ;
+import java.util.TreeSet;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Collections;
-import java.util.TreeSet ;
-import java.util.Iterator ;
-import java.util.SortedSet ;
-import java.util.ArrayList ;
-import java.util.Comparator ;
-import java.util.Collections ;
-
-import java.io.IOException ;
+import java.io.IOException;
import java.io.Serializable;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+
+import jdbm.btree.BTree;
+import jdbm.RecordManager;
+import jdbm.helper.TupleBrowser;
-import jdbm.btree.BTree ;
-import jdbm.RecordManager ;
-import jdbm.helper.TupleBrowser ;
+import org.apache.ldap.common.util.EmptyEnumeration;
+import org.apache.ldap.common.util.SingletonEnumeration;
-import org.apache.ldap.common.util.EmptyEnumeration ;
-import org.apache.ldap.common.util.SingletonEnumeration ;
+import org.apache.eve.db.*;
/**
* A jdbm Btree wrapper that enables duplicate sorted keys using collections.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.8 $
+ * @todo rename to JdbmTable
*/
-public class DefaultTable
- implements Table
+public class DefaultTable implements Table
{
- /** TODO */
- private static final int CACHE_SIZE = 1000 ;
- /** TODO */
- private static final String SZSUFFIX = "_btree_sz" ;
-
- /** TODO */
- private final String m_name ;
- /** TODO */
- private final RecordManager m_recMan ;
- /** TODO */
- private final boolean m_allowsDuplicates ;
- /** TODO */
- private final TupleComparator m_comparator ;
-
- /** TODO */
- private int m_count = 0 ;
- /** TODO */
- private BTree m_bt ;
- /** TODO */
- private TupleRenderer m_renderer ;
+ /** */
+ private static final String SZSUFFIX = "_btree_sz";
+
+ /** */
+ private final String name;
+ /** */
+ private final RecordManager recMan;
+ /** */
+ private final boolean allowsDuplicates;
+ /** */
+ private final TupleComparator comparator;
+
+ /** */
+ private int count = 0;
+ /** */
+ private BTree bt;
+ /** */
+ private TupleRenderer renderer;
// ------------------------------------------------------------------------
@@ -276,32 +60,32 @@
* Creates a Jdbm BTree based tuple Table abstraction that enables
* duplicates.
*
- * @param a_name the name of the table
- * @param a_allowsDuplicates whether or not duplicates are enabled
- * @param a_manager the record manager to be used for this table
- * @param a_comparator a tuple comparator
+ * @param name the name of the table
+ * @param allowsDuplicates whether or not duplicates are enabled
+ * @param manager the record manager to be used for this table
+ * @param comparator a tuple comparator
* @throws NamingException if the table's file cannot be created
*/
- public DefaultTable( String a_name, boolean a_allowsDuplicates,
- RecordManager a_manager, TupleComparator a_comparator )
+ public DefaultTable( String name, boolean allowsDuplicates,
+ RecordManager manager, TupleComparator comparator )
throws NamingException
{
- m_name = a_name ;
- m_recMan = a_manager ;
- m_comparator = a_comparator ;
- m_allowsDuplicates = a_allowsDuplicates ;
+ this.name = name;
+ recMan = manager;
+ this.comparator = comparator;
+ this.allowsDuplicates = allowsDuplicates;
- long l_recId ;
+ long recId;
try
{
- l_recId = m_recMan.getNamedObject( m_name ) ;
+ recId = recMan.getNamedObject( name );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
try
@@ -311,13 +95,13 @@
* comparator if it is not serializable. In this case a
* SerializableComparator will be the effective comparator.
*/
- Comparator l_comparator = a_comparator.getKeyComparator() ;
- Comparator l_effective = null ;
+ Comparator keyComparator = comparator.getKeyComparator();
+ Comparator effective = null;
- if ( l_comparator instanceof Serializable )
+ if ( comparator instanceof Serializable )
{
// Serializable comparators are the effective comparators
- l_effective = l_comparator ;
+ effective = keyComparator;
}
else
{
@@ -325,48 +109,48 @@
* Non-serializable comparators are not effective comparators
* their wrapping SerializableComparators are effective comps
*/
- l_effective = new SerializableComparator( l_comparator ) ;
+ effective = new SerializableComparator( keyComparator );
}
//
// Load existing BTree
//
- if ( l_recId != 0 )
+ if ( recId != 0 )
{
/*
* If we have wrapped a non-Serializable Comparator within a
* SerializingComparator we need to set the non-Serializable
* ThreadLocal Comparator and attempt to deserialize
*/
- if ( l_effective instanceof SerializableComparator )
+ if ( effective instanceof SerializableComparator )
{
- SerializableComparator.set( l_comparator ) ;
- m_bt = BTree.load( m_recMan, l_recId ) ;
+ SerializableComparator.set( keyComparator );
+ bt = BTree.load( recMan, recId );
}
else
{
- m_bt = BTree.load( m_recMan, l_recId ) ;
+ bt = BTree.load( recMan, recId );
}
- l_recId = m_recMan.getNamedObject( m_name + SZSUFFIX ) ;
- m_count = ( ( Integer ) m_recMan.fetch( l_recId ) ).intValue() ;
+ recId = recMan.getNamedObject( name + SZSUFFIX );
+ count = ( ( Integer ) recMan.fetch( recId ) ).intValue();
}
else
{
- m_bt = BTree.createInstance( m_recMan, l_effective ) ;
- l_recId = m_bt.getRecid() ;
- m_recMan.setNamedObject( m_name, l_recId ) ;
+ bt = BTree.createInstance( recMan, effective );
+ recId = bt.getRecid();
+ recMan.setNamedObject( name, recId );
- l_recId = m_recMan.insert( new Integer( 0 ) ) ;
- m_recMan.setNamedObject( m_name + SZSUFFIX, l_recId ) ;
+ recId = recMan.insert( new Integer( 0 ) );
+ recMan.setNamedObject( name + SZSUFFIX, recId );
}
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
}
@@ -375,16 +159,15 @@
* Creates a Jdbm BTree based tuple Table abstraction without duplicates
* enabled using a simple key comparator.
*
- * @param a_name the name of the table
- * @param a_manager the record manager to be used for this table
- * @param a_keyComparator a tuple comparator
+ * @param name the name of the table
+ * @param manager the record manager to be used for this table
+ * @param keyComparator a tuple comparator
* @throws NamingException if the table's file cannot be created
*/
- public DefaultTable( String a_name, RecordManager a_manager,
- Comparator a_keyComparator ) throws NamingException
+ public DefaultTable( String name, RecordManager manager,
+ Comparator keyComparator ) throws NamingException
{
- this( a_name, false, a_manager,
- new KeyOnlyComparator( a_keyComparator ) ) ;
+ this( name, false, manager, new KeyOnlyComparator( keyComparator ) );
}
@@ -394,59 +177,59 @@
/**
- * @see org.apache.ldap.server.backend.table.Table#getComparator()
+ * @see Table#getComparator()
*/
public TupleComparator getComparator()
{
- return m_comparator ;
+ return comparator;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#isDupsEnabled()
+ * @see Table#isDupsEnabled()
*/
public boolean isDupsEnabled()
{
- return m_allowsDuplicates ;
+ return allowsDuplicates;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#getName()
+ * @see Table#getName()
*/
public String getName()
{
- return m_name ;
+ return name;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#getRenderer()
+ * @see Table#getRenderer()
*/
public TupleRenderer getRenderer()
{
- return m_renderer ;
+ return renderer;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#setRenderer(
- * org.apache.ldap.server.backend.table.TupleRenderer)
+ * @see Table#setRenderer(
+ * TupleRenderer)
*/
- public void setRenderer( TupleRenderer a_renderer )
+ public void setRenderer( TupleRenderer renderer )
{
- m_renderer = a_renderer ;
+ this.renderer = renderer;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#isSortedDupsEnabled()
+ * @see Table#isSortedDupsEnabled()
*/
public boolean isSortedDupsEnabled()
{
// If duplicates are enabled than duplicates will be maintained in
// sorted order.
- return m_allowsDuplicates ;
+ return allowsDuplicates;
}
@@ -456,51 +239,51 @@
/**
- * @see org.apache.ldap.server.backend.table.Table#count(java.lang.Object, boolean)
+ * @see Table#count(java.lang.Object, boolean)
*/
- public int count( Object a_key, boolean a_isGreaterThan )
+ public int count( Object key, boolean isGreaterThan )
throws NamingException
{
- throw new UnsupportedOperationException() ;
+ throw new UnsupportedOperationException();
}
/**
- * @see org.apache.ldap.server.backend.table.Table#count(java.lang.Object)
+ * @see Table#count(java.lang.Object)
*/
- public int count( Object a_key )
+ public int count( Object key )
throws NamingException
{
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- if ( null == getRaw( a_key ) )
+ if ( null == getRaw( key ) )
{
- return 0 ;
+ return 0;
}
else
{
- return 1 ;
+ return 1;
}
}
- TreeSet l_set = ( TreeSet ) getRaw( a_key ) ;
+ TreeSet set = ( TreeSet ) getRaw( key );
- if ( l_set != null )
+ if ( set != null )
{
- return l_set.size() ;
+ return set.size();
}
- return 0 ;
+ return 0;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#count()
+ * @see Table#count()
*/
public int count()
throws NamingException
{
- return m_count ;
+ return count;
}
@@ -510,290 +293,287 @@
/**
- * @see org.apache.ldap.server.backend.table.Table#get(java.lang.Object)
+ * @see Table#get(java.lang.Object)
*/
- public Object get( Object a_key ) throws NamingException
+ public Object get( Object key ) throws NamingException
{
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- TreeSet l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( null == l_set || l_set.size() == 0 )
+ TreeSet set = ( TreeSet ) getRaw( key );
+ if ( null == set || set.size() == 0 )
{
- return null ;
+ return null;
}
else
{
- return l_set.first() ;
+ return set.first();
}
}
- return getRaw( a_key ) ;
+ return getRaw( key );
}
/**
- * @see org.apache.ldap.server.backend.table.Table#has(java.lang.Object,
+ * @see Table#has(java.lang.Object,
* java.lang.Object, boolean)
*/
- public boolean has( Object a_key, Object a_val, boolean a_isGreaterThan )
+ public boolean has( Object key, Object val, boolean isGreaterThan )
throws NamingException
{
- TreeSet l_set = null ;
- SortedSet l_subset = null ;
+ TreeSet set = null;
+ SortedSet subset = null;
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- Object l_val = getRaw( a_key ) ;
+ Object rval = getRaw( key );
// key does not exist so return nothing
- if ( null == l_val )
+ if ( null == rval )
{
- return false ;
+ return false;
}
- // l_val == a_val return tuple
- else if ( a_val.equals( l_val ) )
+ // val == val return tuple
+ else if ( val.equals( rval ) )
{
- return true ;
+ return true;
}
- // l_val >= a_val and test is for greater then return tuple
- else if ( m_comparator.compareValue( l_val, a_val ) >= 1 &&
- a_isGreaterThan )
+ // val >= val and test is for greater then return tuple
+ else if ( comparator.compareValue( rval, val ) >= 1 && isGreaterThan )
{
- return true ;
+ return true;
}
- // l_val <= a_val and test is for lesser then return tuple
- else if ( m_comparator.compareValue( l_val, a_val ) <= 1 &&
- ! a_isGreaterThan )
+ // val <= val and test is for lesser then return tuple
+ else if ( comparator.compareValue( rval, val ) <= 1 &&! isGreaterThan )
{
- return true ;
+ return true;
}
- return false ;
+ return false;
}
- l_set = ( TreeSet ) getRaw( a_key ) ;
+ set = ( TreeSet ) getRaw( key );
- if ( null == l_set || l_set.size() == 0 )
+ if ( null == set || set.size() == 0 )
{
- return false ;
+ return false;
}
- if ( a_isGreaterThan )
+ if ( isGreaterThan )
{
- l_subset = l_set.tailSet( a_val ) ;
+ subset = set.tailSet( val );
}
else
{
- l_subset = l_set.headSet( a_val ) ;
+ subset = set.headSet( val );
}
- if ( l_subset.size() > 0 || l_set.contains( a_val ) )
+ if ( subset.size() > 0 || set.contains( val ) )
{
- return true ;
+ return true;
}
- return false ;
+ return false;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#has(java.lang.Object, boolean)
+ * @see Table#has(java.lang.Object, boolean)
*/
- public boolean has( Object a_key, boolean a_isGreaterThan )
- throws NamingException
+ public boolean has( Object key, boolean isGreaterThan ) throws NamingException
{
try
{
// See if we can find the border between keys greater than and less
// than in the set of keys. This will be the spot we search from.
- jdbm.helper.Tuple l_tuple = m_bt.findGreaterOrEqual( a_key ) ;
+ jdbm.helper.Tuple tuple = bt.findGreaterOrEqual( key );
// Test for equality first since it satisfies both greater/less than
- if ( null != l_tuple &&
- m_comparator.compareKey( l_tuple.getKey(), a_key ) == 0 )
+ if ( null != tuple &&
+ comparator.compareKey( tuple.getKey(), key ) == 0 )
{
- return true ;
+ return true;
}
// Greater searches are easy and quick thanks to findGreaterOrEqual
- if ( a_isGreaterThan )
+ if ( isGreaterThan )
{
// A null return above means there were no equal or greater keys
- if ( null == l_tuple )
+ if ( null == tuple )
{
- return false ;
+ return false;
}
// Not Null! - we found a tuple with equal or greater key value
- return true ;
+ return true;
}
// Less than searches occur below and are not as efficient or easy.
// We need to scan up from the begining if findGreaterOrEqual failed
// or scan down if findGreaterOrEqual succeed.
- TupleBrowser l_browser = null ;
- if ( null == l_tuple )
+ TupleBrowser browser = null;
+ if ( null == tuple )
{
// findGreaterOrEqual failed so we create a tuple and scan from
- // the lowest values up via getNext comparing each key to a_key
- l_tuple = new jdbm.helper.Tuple() ;
- l_browser = m_bt.browse() ;
+ // the lowest values up via getNext comparing each key to key
+ tuple = new jdbm.helper.Tuple();
+ browser = bt.browse();
// We should at most have to read one key. If 1st key is not
- // less than or equal to a_key then all keys are > a_key
+ // less than or equal to key then all keys are > key
// since the keys are assorted in ascending order based on the
// comparator.
- while ( l_browser.getNext( l_tuple ) )
+ while ( browser.getNext( tuple ) )
{
- if ( m_comparator.compareKey( l_tuple.getKey(), a_key )
+ if ( comparator.compareKey( tuple.getKey(), key )
<= 0 )
{
- return true ;
+ return true;
}
- return false ;
+ return false;
}
}
else
{
// findGreaterOrEqual succeeded so use the existing tuple and
- // scan the down from the highest key less than a_key via
- // getPrevious while comparing each key to a_key.
- l_browser = m_bt.browse( l_tuple.getKey() ) ;
+ // scan the down from the highest key less than key via
+ // getPrevious while comparing each key to key.
+ browser = bt.browse( tuple.getKey() );
// The above call positions the browser just before the given
// key so we need to step forward once then back. Remember this
- // key represents a key greater than or equal to a_key.
- if ( m_comparator.compareKey( l_tuple.getKey(), a_key ) <= 0 )
+ // key represents a key greater than or equal to key.
+ if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
{
- return true ;
+ return true;
}
- l_browser.getNext( l_tuple ) ;
+ browser.getNext( tuple );
// We should at most have to read one key, but we don't short
// the search as in the search above first because the chance of
// unneccessarily looping is nil since values get smaller.
- while ( l_browser.getPrevious( l_tuple ) )
+ while ( browser.getPrevious( tuple ) )
{
- if ( m_comparator.compareKey( l_tuple.getKey(), a_key )
+ if ( comparator.compareKey( tuple.getKey(), key )
<= 0 )
{
- return true ;
+ return true;
}
}
}
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
- return false ;
+ return false;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#has(java.lang.Object,
+ * @see Table#has(java.lang.Object,
* java.lang.Object)
*/
- public boolean has( Object a_key, Object a_value )
+ public boolean has( Object key, Object value )
throws NamingException
{
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- TreeSet l_set = ( TreeSet ) getRaw( a_key ) ;
+ TreeSet set = ( TreeSet ) getRaw( key );
- if ( null == l_set )
+ if ( null == set )
{
- return false ;
+ return false;
}
- return l_set.contains( a_value ) ;
+ return set.contains( value );
}
- Object l_obj = getRaw( a_key ) ;
+ Object obj = getRaw( key );
- if ( null == l_obj )
+ if ( null == obj )
{
- return false ;
+ return false;
}
- return l_obj.equals( a_value ) ;
+ return obj.equals( value );
}
/**
- * @see org.apache.ldap.server.backend.table.Table#has(java.lang.Object)
+ * @see Table#has(java.lang.Object)
*/
- public boolean has( Object a_key )
+ public boolean has( Object key )
throws NamingException
{
- return getRaw( a_key ) != null ;
+ return getRaw( key ) != null;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#put(java.lang.Object,
+ * @see Table#put(java.lang.Object,
* java.lang.Object)
*/
- public Object put( Object a_key, Object a_value )
+ public Object put( Object key, Object value )
throws NamingException
{
- Object l_replaced = null ;
+ Object replaced = null;
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- Comparator l_effective = null ;
- TreeSet l_set = ( TreeSet ) getRaw( a_key ) ;
+ Comparator effective = null;
+ TreeSet set = ( TreeSet ) getRaw( key );
- if ( m_comparator.getValueComparator() instanceof Serializable )
+ if ( comparator.getValueComparator() instanceof Serializable )
{
- l_effective = m_comparator.getValueComparator() ;
+ effective = comparator.getValueComparator();
}
else
{
- l_effective = new SerializableComparator(
- m_comparator.getValueComparator() ) ;
+ effective = new SerializableComparator(
+ comparator.getValueComparator() );
}
- if ( null == l_set )
+ if ( null == set )
{
- l_set = new TreeSet( l_effective ) ;
+ set = new TreeSet( effective );
}
- else if ( l_set.contains( a_value ) )
+ else if ( set.contains( value ) )
{
- return a_value ;
+ return value;
}
- l_set.add( a_value ) ;
- putRaw( a_key, l_set, true ) ;
- m_count++ ;
- return null ;
+ set.add( value );
+ putRaw( key, set, true );
+ count++;
+ return null;
}
- l_replaced = putRaw( a_key, a_value, true ) ;
+ replaced = putRaw( key, value, true );
- if ( null == l_replaced )
+ if ( null == replaced )
{
- m_count++ ;
+ count++;
}
- return l_replaced ;
+ return replaced;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#put(java.lang.Object,
+ * @see Table#put(java.lang.Object,
* javax.naming.NamingEnumeration)
*/
- public Object put( Object a_key, NamingEnumeration a_values )
+ public Object put( Object key, NamingEnumeration values )
throws NamingException
{
- TreeSet l_set = null ;
- Comparator l_effective = null ;
+ TreeSet set = null;
+ Comparator effective = null;
/*
* If we do not allow dupliicates call the single add put using the
@@ -801,119 +581,117 @@
* just return null without doing anything. If more than one value
* is in the enumeration than we blow a UnsupportedOperationException.
*/
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- if ( a_values.hasMore() )
+ if ( values.hasMore() )
{
- Object l_value = a_values.next() ;
+ Object value = values.next();
- if ( a_values.hasMore() )
+ if ( values.hasMore() )
{
throw new UnsupportedOperationException(
"Attempting to put duplicate keys into table "
- + m_name + " which does not support duplicates" ) ;
+ + name + " which does not support duplicates" );
}
- return put( a_key, l_value ) ;
+ return put( key, value );
}
- return null ;
+ return null;
}
/*
* Here the table allows duplicates so we get the TreeSet from the
* Table holding all the duplicate key values or create one if it
- * does not exist for a_key. We check if the value is present and
+ * does not exist for key. We check if the value is present and
* if it is we add it and increment the table entry counter.
*/
- l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( m_comparator.getValueComparator() instanceof Serializable )
+ set = ( TreeSet ) getRaw( key );
+ if ( comparator.getValueComparator() instanceof Serializable )
{
- l_effective = m_comparator.getValueComparator() ;
+ effective = comparator.getValueComparator();
}
else
{
- l_effective = new SerializableComparator(
- m_comparator.getValueComparator() ) ;
+ effective = new SerializableComparator(
+ comparator.getValueComparator() );
}
- if ( null == l_set )
+ if ( null == set )
{
- l_set = new TreeSet( l_effective ) ;
+ set = new TreeSet( effective );
}
- while ( a_values.hasMore() )
+ while ( values.hasMore() )
{
- Object l_val = a_values.next() ;
+ Object val = values.next();
- if ( ! l_set.contains( l_val ) )
+ if ( ! set.contains( val ) )
{
- l_set.add( l_val ) ;
- m_count++ ;
+ set.add( val );
+ count++;
}
}
// Return the raw TreeSet
- return putRaw( a_key, l_set, true ) ;
+ return putRaw( key, set, true );
}
/**
- * @see org.apache.ldap.server.backend.table.Table#remove(java.lang.Object,
+ * @see Table#remove(java.lang.Object,
* java.lang.Object)
*/
- public Object remove( Object a_key, Object a_value )
+ public Object remove( Object key, Object value )
throws NamingException
{
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- TreeSet l_set = ( TreeSet ) getRaw( a_key ) ;
+ TreeSet set = ( TreeSet ) getRaw( key );
- if ( null == l_set )
+ if ( null == set )
{
- return null ;
+ return null;
}
// If removal succeeds then remove if set is empty else replace it
- if ( l_set.remove( a_value ) )
+ if ( set.remove( value ) )
{
- if ( l_set.isEmpty() )
+ if ( set.isEmpty() )
{
- removeRaw( a_key ) ;
+ removeRaw( key );
}
else
{
- putRaw( a_key, l_set, true ) ;
+ putRaw( key, set, true );
}
// Decrement counter if removal occurs.
- m_count-- ;
- return a_value ;
+ count--;
+ return value;
}
- return null ;
+ return null;
}
- Object l_removed = null ;
-
- // Remove the value only if it is the same as a_value.
- if ( getRaw( a_key ).equals( a_value ) )
+ // Remove the value only if it is the same as value.
+ if ( getRaw( key ).equals( value ) )
{
- return removeRaw( a_key ) ;
+ return removeRaw( key );
}
- return null ;
+ return null;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#remove(java.lang.Object,
+ * @see Table#remove(java.lang.Object,
* javax.naming.NamingEnumeration)
*/
- public Object remove( Object a_key, NamingEnumeration a_values )
+ public Object remove( Object key, NamingEnumeration values )
throws NamingException
{
- TreeSet l_set = null ;
+ TreeSet set = null;
/*
* If we do not allow dupliicates call the single remove using the
@@ -921,34 +699,34 @@
* just return null without doing anything. If more than one value
* is in the enumeration than we blow a UnsupportedOperationException.
*/
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- if ( a_values.hasMore() )
+ if ( values.hasMore() )
{
- Object l_value = a_values.next() ;
+ Object value = values.next();
- if ( a_values.hasMore() )
+ if ( values.hasMore() )
{
throw new UnsupportedOperationException(
"Attempting to put duplicate keys into table "
- + m_name + " which does not support duplicates" ) ;
+ + name + " which does not support duplicates" );
}
- return remove( a_key, l_value ) ;
+ return remove( key, value );
}
- return null ;
+ return null;
}
/*
* Here the table allows duplicates so we get the TreeSet from the
* Table holding all the duplicate key values or return null if it
- * does not exist for a_key - nothing to do here.
+ * does not exist for key - nothing to do here.
*/
- l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( null == l_set )
+ set = ( TreeSet ) getRaw( key );
+ if ( null == set )
{
- return null ;
+ return null;
}
/*
@@ -956,76 +734,76 @@
* is in the set and remove it if it is present. We decrement the
* counter while doing so.
*/
- while ( a_values.hasMore() )
+ while ( values.hasMore() )
{
- Object l_val = a_values.next() ;
+ Object val = values.next();
- if ( ! l_set.contains( l_val ) )
+ if ( ! set.contains( val ) )
{
- l_set.remove( l_val ) ;
- m_count-- ;
+ set.remove( val );
+ count--;
}
}
// Return the raw TreeSet and put the changed one back.
- return putRaw( a_key, l_set, true ) ;
+ return putRaw( key, set, true );
}
/**
- * @see org.apache.ldap.server.backend.table.Table#remove(java.lang.Object)
+ * @see Table#remove(java.lang.Object)
*/
- public Object remove( Object a_key )
+ public Object remove( Object key )
throws NamingException
{
- Object l_returned = removeRaw( a_key ) ;
+ Object returned = removeRaw( key );
- if ( null == l_returned )
+ if ( null == returned )
{
- return null ;
+ return null;
}
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- TreeSet l_set = ( TreeSet ) l_returned ;
- this.m_count -= l_set.size() ;
- return l_set.first() ;
+ TreeSet set = ( TreeSet ) returned;
+ this.count -= set.size();
+ return set.first();
}
- this.m_count-- ;
- return l_returned ;
+ this.count--;
+ return returned;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#listValues(java.lang.Object)
+ * @see Table#listValues(java.lang.Object)
*/
- public NamingEnumeration listValues( Object a_key )
+ public NamingEnumeration listValues( Object key )
throws NamingException
{
- TreeSet l_set = null ;
+ TreeSet set = null;
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- Object l_value = get( a_key ) ;
+ Object value = get( key );
- if ( null == l_value )
+ if ( null == value )
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
else
{
- return new SingletonEnumeration( l_value ) ;
+ return new SingletonEnumeration( value );
}
}
- l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( null == l_set )
+ set = ( TreeSet ) getRaw( key );
+ if ( null == set )
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
- final Iterator l_list = l_set.iterator() ;
+ final Iterator list = set.iterator();
return new NamingEnumeration()
{
public void close()
@@ -1034,24 +812,24 @@
public Object nextElement()
{
- return l_list.next() ;
+ return list.next();
}
public Object next()
{
- return l_list.next() ;
+ return list.next();
}
public boolean hasMore()
{
- return l_list.hasNext() ;
+ return list.hasNext();
}
public boolean hasMoreElements()
{
- return l_list.hasNext() ;
+ return list.hasNext();
}
- } ;
+ };
}
@@ -1061,207 +839,203 @@
/**
- * @see org.apache.ldap.server.backend.table.Table#listTuples()
+ * @see Table#listTuples()
*/
public NamingEnumeration listTuples()
throws NamingException
{
- NamingEnumeration l_list = null ;
+ NamingEnumeration list = null;
try
{
- DefaultTupleBrowser l_browser =
- new DefaultTupleBrowser( m_bt.browse() ) ;
- l_list = new NoDupsEnumeration( l_browser, true ) ;
+ DefaultTupleBrowser browser = new DefaultTupleBrowser( bt.browse() );
+ list = new NoDupsEnumeration( browser, true );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- return new DupsEnumeration( ( NoDupsEnumeration ) l_list ) ;
+ return new DupsEnumeration( ( NoDupsEnumeration ) list );
}
- return l_list ;
+ return list;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#listTuples(java.lang.Object)
+ * @see Table#listTuples(java.lang.Object)
*/
- public NamingEnumeration listTuples( Object a_key )
+ public NamingEnumeration listTuples( Object key )
throws NamingException
{
- TreeSet l_set = null ;
- NamingEnumeration l_list = null ;
-
+ TreeSet set = null;
+
// Handle single and zero value returns without duplicates enabled
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- Object l_val = getRaw( a_key ) ;
+ Object val = getRaw( key );
- if ( null == l_val )
+ if ( null == val )
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
else
{
return new SingletonEnumeration(
- new Tuple( a_key, getRaw( a_key ) ) ) ;
+ new Tuple( key, getRaw( key ) ) );
}
}
- l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( l_set == null )
+ set = ( TreeSet ) getRaw( key );
+ if ( set == null )
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
- return new TupleEnumeration( a_key, l_set.iterator() ) ;
+ return new TupleEnumeration( key, set.iterator() );
}
/**
- * @see org.apache.ldap.server.backend.table.Table#listTuples(java.lang.Object,
+ * @see Table#listTuples(java.lang.Object,
* boolean)
*/
- public NamingEnumeration listTuples( Object a_key, boolean a_isGreaterThan )
+ public NamingEnumeration listTuples( Object key, boolean isGreaterThan )
throws NamingException
{
- NamingEnumeration l_list = null ;
+ NamingEnumeration list = null;
try
{
- if ( a_isGreaterThan )
+ if ( isGreaterThan )
{
- DefaultTupleBrowser l_browser =
- new DefaultTupleBrowser( m_bt.browse( a_key ) ) ;
- l_list = new NoDupsEnumeration( l_browser, a_isGreaterThan ) ;
+ DefaultTupleBrowser browser =
+ new DefaultTupleBrowser( bt.browse( key ) );
+ list = new NoDupsEnumeration( browser, isGreaterThan );
}
else
{
/* According to the jdbm docs a browser is positioned right
- * before a key greater than or equal to a_key. getNext() will
+ * before a key greater than or equal to key. getNext() will
* return the next tuple with a key greater than or equal to
- * a_key. getPrevious() used in descending scans for less than
+ * key. getPrevious() used in descending scans for less than
* for equal to comparisions will not. We need to advance
* forward once and check if the returned Tuple key equals
- * a_key. If it does then we do nothing feeding in the browser
+ * key. If it does then we do nothing feeding in the browser
* to the NoDupsCursor. If it does not we call getPrevious and
* pass it into the NoDupsCursor constructor.
*/
- jdbm.helper.Tuple l_tuple = new jdbm.helper.Tuple() ;
- TupleBrowser l_browser = m_bt.browse( a_key ) ;
+ jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
+ TupleBrowser browser = bt.browse( key );
- if ( l_browser.getNext( l_tuple ) )
+ if ( browser.getNext( tuple ) )
{
- Object l_greaterKey = l_tuple.getKey() ;
+ Object greaterKey = tuple.getKey();
- if ( 0 != m_comparator.compareKey( a_key, l_greaterKey ) )
+ if ( 0 != comparator.compareKey( key, greaterKey ) )
{
- // Make sure we don't return l_greaterKey in cursor
- l_browser.getPrevious( l_tuple ) ;
+ // Make sure we don't return greaterKey in cursor
+ browser.getPrevious( tuple );
}
}
- // If l_greaterKey != a_key above then it will not be returned.
- l_list = new NoDupsEnumeration(
- new DefaultTupleBrowser( l_browser ), a_isGreaterThan ) ;
+ // If greaterKey != key above then it will not be returned.
+ list = new NoDupsEnumeration(
+ new DefaultTupleBrowser( browser ), isGreaterThan );
}
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException(
+ NamingException ne = new NamingException(
"Failed to get TupleBrowser on table "
- + m_name + " using key " + renderKey( a_key ) ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ + name + " using key " + renderKey( key ) );
+ ne.setRootCause( e );
+ throw ne;
}
- if ( m_allowsDuplicates )
+ if ( allowsDuplicates )
{
- l_list = new DupsEnumeration( ( NoDupsEnumeration ) l_list ) ;
+ list = new DupsEnumeration( ( NoDupsEnumeration ) list );
}
- return l_list ;
+ return list;
}
/**
- * @see org.apache.ldap.server.backend.table.Table#listTuples(java.lang.Object,
+ * @see Table#listTuples(java.lang.Object,
* java.lang.Object, boolean)
*/
- public NamingEnumeration listTuples( Object a_key, Object a_val,
- boolean a_isGreaterThan ) throws NamingException
+ public NamingEnumeration listTuples( Object key, Object val,
+ boolean isGreaterThan ) throws NamingException
{
- TreeSet l_set = null ;
+ TreeSet set = null;
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- Object l_val = getRaw( a_key ) ;
+ Object rval = getRaw( key );
- if ( null == l_val ) // key does not exist so return nothing
+ if ( null == rval ) // key does not exist so return nothing
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
- else if ( a_val.equals( l_val ) ) // l_val == a_val return tuple
+ else if ( val.equals( rval ) ) // val == rval return tuple
{
- return new SingletonEnumeration( new Tuple( a_key, a_val ) ) ;
+ return new SingletonEnumeration( new Tuple( key, val ) );
}
- // l_val >= a_val and test is for greater then return tuple
- else if ( m_comparator.compareValue( l_val, a_val ) >= 1 &&
- a_isGreaterThan )
+ // val >= val and test is for greater then return tuple
+ else if ( comparator.compareValue( val, rval ) >= 1 && isGreaterThan )
{
- return new SingletonEnumeration( new Tuple( a_key, a_val ) ) ;
+ return new SingletonEnumeration( new Tuple( key, val ) );
}
- // l_val <= a_val and test is for lesser then return tuple
- else if ( m_comparator.compareValue( l_val, a_val ) <= 1 &&
- ! a_isGreaterThan )
+ // val <= val and test is for lesser then return tuple
+ else if ( comparator.compareValue( val, rval ) <= 1 && ! isGreaterThan )
{
- return new SingletonEnumeration( new Tuple( a_key, a_val ) ) ;
+ return new SingletonEnumeration( new Tuple( key, val ) );
}
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
- l_set = ( TreeSet ) getRaw( a_key ) ;
- if ( l_set == null )
+ set = ( TreeSet ) getRaw( key );
+ if ( set == null )
{
- return new EmptyEnumeration() ;
+ return new EmptyEnumeration();
}
- if ( a_isGreaterThan )
+ if ( isGreaterThan )
{
- return new TupleEnumeration( a_key,
- l_set.tailSet( a_val ).iterator() ) ;
+ return new TupleEnumeration( key,
+ set.tailSet( val ).iterator() );
}
else
{
- // Get all values from the smallest upto a_val and put them into
+ // Get all values from the smallest upto val and put them into
// a list. They will be in ascending order so we need to reverse
- // the list after adding a_val which is not included in headSet.
- SortedSet l_headset = l_set.headSet( a_val ) ;
- ArrayList l_list = new ArrayList( l_set.size() + 1 ) ;
- l_list.addAll( l_headset ) ;
+ // the list after adding val which is not included in headSet.
+ SortedSet headset = set.headSet( val );
+ ArrayList list = new ArrayList( set.size() + 1 );
+ list.addAll( headset );
- // Add largest value (a_val) if it is in the set. TreeSet.headSet
- // does not get a_val if a_val is in the set. So we add it now to
+ // Add largest value (val) if it is in the set. TreeSet.headSet
+ // does not get val if val is in the set. So we add it now to
// the end of the list. List is now ascending from smallest to
- // a_val
- if ( l_set.contains( a_val ) )
+ // val
+ if ( set.contains( val ) )
{
- l_list.add( a_val ) ;
+ list.add( val );
}
- // Reverse the list now we have descending values from a_val to the
- // smallest value that a_key has. Return tuple cursor over list.
- Collections.reverse( l_list ) ;
- return new TupleEnumeration( a_key, l_list.iterator() ) ;
+ // Reverse the list now we have descending values from val to the
+ // smallest value that key has. Return tuple cursor over list.
+ Collections.reverse( list );
+ return new TupleEnumeration( key, list.iterator() );
}
}
@@ -1272,12 +1046,12 @@
/**
- * @see org.apache.ldap.server.backend.table.Table#close()
+ * @see Table#close()
*/
public synchronized void close()
throws NamingException
{
- sync() ;
+ sync();
}
@@ -1290,22 +1064,22 @@
{
try
{
- long l_recId = m_recMan.getNamedObject( m_name + SZSUFFIX ) ;
+ long recId = recMan.getNamedObject( name + SZSUFFIX );
- if ( 0 == l_recId )
+ if ( 0 == recId )
{
- l_recId = m_recMan.insert( new Integer( m_count ) ) ;
+ recId = recMan.insert( new Integer( count ) );
}
else
{
- m_recMan.update( l_recId, new Integer( m_count ) ) ;
+ recMan.update( recId, new Integer( count ) );
}
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
}
@@ -1316,89 +1090,27 @@
/**
- * Renders a key/value pair or tuple using the renderer associated with this
- * table.
- *
- * @param a_key the key to render.
- * @param a_value the value to render.
- * @return the rendered String representation of the Tuple
- */
- private String render( Object a_key, Object a_value )
- {
- StringBuffer l_buf = new StringBuffer() ;
-
- l_buf.append( "('" ) ;
- if ( null == m_renderer )
- {
- l_buf.append( a_key.toString() ) ;
- }
- else
- {
- l_buf.append( m_renderer.getKeyString( a_key ) ) ;
- }
-
- l_buf.append( "', '" ) ;
- if ( null == m_renderer )
- {
- l_buf.append( a_value.toString() ) ;
- }
- else
- {
- l_buf.append( m_renderer.getValueString( a_value ) ) ;
- }
-
- l_buf.append( "')" ) ;
- return l_buf.toString() ;
- }
-
-
- /**
* Renders a key using the renderer associated with this table.
*
- * @param a_obj the key to render.
- * @return the rendered String representation of a_obj
- */
- private String renderKey( Object a_obj )
- {
- StringBuffer l_buf = new StringBuffer() ;
-
- l_buf.append( '\'' ) ;
- if ( null == m_renderer )
- {
- l_buf.append( a_obj.toString() ) ;
- }
- else
- {
- l_buf.append( m_renderer.getKeyString( a_obj ) ) ;
- }
-
- l_buf.append( '\'' ) ;
- return l_buf.toString() ;
- }
-
-
- /**
- * Renders a value using the renderer associated with this table.
- *
- * @param a_obj the value to render.
- * @return the rendered String representation of a_obj
+ * @param obj the key to render.
+ * @return the rendered String representation of obj
*/
- private String renderValue( Object a_obj )
+ private String renderKey( Object obj )
{
- StringBuffer l_buf = new StringBuffer() ;
+ StringBuffer buf = new StringBuffer();
- l_buf.append( '\'' ) ;
- if ( null == m_renderer )
+ buf.append( '\'' );
+ if ( null == renderer )
{
- l_buf.append( a_obj.toString() ) ;
+ buf.append( obj.toString() );
}
else
{
- l_buf.append( m_renderer.getValueString( a_obj ) ) ;
+ buf.append( renderer.getKeyString( obj ) );
}
- l_buf.append( '\'' ) ;
- return l_buf.toString() ;
+ buf.append( '\'' );
+ return buf.toString();
}
@@ -1406,46 +1118,45 @@
* Gets a Tuple value from the btree while wrapping any IOExceptions with a
* NamingException.
*
- * @param a_key the key of the Tuple to get the value of
+ * @param key the key of the Tuple to get the value of
* @return the raw value object from the btree
* @throws NamingException if there are any problems accessing the btree.
*/
- private Object getRaw( Object a_key )
- throws NamingException
+ private Object getRaw( Object key ) throws NamingException
{
- Object l_val = null ;
+ Object val = null;
- if ( null == a_key )
+ if ( null == key )
{
- return null ;
+ return null;
}
try
{
- if ( ! m_allowsDuplicates )
+ if ( ! allowsDuplicates )
{
- l_val = m_bt.find( a_key ) ;
+ val = bt.find( key );
}
else
{
- Comparator l_comparator = m_comparator.getValueComparator() ;
- if ( ! ( l_comparator instanceof Serializable ) )
+ Comparator comparator = this.comparator.getValueComparator();
+ if ( ! ( comparator instanceof Serializable ) )
{
- SerializableComparator.set( l_comparator ) ;
+ SerializableComparator.set( comparator );
}
- l_val = m_bt.find( a_key ) ;
- SerializableComparator.unset() ;
+ val = bt.find( key );
+ SerializableComparator.unset();
}
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
- return l_val ;
+ return val;
}
@@ -1453,29 +1164,29 @@
* Puts a Tuple into the btree while wrapping any IOExceptions with a
* NamingException.
*
- * @param a_key the key of the Tuple to put
- * @param a_value the value of the Tuple to put
- * @param a_doReplace whether or not to replace the object if it exists
+ * @param key the key of the Tuple to put
+ * @param value the value of the Tuple to put
+ * @param doReplace whether or not to replace the object if it exists
* @return the raw value object removed from the btree on replacement
* @throws NamingException if there are any problems accessing the btree.
*/
- private Object putRaw( Object a_key, Object a_value, boolean a_doReplace )
+ private Object putRaw( Object key, Object value, boolean doReplace )
throws NamingException
{
- Object l_val = null ;
+ Object val = null;
try
{
- l_val = m_bt.insert( a_key, a_value, a_doReplace ) ;
+ val = bt.insert( key, value, doReplace );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
- return l_val ;
+ return val;
}
@@ -1483,26 +1194,26 @@
* Removes a entry from the btree while wrapping any IOExceptions with a
* NamingException.
*
- * @param a_key the key of the Tuple to remove
+ * @param key the key of the Tuple to remove
* @return the raw value object removed from the btree
* @throws NamingException if there are any problems accessing the btree.
*/
- private Object removeRaw( Object a_key )
+ private Object removeRaw( Object key )
throws NamingException
{
- Object l_val = null ;
+ Object val = null;
try
{
- l_val = m_bt.remove( a_key ) ;
+ val = bt.remove( key );
}
catch ( IOException e )
{
- NamingException l_ne = new NamingException() ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException();
+ ne.setRootCause( e );
+ throw ne;
}
- return l_val ;
+ return val;
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTupleBrowser.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTupleBrowser.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/table/DefaultTupleBrowser.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DefaultTupleBrowser.java Wed Sep 29 19:00:03 2004
@@ -1,314 +1,98 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+package org.apache.eve.db.jdbm;
-/*
- * $Id: DefaultTupleBrowser.java,v 1.2 2003/09/21 06:46:04 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- */
-package org.apache.ldap.server.backend.db.table ;
+import org.apache.eve.db.Tuple;
+import org.apache.eve.db.TupleBrowser;
-import java.io.IOException ;
+import java.io.IOException;
-import javax.naming.NamingException ;
+import javax.naming.NamingException;
/**
* TupleBrowser wrapper for Jdbm based TupleBrowsers.
*
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
- * @testcase org.apache.ldap.server.backend.berkeley.table.TestMasterTable
+ * @todo rename this to JdbmTupleBrowser
*/
-public class DefaultTupleBrowser
- implements TupleBrowser
+public class DefaultTupleBrowser implements TupleBrowser
{
/** underlying wrapped jdbm.helper.TupleBrowser */
- private jdbm.helper.TupleBrowser m_jdbmBrowser ;
+ private jdbm.helper.TupleBrowser jdbmBrowser;
/** safe temp jdbm.helper.Tuple used to store next/previous tuples */
- private jdbm.helper.Tuple m_jdbmTuple = new jdbm.helper.Tuple() ;
+ private jdbm.helper.Tuple jdbmTuple = new jdbm.helper.Tuple();
/**
- * @todo Document me!
- *
- * @param a_jdbmBrowser JDBM browser to wrap.
+ * Creates a DefaultTupleBrowser.
+ *
+ * @param jdbmBrowser JDBM browser to wrap.
*/
- public DefaultTupleBrowser( jdbm.helper.TupleBrowser a_jdbmBrowser )
+ public DefaultTupleBrowser( jdbm.helper.TupleBrowser jdbmBrowser )
{
- m_jdbmBrowser = a_jdbmBrowser ;
+ this.jdbmBrowser = jdbmBrowser;
}
/**
- * @see org.apache.ldap.server.backend.db.table.TupleBrowser#getNext(
- * org.apache.ldap.server.backend.db.table.Tuple)
+ * @see TupleBrowser#getNext(Tuple)
*/
- public boolean getNext( Tuple a_tuple ) throws NamingException
+ public boolean getNext( Tuple tuple ) throws NamingException
{
- boolean l_isSuccess = false ;
+ boolean isSuccess = false;
- synchronized ( m_jdbmTuple )
+ synchronized ( jdbmTuple )
{
try
{
- l_isSuccess = m_jdbmBrowser.getNext( m_jdbmTuple ) ;
+ isSuccess = jdbmBrowser.getNext( jdbmTuple );
}
catch ( IOException ioe )
{
- NamingException l_ne = new NamingException(
- "Failed on call to jdbm TupleBrowser.getNext()" ) ;
- l_ne.setRootCause( ioe ) ;
- throw l_ne ;
+ NamingException ne = new NamingException(
+ "Failed on call to jdbm TupleBrowser.getNext()" );
+ ne.setRootCause( ioe );
+ throw ne;
}
- if ( l_isSuccess )
+ if ( isSuccess )
{
- a_tuple.setKey( m_jdbmTuple.getKey() ) ;
- a_tuple.setValue( m_jdbmTuple.getValue() ) ;
+ tuple.setKey( jdbmTuple.getKey() );
+ tuple.setValue( jdbmTuple.getValue() );
}
}
- return l_isSuccess ;
+ return isSuccess;
}
/**
- * @see org.apache.ldap.server.backend.db.table.TupleBrowser#getPrevious(
- * org.apache.ldap.server.backend.db.table.Tuple)
+ * @see TupleBrowser#getPrevious(Tuple)
*/
- public boolean getPrevious( Tuple a_tuple ) throws NamingException
+ public boolean getPrevious( Tuple tuple ) throws NamingException
{
- boolean l_isSuccess = false ;
+ boolean isSuccess = false;
- synchronized ( m_jdbmTuple )
+ synchronized ( jdbmTuple )
{
try
{
- l_isSuccess = m_jdbmBrowser.getPrevious( m_jdbmTuple ) ;
+ isSuccess = jdbmBrowser.getPrevious( jdbmTuple );
}
catch ( IOException ioe )
{
- NamingException l_ne = new NamingException(
- "Failed on call to jdbm TupleBrowser.getPrevious()" ) ;
- l_ne.setRootCause( ioe ) ;
- throw l_ne ;
+ NamingException ne = new NamingException(
+ "Failed on call to jdbm TupleBrowser.getPrevious()" );
+ ne.setRootCause( ioe );
+ throw ne;
}
- if ( l_isSuccess )
+ if ( isSuccess )
{
- a_tuple.setKey( m_jdbmTuple.getKey() ) ;
- a_tuple.setValue( m_jdbmTuple.getValue() ) ;
+ tuple.setKey( jdbmTuple.getKey() );
+ tuple.setValue( jdbmTuple.getValue() );
}
}
- return l_isSuccess ;
+ return isSuccess;
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DisjunctionEnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DisjunctionEnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/DisjunctionEnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/DisjunctionEnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,207 +1,207 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright [yyyy] [name of copyright owner]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
/*
* $Id: DisjunctionEnumeratorImpl.java,v 1.1 2003/10/13 18:10:17 akarasulu Exp $
@@ -212,17 +212,17 @@
*
* Created on Oct 13, 2003
*/
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
import java.util.ArrayList;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.server.backend.db.Database ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.eve.db.*;
/**
@@ -238,53 +238,40 @@
* @author $Author: akarasulu $
* @version $Revision: 1.1 $
*/
-public class DisjunctionEnumeratorImpl
- implements DisjunctionEnumerator, EnumeratorDependent
+public class DisjunctionEnumeratorImpl implements DisjunctionEnumerator
{
- /** Database this conjunction is applied upon */
- private Database m_db = null ;
/** Top level expression enumerator - non Avalon dependency avaoids cycle */
- private Enumerator m_enumerator ;
+ private Enumerator enumerator;
/**
- * @see org.apache.ldap.server.backend.db.search.Enumerator#enumerate(
- * org.apache.ldap.common.filter.ExprNode)
+ * Creates a disjunction enumerator using a top level enumerator.
+ *
+ * @param enumerator the top level enumerator
*/
- public NamingEnumeration enumerate( ExprNode a_node )
- throws NamingException
+ public DisjunctionEnumeratorImpl( Enumerator enumerator )
{
- ArrayList l_children = ( ( BranchNode ) a_node ).getChildren() ;
- NamingEnumeration [] l_childEnumerations =
- new NamingEnumeration [l_children.size()] ;
-
- // Recursively create NamingEnumerations for each child expression node
- for ( int ii = 0 ; ii < l_childEnumerations.length; ii++ )
- {
- l_childEnumerations[ii] =
- m_enumerator.enumerate( ( ExprNode ) l_children.get( ii ) ) ;
- }
-
- return new DisjunctionEnumeration( l_childEnumerations ) ;
+ this.enumerator = enumerator;
}
/**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
+ * @see Enumerator#enumerate(ExprNode)
*/
- public void enableDatabase( Database a_db )
+ public NamingEnumeration enumerate( ExprNode node )
+ throws NamingException
{
- m_db = a_db ;
- }
+ ArrayList children = ( ( BranchNode ) node ).getChildren();
+ NamingEnumeration [] childEnumerations =
+ new NamingEnumeration [children.size()];
+ // Recursively create NamingEnumerations for each child expression node
+ for ( int ii = 0; ii < childEnumerations.length; ii++ )
+ {
+ childEnumerations[ii] =
+ enumerator.enumerate( ( ExprNode ) children.get( ii ) );
+ }
- /**
- * @see org.apache.ldap.server.backend.db.search.EnumeratorDependent#
- * setEnumeratorDependency(org.apache.ldap.server.backend.db.search.Enumerator)
- */
- public void setEnumeratorDependency( Enumerator a_enumerator )
- {
- m_enumerator = a_enumerator ;
+ return new DisjunctionEnumeration( childEnumerations );
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,352 +1,131 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: EnumeratorImpl.java,v 1.2 2003/10/17 00:10:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 11, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
+
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.LeafNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.filter.BranchNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.filter.AssertionNode;
+import org.apache.ldap.common.filter.SubstringNode;
+import org.apache.ldap.common.NotImplementedException;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.LeafNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.common.filter.SimpleNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.common.filter.AssertionNode ;
-import org.apache.ldap.common.filter.SubstringNode ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.common.NotImplementedException ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
+import org.apache.eve.db.*;
/**
* Enumerates over candidates that satisfy a filter expression.
*
- * @avalon.component name="enumerator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.Enumerator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class EnumeratorImpl extends AbstractLogEnabled
- implements Enumerator, Serviceable
+public class EnumeratorImpl implements Enumerator
{
/** The database used by this enumerator */
- private Database m_db = null ;
-
+ private Database db = null;
/** Enumerator flyweight for evaulating filter scope assertions */
- private ScopeEnumerator m_scopeEnumerator ;
+ private ScopeEnumerator scopeEnumerator;
/** Enumerator flyweight for evaulating filter substring assertions */
- private SubstringEnumerator m_substringEnumerator ;
+ private SubstringEnumerator substringEnumerator;
/** Enumerator flyweight for evaulating filter conjunction assertions */
- private ConjunctionEnumerator m_conjunctionEnumerator ;
+ private ConjunctionEnumeratorImpl conjunctionEnumerator;
/** Enumerator flyweight for evaulating filter disjunction assertions */
- private DisjunctionEnumerator m_disjunctionEnumerator ;
+ private DisjunctionEnumerator disjunctionEnumerator;
/** Enumerator flyweight for evaulating filter negation assertions */
- private NegationEnumerator m_negationEnumerator ;
-
+ private NegationEnumerator negationEnumerator;
/** Evaluator dependency on a LeafNode evaluator */
- private LeafEvaluator m_evaluator ;
-
+ private LeafEvaluator evaluator;
+
+
+ public EnumeratorImpl( Database db, Evaluator topEvaluator,
+ LeafEvaluator leafEvaluator )
+ {
+ this.db = db;
+ scopeEnumerator = new ScopeEnumeratorImpl();
+ substringEnumerator = new SubstringEnumeratorImpl();
+ conjunctionEnumerator = new ConjunctionEnumeratorImpl( this, topEvaluator );
+ disjunctionEnumerator = new DisjunctionEnumeratorImpl( this );
+ negationEnumerator = new NegationEnumeratorImpl();
+ }
+
/**
* Creates an enumeration to enumerate through the set of candidates
* satisfying a filter expression.
*
- * @param a_node a filter expression root
+ * @param node a filter expression root
* @return an enumeration over the
* @throws NamingException if database access fails
*/
- public NamingEnumeration enumerate( ExprNode a_node ) throws NamingException
+ public NamingEnumeration enumerate( ExprNode node ) throws NamingException
{
- NamingEnumeration l_list = null ;
+ NamingEnumeration list = null;
- if ( a_node instanceof ScopeNode )
+ if ( node instanceof ScopeNode )
{
- l_list = m_scopeEnumerator.enumerate( ( ScopeNode ) a_node ) ;
+ list = scopeEnumerator.enumerate( ( ScopeNode ) node );
}
- else if ( a_node instanceof AssertionNode )
+ else if ( node instanceof AssertionNode )
{
throw new IllegalArgumentException( "Cannot produce enumeration "
- + "on an AssertionNode" ) ;
+ + "on an AssertionNode" );
}
- else if ( a_node.isLeaf() )
+ else if ( node.isLeaf() )
{
- Index l_idx = null ;
- LeafNode l_leaf = ( LeafNode ) a_node ;
- SimpleNode l_simple = null ;
-
- switch( l_leaf.getAssertionType() )
+ LeafNode leaf = ( LeafNode ) node;
+
+ switch( leaf.getAssertionType() )
{
case( LeafNode.APPROXIMATE ):
- l_list = enumEquality( ( SimpleNode ) a_node ) ;
- break ;
+ list = enumEquality( ( SimpleNode ) node );
+ break;
case( LeafNode.EQUALITY ):
- l_list = enumEquality( ( SimpleNode ) a_node ) ;
- break ;
+ list = enumEquality( ( SimpleNode ) node );
+ break;
case( LeafNode.EXTENSIBLE ):
// N O T I M P L E M E N T E D Y E T !
- throw new NotImplementedException() ;
+ throw new NotImplementedException();
case( LeafNode.GREATEREQ ):
- l_list = enumGreater( ( SimpleNode ) a_node, true ) ;
- break ;
+ list = enumGreater( ( SimpleNode ) node, true );
+ break;
case( LeafNode.LESSEQ ):
- l_list = enumGreater( ( SimpleNode ) a_node, false ) ;
- break ;
+ list = enumGreater( ( SimpleNode ) node, false );
+ break;
case( LeafNode.PRESENCE ):
- l_list = enumPresence( ( PresenceNode ) a_node ) ;
- break ;
+ list = enumPresence( ( PresenceNode ) node );
+ break;
case( LeafNode.SUBSTRING ):
- l_list = m_substringEnumerator.enumerate( ( SubstringNode )
- l_leaf ) ;
- break ;
+ list = substringEnumerator.enumerate( ( SubstringNode )
+ leaf );
+ break;
default:
- throw new IllegalArgumentException( "Unknown leaf assertion" ) ;
+ throw new IllegalArgumentException( "Unknown leaf assertion" );
}
}
else
{
- BranchNode l_branch = ( BranchNode ) a_node ;
+ BranchNode branch = ( BranchNode ) node;
- switch( l_branch.getOperator() )
+ switch( branch.getOperator() )
{
case( BranchNode.AND ):
- l_list = m_conjunctionEnumerator.enumerate( l_branch ) ;
- break ;
+ list = conjunctionEnumerator.enumerate( branch );
+ break;
case( BranchNode.NOT ):
- l_list = m_negationEnumerator.enumerate( l_branch ) ;
- break ;
+ list = negationEnumerator.enumerate( branch );
+ break;
case( BranchNode.OR ):
- l_list = m_disjunctionEnumerator.enumerate( l_branch ) ;
- break ;
+ list = disjunctionEnumerator.enumerate( branch );
+ break;
default:
throw new IllegalArgumentException(
- "Unknown branch logical operator" ) ;
+ "Unknown branch logical operator" );
}
}
- return l_list ;
+ return list;
}
@@ -354,20 +133,20 @@
* Returns an enumeration over candidates that satisfy a presence attribute
* value assertion.
*
- * @param a_node the presence AVA node
+ * @param node the presence AVA node
* @return an enumeration over the index records matching the AVA
* @throws NamingException if there is a failure while accessing the db
*/
- private NamingEnumeration enumPresence( final PresenceNode a_node )
+ private NamingEnumeration enumPresence( final PresenceNode node )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getExistanceIndex() ;
- return l_idx.listIndices( a_node.getAttribute() ) ;
+ Index idx = db.getExistanceIndex();
+ return idx.listIndices( node.getAttribute() );
}
- return nonIndexedScan( a_node ) ;
+ return nonIndexedScan( node );
}
@@ -375,29 +154,29 @@
* Returns an enumeration over candidates that satisfy a simple greater than
* or less than or equal to attribute value assertion.
*
- * @param a_node the AVA node
- * @param a_isGreater true if >= false if <= is used
+ * @param node the AVA node
+ * @param isGreater true if >= false if <= is used
* @return an enumeration over the index records matching the AVA
* @throws NamingException if there is a failure while accessing the db
*/
- private NamingEnumeration enumGreater( final SimpleNode a_node,
- final boolean a_isGreater ) throws NamingException
+ private NamingEnumeration enumGreater( final SimpleNode node,
+ final boolean isGreater ) throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
- if ( a_isGreater )
+ if ( isGreater )
{
- return l_idx.listIndices( a_node.getValue(), true ) ;
+ return idx.listIndices( node.getValue(), true );
}
else
{
- return l_idx.listIndices( a_node.getValue(), false ) ;
+ return idx.listIndices( node.getValue(), false );
}
}
- return nonIndexedScan( a_node ) ;
+ return nonIndexedScan( node );
}
@@ -405,20 +184,20 @@
* Returns an enumeration over candidates that satisfy a simple equality
* attribute value assertion.
*
- * @param a_node the equality AVA node
+ * @param node the equality AVA node
* @return an enumeration over the index records matching the AVA
* @throws NamingException if there is a failure while accessing the db
*/
- private NamingEnumeration enumEquality( final SimpleNode a_node )
+ private NamingEnumeration enumEquality( final SimpleNode node )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
- return l_idx.listIndices( a_node.getValue() ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
+ return idx.listIndices( node.getValue() );
}
- return nonIndexedScan( a_node ) ;
+ return nonIndexedScan( node );
}
@@ -426,115 +205,23 @@
* Creates a scan over all entries in the database with an assertion to test
* for the correct evaluation of a filter expression on a LeafNode.
*
- * @param a_node the leaf node to produce a scan over
+ * @param node the leaf node to produce a scan over
* @return the enumeration over all perspective candidates satisfying expr
* @throws NamingException if db access failures result
*/
- private NamingEnumeration nonIndexedScan( final LeafNode a_node )
+ private NamingEnumeration nonIndexedScan( final LeafNode node )
throws NamingException
{
- NamingEnumeration l_underlying = m_db.getNdnIndex().listIndices() ;
- IndexAssertion l_assertion = new IndexAssertion()
+ NamingEnumeration underlying = db.getNdnIndex().listIndices();
+ IndexAssertion assertion = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord a_record )
+ public boolean assertCandidate( IndexRecord record )
throws NamingException
{
- return m_evaluator.evaluate( a_node, a_record ) ;
+ return evaluator.evaluate( node, record );
}
- } ;
-
- return new IndexAssertionEnumeration( l_underlying, l_assertion ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_scopeEnumerator.enableDatabase( a_db ) ;
- m_substringEnumerator.enableDatabase( a_db ) ;
- m_negationEnumerator.enableDatabase( a_db ) ;
- m_disjunctionEnumerator.enableDatabase( a_db ) ;
- m_conjunctionEnumerator.enableDatabase( a_db ) ;
- }
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.LeafEvaluator"
- * key="leaf-evaluator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.ScopeEnumerator"
- * key="scope-enumerator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.SubstringEnumerator"
- * key="substring-enumerator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.ConjunctionEnumerator"
- * key="conjunction-enumerator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.DisjunctionEnumerator"
- * key="disjunction-enumerator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.NegationEnumerator"
- * key="negation-enumerator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- m_evaluator = ( LeafEvaluator ) a_manager
- .lookup( "leaf-evaluator" ) ;
-
- m_scopeEnumerator = ( ScopeEnumerator ) a_manager
- .lookup( "scope-enumerator" ) ;
-
- m_substringEnumerator = ( SubstringEnumerator ) a_manager
- .lookup( "substring-enumerator" ) ;
-
- /*
- * Get handles on the conjunction, disjunction and negation enumerators
- * and enable them with handles to this top level enumerator for
- * recursive calls if they implement the EnumeratorDependent interface.
- */
-
- m_conjunctionEnumerator = ( ConjunctionEnumerator ) a_manager
- .lookup( "conjunction-enumerator" ) ;
- if ( m_conjunctionEnumerator instanceof EnumeratorDependent )
- {
- ( ( EnumeratorDependent ) m_conjunctionEnumerator )
- .setEnumeratorDependency( this ) ;
- }
+ };
- m_disjunctionEnumerator = ( DisjunctionEnumerator ) a_manager
- .lookup( "disjunction-enumerator" ) ;
- if ( m_disjunctionEnumerator instanceof EnumeratorDependent )
- {
- ( ( EnumeratorDependent ) m_disjunctionEnumerator )
- .setEnumeratorDependency( this ) ;
- }
-
- m_negationEnumerator = ( NegationEnumerator ) a_manager
- .lookup( "negation-enumerator" ) ;
- if ( m_negationEnumerator instanceof EnumeratorDependent )
- {
- ( ( EnumeratorDependent ) m_negationEnumerator )
- .setEnumeratorDependency( this ) ;
- }
+ return new IndexAssertionEnumeration( underlying, assertion );
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EvaluatorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EvaluatorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/EvaluatorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/EvaluatorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,269 +1,46 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: EvaluatorImpl.java,v 1.2 2003/10/15 01:59:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 10, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
-import java.util.Iterator ;
+import java.util.Iterator;
-import javax.naming.NamingException ;
+import javax.naming.NamingException;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.BranchNode;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
+import org.apache.eve.db.Evaluator;
+import org.apache.eve.db.IndexRecord;
+import org.apache.eve.db.LeafEvaluator;
/**
* Filter expression evaluator implemenation.
*
- * @avalon.component name="evaluator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.Evaluator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class EvaluatorImpl extends AbstractLogEnabled
- implements Evaluator, Serviceable
+public class EvaluatorImpl implements Evaluator
{
- /** Database used to evaluate leaf with */
- private Database m_db ;
/** Leaf Evaluator flyweight use for leaf filter assertions */
- private LeafEvaluator m_leafEvaluator ;
+ private LeafEvaluator leafEvaluator;
+
+
+ public EvaluatorImpl( LeafEvaluator leafEvaluator )
+ {
+ this.leafEvaluator = leafEvaluator;
+ }
/**
- * @see org.apache.ldap.server.backend.db.search.Evaluator#evaluate(
- * org.apache.ldap.common.filter.ExprNode, org.apache.ldap.server.backend.db.index.IndexRecord)
+ * @see org.apache.eve.db.Evaluator#evaluate(ExprNode, IndexRecord)
*/
- public boolean evaluate( ExprNode a_node, IndexRecord a_record )
+ public boolean evaluate( ExprNode node, IndexRecord record )
throws NamingException
{
- if ( a_node.isLeaf() )
+ if ( node.isLeaf() )
{
- return m_leafEvaluator.evaluate( a_node, a_record ) ;
+ return leafEvaluator.evaluate( node, record );
}
- return evaluateBranch( ( BranchNode ) a_node, a_record ) ;
+ return evaluateBranch( ( BranchNode ) node, record );
}
@@ -271,86 +48,53 @@
* Evaluates a BranchNode on an candidate entry using an IndexRecord on the
* entry.
*
- * @param a_node the branch node to evaluate
- * @param a_record the index record for the entry
+ * @param node the branch node to evaluate
+ * @param record the index record for the entry
* @return true if the entry should be returned false otherwise
* @throws NamingException if there is a failure while accessing the db
*/
- boolean evaluateBranch( BranchNode a_node, IndexRecord a_record )
+ boolean evaluateBranch( BranchNode node, IndexRecord record )
throws NamingException
{
- switch( a_node.getOperator() )
+ switch( node.getOperator() )
{
case( BranchNode.OR ):
- Iterator l_children = a_node.getChildren().iterator() ;
+ Iterator children = node.getChildren().iterator();
- while ( l_children.hasNext() )
+ while ( children.hasNext() )
{
- ExprNode l_child = ( ExprNode ) l_children.next() ;
+ ExprNode child = ( ExprNode ) children.next();
- if ( evaluate( l_child, a_record ) )
+ if ( evaluate( child, record ) )
{
- return true ;
+ return true;
}
}
- return false ;
+ return false;
case( BranchNode.AND ):
- l_children = a_node.getChildren().iterator() ;
- while ( l_children.hasNext() )
+ children = node.getChildren().iterator();
+ while ( children.hasNext() )
{
- ExprNode l_child = ( ExprNode ) l_children.next() ;
+ ExprNode child = ( ExprNode ) children.next();
- if ( ! evaluate( l_child, a_record ) )
+ if ( ! evaluate( child, record ) )
{
- return false ;
+ return false;
}
}
- return true ;
+ return true;
case( BranchNode.NOT ):
- if ( null != a_node.getChild() )
+ if ( null != node.getChild() )
{
- return ! evaluate( a_node.getChild(), a_record ) ;
+ return ! evaluate( node.getChild(), record );
}
- throw new NamingException( "Negation has no child: " + a_node ) ;
+ throw new NamingException( "Negation has no child: " + node );
default:
throw new NamingException( "Unrecognized branch node operator: "
- + a_node.getOperator() ) ;
+ + node.getOperator() );
}
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_leafEvaluator.enableDatabase( a_db ) ;
- }
-
-
- // ------------------------------------------------------------------------
- // AVALON LIFE-CYCLE METHODS
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.LeafEvaluator"
- * key="leaf-evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "Looking up leaf-evaluator" ) ;
- m_leafEvaluator = ( LeafEvaluatorImpl ) a_manager
- .lookup( "leaf-evaluator" ) ;
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/LeafEvaluatorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/LeafEvaluatorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/LeafEvaluatorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/LeafEvaluatorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,309 +1,95 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: LeafEvaluatorImpl.java,v 1.4 2003/10/17 01:08:56 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 9, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
+
+import java.math.BigInteger;
+import java.util.Comparator;
-import java.math.BigInteger ;
-import java.util.Comparator ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.LeafNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.schema.Normalizer;
+import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.NotImplementedException;
+
+import org.apache.eve.db.Index;
+import org.apache.eve.db.Database;
+import org.apache.eve.db.IndexRecord;
+import org.apache.eve.db.LeafEvaluator;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.Attributes ;
-
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.LeafNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.common.filter.SimpleNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.common.NotImplementedException ;
-import org.apache.ldap.server.schema.matching.Normalizer ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
-import org.apache.ldap.server.schema.matching.ComparatorRegistry ;
-import org.apache.ldap.server.schema.matching.NormalizerRegistry ;
+import org.apache.eve.schema.NormalizerRegistry;
+import org.apache.eve.schema.ComparatorRegistry;
/**
* Evaluates LeafNode assertions on candidates using a database.
*
- * @avalon.component name="leaf-evaluator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.LeafEvaluator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.4 $
*/
-public class LeafEvaluatorImpl extends AbstractLogEnabled
- implements Serviceable, LeafEvaluator
+public class LeafEvaluatorImpl implements LeafEvaluator
{
/** Database used to evaluate leaf with */
- private Database m_db ;
+ private Database db;
/** Normalizer registry for up value normalization */
- private NormalizerRegistry m_normalizerRegistry ;
+ private NormalizerRegistry normalizerRegistry;
/** Comparator registry for comparing normalized values */
- private ComparatorRegistry m_comparatorRegistry ;
+ private ComparatorRegistry comparatorRegistry;
/** Substring node evaluator we depend on */
- private SubstringEvaluatorImpl m_substringEvaluator ;
+ private SubstringEvaluatorImpl substringEvaluator;
/** ScopeNode evaluator we depend on */
- private ScopeEvaluatorImpl m_scopeEvaluator ;
+ private ScopeEvaluatorImpl scopeEvaluator;
+
+
+
+ public LeafEvaluatorImpl( Database db,
+ ScopeEvaluatorImpl scopeEvaluator,
+ NormalizerRegistry normalizerRegistry,
+ ComparatorRegistry comparatorRegistry,
+ SubstringEvaluatorImpl substringEvaluator )
+ {
+ this.db = db;
+ this.scopeEvaluator = scopeEvaluator;
+ this.normalizerRegistry = normalizerRegistry;
+ this.comparatorRegistry = comparatorRegistry;
+ this.substringEvaluator = substringEvaluator;
+ }
/**
- * @see org.apache.ldap.server.backend.db.search.Evaluator#evaluate(
- * org.apache.ldap.common.filter.ExprNode, org.apache.ldap.server.backend.db.index.IndexRecord)
+ * @see org.apache.eve.db.Evaluator#evaluate(ExprNode, IndexRecord)
*/
- public boolean evaluate( ExprNode a_node, IndexRecord a_record )
+ public boolean evaluate( ExprNode node, IndexRecord record )
throws NamingException
{
- Index l_idx = null ;
- SimpleNode l_simple = null ;
-
- if ( a_node instanceof ScopeNode )
+ if ( node instanceof ScopeNode )
{
- return m_scopeEvaluator.evaluate( a_node, a_record ) ;
+ return scopeEvaluator.evaluate( node, record );
}
- switch( ( ( LeafNode ) a_node ).getAssertionType() )
+ switch( ( ( LeafNode ) node ).getAssertionType() )
{
case( LeafNode.APPROXIMATE ):
- return evalEquality( ( SimpleNode ) a_node, a_record ) ;
+ return evalEquality( ( SimpleNode ) node, record );
case( LeafNode.EQUALITY ):
- return evalEquality( ( SimpleNode ) a_node, a_record ) ;
+ return evalEquality( ( SimpleNode ) node, record );
case( LeafNode.EXTENSIBLE ):
- throw new NotImplementedException() ;
+ throw new NotImplementedException();
case( LeafNode.GREATEREQ ):
- return evalGreater( ( SimpleNode ) a_node, a_record, true ) ;
+ return evalGreater( ( SimpleNode ) node, record, true );
case( LeafNode.LESSEQ ):
- return evalGreater( ( SimpleNode ) a_node, a_record, false ) ;
+ return evalGreater( ( SimpleNode ) node, record, false );
case( LeafNode.PRESENCE ):
- String l_attrId = ( ( PresenceNode ) a_node ).getAttribute() ;
- return evalPresence( l_attrId, a_record ) ;
+ String attrId = ( ( PresenceNode ) node ).getAttribute();
+ return evalPresence( attrId, record );
case( LeafNode.SUBSTRING ):
- return m_substringEvaluator.evaluate( a_node, a_record ) ;
+ return substringEvaluator.evaluate( node, record );
default:
throw new NamingException( "Unrecognized leaf node type: "
- + ( ( LeafNode ) a_node ).getAssertionType() ) ;
+ + ( ( LeafNode ) node ).getAssertionType() );
}
}
@@ -312,88 +98,88 @@
* Evaluates a simple greater than or less than attribute value assertion on
* a perspective candidate.
*
- * @param a_node the greater than or less than node to evaluate
- * @param a_record the IndexRecord of the perspective candidate
- * @param a_isGreater true if it is a greater than or equal to comparison,
+ * @param node the greater than or less than node to evaluate
+ * @param record the IndexRecord of the perspective candidate
+ * @param isGreater true if it is a greater than or equal to comparison,
* false if it is a less than or equal to comparison.
* @return the ava evaluation on the perspective candidate
* @throws NamingException if there is a database access failure
*/
- private boolean evalGreater( SimpleNode a_node, IndexRecord a_record,
- boolean a_isGreater ) throws NamingException
+ private boolean evalGreater( SimpleNode node, IndexRecord record,
+ boolean isGreater ) throws NamingException
{
- String l_attrId = a_node.getAttribute() ;
- BigInteger l_id = a_record.getEntryId() ;
+ String attrId = node.getAttribute();
+ BigInteger id = record.getEntryId();
- if ( m_db.hasUserIndexOn( l_attrId ) )
+ if ( db.hasUserIndexOn( attrId ) )
{
- Index l_idx = m_db.getUserIndex( l_attrId ) ;
+ Index idx = db.getUserIndex( attrId );
- if ( a_isGreater )
+ if ( isGreater )
{
- return l_idx.hasValue( a_node.getValue(), l_id, true ) ;
+ return idx.hasValue( node.getValue(), id, true );
}
- return l_idx.hasValue( a_node.getValue(), l_id, false ) ;
+ return idx.hasValue( node.getValue(), id, false );
}
// resusitate entry if need be
- if ( null == a_record.getAttributes() )
+ if ( null == record.getAttributes() )
{
- a_record.setAttributes( m_db.lookup( l_id ) ) ;
+ record.setAttributes( db.lookup( id ) );
}
// get the attribute associated with the node
- Attribute l_attr = a_record.getAttributes().get( l_attrId ) ;
+ Attribute attr = record.getAttributes().get( attrId );
// If we do not have the attribute just return false
- if ( null == l_attr )
+ if ( null == attr )
{
- return false ;
+ return false;
}
/*
* We need to iterate through all values and for each value we normalize
* and use the comparator to determine if a match exists.
*/
- Normalizer l_normalizer = m_normalizerRegistry.getEquality( l_attrId ) ;
- Comparator l_comparator = m_comparatorRegistry.getEquality( l_attrId ) ;
- Object l_filterValue = l_normalizer.normalize( a_node.getValue() ) ;
- NamingEnumeration l_list = l_attr.getAll() ;
+ Normalizer normalizer = normalizerRegistry.getEquality( attrId );
+ Comparator comparator = comparatorRegistry.getEquality( attrId );
+ Object filterValue = normalizer.normalize( node.getValue() );
+ NamingEnumeration list = attr.getAll();
/*
- * Cheaper to not check a_isGreater in one loop - better to separate
- * out into two loops which you choose to execute based on a_isGreater
+ * Cheaper to not check isGreater in one loop - better to separate
+ * out into two loops which you choose to execute based on isGreater
*/
- if ( a_isGreater )
+ if ( isGreater )
{
- while ( l_list.hasMore() )
+ while ( list.hasMore() )
{
- Object l_value = l_normalizer.normalize( l_list.next() ) ;
+ Object value = normalizer.normalize( list.next() );
// Found a value that is greater than or equal to the ava value
- if ( 0 >= l_comparator.compare( l_value, l_filterValue ) )
+ if ( 0 >= comparator.compare( value, filterValue ) )
{
- return true ;
+ return true;
}
}
}
else
{
- while ( l_list.hasMore() )
+ while ( list.hasMore() )
{
- Object l_value = l_normalizer.normalize( l_list.next() ) ;
+ Object value = normalizer.normalize( list.next() );
// Found a value that is less than or equal to the ava value
- if ( 0 <= l_comparator.compare( l_value, l_filterValue ) )
+ if ( 0 <= comparator.compare( value, filterValue ) )
{
- return true ;
+ return true;
}
}
}
// no match so return false
- return false ;
+ return false;
}
@@ -401,29 +187,29 @@
* Evaluates a simple presence attribute value assertion on a perspective
* candidate.
*
- * @param a_attrId the name of the attribute tested for presence
- * @param a_rec the IndexRecord of the perspective candidate
+ * @param attrId the name of the attribute tested for presence
+ * @param rec the IndexRecord of the perspective candidate
* @return the ava evaluation on the perspective candidate
* @throws NamingException if there is a database access failure
*/
- private boolean evalPresence( String a_attrId, IndexRecord a_rec )
+ private boolean evalPresence( String attrId, IndexRecord rec )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_attrId ) )
+ if ( db.hasUserIndexOn( attrId ) )
{
- Index l_idx = m_db.getExistanceIndex() ;
- return l_idx.hasValue( a_attrId, a_rec.getEntryId() ) ;
+ Index idx = db.getExistanceIndex();
+ return idx.hasValue( attrId, rec.getEntryId() );
}
// resusitate entry if need be
- if ( null == a_rec.getAttributes() )
+ if ( null == rec.getAttributes() )
{
- a_rec.setAttributes( m_db.lookup( a_rec.getEntryId() ) ) ;
+ rec.setAttributes( db.lookup( rec.getEntryId() ) );
}
// get the attribute associated with the node
- Attributes l_attrs = a_rec.getAttributes() ;
- return null != l_attrs.get( a_attrId ) ;
+ Attributes attrs = rec.getAttributes();
+ return null != attrs.get( attrId );
}
@@ -431,61 +217,59 @@
* Evaluates a simple equality attribute value assertion on a perspective
* candidate.
*
- * @param a_node the equality node to evaluate
- * @param a_rec the IndexRecord of the perspective candidate
+ * @param node the equality node to evaluate
+ * @param rec the IndexRecord of the perspective candidate
* @return the ava evaluation on the perspective candidate
* @throws NamingException if there is a database access failure
*/
- private boolean evalEquality( SimpleNode a_node, IndexRecord a_rec )
+ private boolean evalEquality( SimpleNode node, IndexRecord rec )
throws NamingException
{
- if ( m_db.hasUserIndexOn( a_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( node.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( a_node.getAttribute() ) ;
- return l_idx.hasValue( a_node.getValue(), a_rec.getEntryId() ) ;
+ Index idx = db.getUserIndex( node.getAttribute() );
+ return idx.hasValue( node.getValue(), rec.getEntryId() );
}
- Normalizer l_normalizer = m_normalizerRegistry
- .getEquality( a_node.getAttribute() ) ;
- Comparator l_comparator = m_comparatorRegistry
- .getEquality( a_node.getAttribute() ) ;
+ Normalizer normalizer = normalizerRegistry.getEquality( node.getAttribute() );
+ Comparator comparator = comparatorRegistry.getEquality( node.getAttribute() );
/*
- * Get the attribute and if it is not set in a_rec then resusitate it
- * from the master table and set it in a_rec for use later if at all.
+ * Get the attribute and if it is not set in rec then resusitate it
+ * from the master table and set it in rec for use later if at all.
* Before iterating through all values for a match check to see if the
* AVA value is contained or the normalized form of the AVA value is
* contained.
*/
// resusitate entry if need be
- if ( null == a_rec.getAttributes() )
+ if ( null == rec.getAttributes() )
{
- a_rec.setAttributes( m_db.lookup( a_rec.getEntryId() ) ) ;
+ rec.setAttributes( db.lookup( rec.getEntryId() ) );
}
// get the attribute associated with the node
- Attribute l_attr = a_rec.getAttributes().get( a_node.getAttribute() ) ;
+ Attribute attr = rec.getAttributes().get( node.getAttribute() );
// If we do not have the attribute just return false
- if ( null == l_attr )
+ if ( null == attr )
{
- return false ;
+ return false;
}
// check if AVA value exists in attribute
- if ( l_attr.contains( a_node.getValue() ) )
+ if ( attr.contains( node.getValue() ) )
{
- return true ;
+ return true;
}
// get the normalized AVA filter value
- Object l_filterValue = l_normalizer.normalize( a_node.getValue() ) ;
+ Object filterValue = normalizer.normalize( node.getValue() );
// check if the normalized value is present
- if ( l_attr.contains( l_filterValue ) )
+ if ( attr.contains( filterValue ) )
{
- return true ;
+ return true;
}
/*
@@ -493,76 +277,18 @@
* a lookup to work. For each value we normalize and use the comparator
* to determine if a match exists.
*/
- NamingEnumeration l_list = l_attr.getAll() ;
- while ( l_list.hasMore() )
+ NamingEnumeration list = attr.getAll();
+ while ( list.hasMore() )
{
- Object l_value = l_normalizer.normalize( l_list.next() ) ;
+ Object value = normalizer.normalize( list.next() );
- if ( 0 == l_comparator.compare( l_value, l_filterValue ) )
+ if ( 0 == comparator.compare( value, filterValue ) )
{
- return true ;
+ return true;
}
}
// no match so return false
- return false ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_scopeEvaluator.enableDatabase( a_db ) ;
- m_substringEvaluator.enableDatabase( a_db ) ;
- }
-
-
- // ------------------------------------------------------------------------
- // AVALON LIFE-CYCLE METHODS
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.NormalizerRegistry"
- * key="normalizer-registry" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.ComparatorRegistry"
- * key="comparator-registry" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.SubstringEvaluator"
- * key="substring-evaluator" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.ScopeEvaluator"
- * key="scope-evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "Looking up normalizer-registry" ) ;
- m_normalizerRegistry = ( NormalizerRegistry ) a_manager
- .lookup( "normalizer-registry" ) ;
-
- getLogger().debug( "Looking up comparator-registry" ) ;
- m_comparatorRegistry = ( ComparatorRegistry ) a_manager
- .lookup( "comparator-registry" ) ;
-
- getLogger().debug( "Looking up substring-evaluator" ) ;
- m_substringEvaluator = ( SubstringEvaluatorImpl ) a_manager
- .lookup( "substring-evaluator" ) ;
-
- getLogger().debug( "Looking up scope-evaluator" ) ;
- m_scopeEvaluator = ( ScopeEvaluatorImpl ) a_manager
- .lookup( "scope-evaluator" ) ;
+ return false;
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/NegationEnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/NegationEnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/NegationEnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/NegationEnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,343 +1,79 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: NegationEnumeratorImpl.java,v 1.2 2003/10/15 01:59:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 13, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
+
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.LeafNode;
+import org.apache.ldap.common.filter.BranchNode;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.LeafNode ;
-import org.apache.ldap.common.filter.BranchNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.backend.db.index.IndexRecord;
+import org.apache.eve.db.*;
/**
* Creates a naming enumeration over the set of candidates accepted by a negated
* filter expression.
*
- * @avalon.component name="negation-enumerator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.NegationEnumerator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class NegationEnumeratorImpl extends AbstractLogEnabled
- implements NegationEnumerator, EnumeratorDependent, Serviceable
+public class NegationEnumeratorImpl implements NegationEnumerator
{
/** Database this conjunction is applied upon */
- private Database m_db = null ;
+ private Database db = null;
/** Top level expression evaluator */
- private Evaluator m_evaluator ;
- /** Top level expression enumerator - non Avalon dependency avaoids cycle */
- private Enumerator m_enumerator ;
+ private Evaluator evaluator;
+
+
+ /**
+ * Creates a negation branch node enumerator.
+ *
+ * @param db the database to use for enumerations
+ * @param evaluator the top level evaluator
+ */
+ public NegationEnumeratorImpl( Database db, Evaluator evaluator )
+ {
+ this.db = db;
+ this.evaluator = evaluator;
+ }
/**
- * @see org.apache.ldap.server.backend.db.search.Enumerator#enumerate(
- * org.apache.ldap.common.filter.ExprNode)
+ * @see Enumerator#enumerate(ExprNode)
*/
- public NamingEnumeration enumerate( ExprNode a_node )
- throws NamingException
+ public NamingEnumeration enumerate( ExprNode node ) throws NamingException
{
- Index l_idx = null ;
- final BranchNode l_node = ( BranchNode ) a_node ;
- NamingEnumeration l_childEnumeration = null ;
- NamingEnumeration l_enumeration = null ;
+ Index idx = null;
+ final BranchNode bnode = ( BranchNode ) node;
+ NamingEnumeration childEnumeration = null;
+ NamingEnumeration enumeration = null;
// Iterates over entire set of index values
- if ( l_node.getChild().isLeaf() )
+ if ( bnode.getChild().isLeaf() )
{
- LeafNode l_child = ( LeafNode ) l_node.getChild() ;
- l_idx = m_db.getUserIndex( l_child.getAttribute() ) ;
- l_childEnumeration = l_idx.listIndices() ;
+ LeafNode child = ( LeafNode ) bnode.getChild();
+ idx = db.getUserIndex( child.getAttribute() );
+ childEnumeration = idx.listIndices();
}
// Iterates over the entire set of entries
else
{
- l_idx = m_db.getNdnIndex() ;
- l_childEnumeration = l_idx.listIndices() ;
+ idx = db.getNdnIndex();
+ childEnumeration = idx.listIndices();
}
- IndexAssertion l_assertion = new IndexAssertion()
+ IndexAssertion assertion = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord a_rec )
- throws NamingException
+ public boolean assertCandidate( IndexRecord rec ) throws NamingException
{
// NOTICE THE ! HERE
// The candidate is valid if it does not pass assertion. A
// candidate that passes assertion is therefore invalid.
- return ! m_evaluator.evaluate( l_node.getChild(), a_rec ) ;
+ return ! evaluator.evaluate( bnode.getChild(), rec );
}
- } ;
+ };
- l_enumeration = new IndexAssertionEnumeration( l_childEnumeration,
- l_assertion, true ) ;
- return l_enumeration ;
+ enumeration = new IndexAssertionEnumeration( childEnumeration, assertion, true );
+ return enumeration;
}
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_evaluator.enableDatabase( a_db ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.search.EnumeratorDependent#
- * setEnumeratorDependency(org.apache.ldap.server.backend.db.search.Enumerator)
- */
- public void setEnumeratorDependency( Enumerator a_enumerator )
- {
- m_enumerator = a_enumerator ;
- }
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.Evaluator"
- * key="evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#
- * service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "looking up the evaluator" ) ;
- m_evaluator = ( EvaluatorImpl ) a_manager.lookup( "evaluator" ) ;
- }
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,290 +1,66 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: ScopeEnumeratorImpl.java,v 1.2 2003/10/15 01:59:46 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 11, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
+
+import java.math.BigInteger;
-import java.math.BigInteger ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchControls;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.SearchControls ;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.common.util.SingletonEnumeration ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.util.SingletonEnumeration;
+
+import org.apache.eve.db.*;
/**
* Enumerates candidates based on scope.
*
- * @avalon.component name="scope-enumerator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.ScopeEnumerator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class ScopeEnumeratorImpl extends AbstractLogEnabled
- implements ScopeEnumerator, Serviceable
+public class ScopeEnumeratorImpl implements ScopeEnumerator
{
/** Database used to enumerate based on scope */
- private Database m_db = null ;
+ private Database db = null;
/** Filter scope expression evaluator */
- private ScopeEvaluator m_evaluator = null ;
+ private ScopeEvaluator evaluator = null;
+
+
+ public ScopeEnumeratorImpl( Database db, ScopeEvaluator evaluator )
+ {
+ this.db = db;
+ this.evaluator = evaluator;
+ }
/**
* Builds an enumeration over all entries that satisfy the constraints of
* the scope assertion node.
*
- * @param a_node the scope node
+ * @param node the scope node
* @return the candidates that are within scope
* @throws NamingException if any system indices fail
- * @see org.apache.ldap.server.backend.db.search.Enumerator#enumerate(
- * org.apache.ldap.common.filter.ExprNode)
+ * @see Enumerator#enumerate(ExprNode)
*/
- public NamingEnumeration enumerate( ExprNode a_node )
- throws NamingException
+ public NamingEnumeration enumerate( ExprNode node ) throws NamingException
{
- final ScopeNode l_node = ( ScopeNode ) a_node ;
- final BigInteger l_id = m_db.getEntryId( l_node.getBaseDn() ) ;
+ final ScopeNode snode = ( ScopeNode ) node;
+ final BigInteger id = db.getEntryId( snode.getBaseDn() );
- switch( l_node.getScope() )
+ switch( snode.getScope() )
{
case( SearchControls.OBJECT_SCOPE ):
- final IndexRecord l_record = new IndexRecord() ;
- l_record.setEntryId( l_id ) ;
- l_record.setIndexKey( l_node.getBaseDn() ) ;
- return new SingletonEnumeration( l_record ) ;
+ final IndexRecord record = new IndexRecord();
+ record.setEntryId( id );
+ record.setIndexKey( snode.getBaseDn() );
+ return new SingletonEnumeration( record );
case( SearchControls.ONELEVEL_SCOPE ):
- return enumerateChildren( l_node.getBaseDn(),
- l_node.getDerefAliases().derefInSearching() ) ;
+ return enumerateChildren( snode.getBaseDn(),
+ snode.getDerefAliases().derefInSearching() );
case( SearchControls.SUBTREE_SCOPE ):
- return enumerateDescendants( l_node ) ;
+ return enumerateDescendants( snode );
default:
- throw new NamingException( "Unrecognized search scope!" ) ;
+ throw new NamingException( "Unrecognized search scope!" );
}
}
@@ -293,27 +69,27 @@
* Constructs an enumeration over all entries within one level scope even
* when aliases are enabled while searching.
*
- * @param a_dn the base dn
- * @param a_deref whether or not we dereference while searching
+ * @param dn the base dn
+ * @param deref whether or not we dereference while searching
* @return the enumeration of all entries in direct or alias extended one
* level scope to the base
* @throws NamingException if any failures occur while accessing system
* indices.
*/
- private NamingEnumeration enumerateChildren( String a_dn, boolean a_deref )
+ private NamingEnumeration enumerateChildren( String dn, boolean deref )
throws NamingException
{
- Index l_idx = m_db.getHeirarchyIndex() ;
- final BigInteger l_id = m_db.getEntryId( a_dn ) ;
- final NamingEnumeration l_children = l_idx.listIndices( l_id ) ;
+ Index idx = db.getHeirarchyIndex();
+ final BigInteger id = db.getEntryId( dn );
+ final NamingEnumeration children = idx.listIndices( id );
/*
* If alias dereferencing is not enabled while searching then we just
* return the enumeration of the base entry's children.
*/
- if ( ! a_deref )
+ if ( ! deref )
{
- return l_children ;
+ return children;
}
/* ====================================================================
@@ -328,16 +104,16 @@
*/
// List all entries brought into one level scope at base by aliases
- l_idx = m_db.getOneAliasIndex() ;
- NamingEnumeration l_aliasIntroduced = l_idx.listIndices( l_id ) ;
+ idx = db.getOneAliasIndex();
+ NamingEnumeration aliasIntroduced = idx.listIndices( id );
// Still need to use assertion enum to weed out aliases
- NamingEnumeration l_nonAliasChildren = new IndexAssertionEnumeration(
- l_children, new AssertNotAlias() ) ;
+ NamingEnumeration nonAliasChildren = new IndexAssertionEnumeration(
+ children, new AssertNotAlias() );
// Combine both into one enumeration
- NamingEnumeration [] l_all = {l_nonAliasChildren, l_aliasIntroduced} ;
- return new DisjunctionEnumeration( l_all ) ;
+ NamingEnumeration [] all = {nonAliasChildren, aliasIntroduced};
+ return new DisjunctionEnumeration( all );
}
@@ -345,146 +121,101 @@
* Constructs an enumeration over all entries within subtree scope even
* when aliases are enabled while searching.
*
- * @param a_node the scope node
+ * @param node the scope node
* @return the enumeration of all entries in direct or alias extended
* subtree scope to the base
* @throws NamingException if any failures occur while accessing system
* indices.
*/
- private NamingEnumeration enumerateDescendants( final ScopeNode a_node )
+ private NamingEnumeration enumerateDescendants( final ScopeNode node )
throws NamingException
{
- Index l_idx = null ;
- final BigInteger l_baseId = m_db.getEntryId( a_node.getBaseDn() ) ;
+ Index idx = null;
/*
* If we do not dereference while searching then we simply return any
* entry that is not a descendant of the base.
*/
- if ( ! a_node.getDerefAliases().derefInSearching() )
+ if ( ! node.getDerefAliases().derefInSearching() )
{
// Gets a NamingEnumeration over all elements
- l_idx = m_db.getNdnIndex() ;
- NamingEnumeration l_underlying = l_idx.listIndices() ;
- return new IndexAssertionEnumeration( l_underlying,
- new AssertDescendant( a_node ) ) ;
+ idx = db.getNdnIndex();
+ NamingEnumeration underlying = idx.listIndices();
+ return new IndexAssertionEnumeration( underlying,
+ new AssertDescendant( node ) );
}
// Create an assertion to assert or evaluate an expression
- IndexAssertion l_assertion = new IndexAssertion()
+ IndexAssertion assertion = new IndexAssertion()
{
- public boolean assertCandidate( IndexRecord a_rec )
+ public boolean assertCandidate( IndexRecord rec )
throws NamingException
{
- return m_evaluator.evaluate( a_node, a_rec ) ;
+ return evaluator.evaluate( node, rec );
}
- } ;
+ };
// Gets a NamingEnumeration over all elements
- l_idx = m_db.getNdnIndex() ;
- NamingEnumeration l_underlying = l_idx.listIndices() ;
- return new IndexAssertionEnumeration( l_underlying, l_assertion ) ;
+ idx = db.getNdnIndex();
+ NamingEnumeration underlying = idx.listIndices();
+ return new IndexAssertionEnumeration( underlying, assertion );
}
/**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- m_evaluator.enableDatabase( a_db ) ;
- }
-
-
- /**
* Asserts an entry is a descendant.
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
class AssertDescendant implements IndexAssertion
{
/** Scope node with base and alias info */
- private final ScopeNode m_scope ;
+ private final ScopeNode scope;
/**
* Creates a assertion using a ScopeNode to determine the search base.
*
- * @param a_node the scope node with search base
+ * @param node the scope node with search base
*/
- AssertDescendant( final ScopeNode a_node )
+ AssertDescendant( final ScopeNode node )
{
- m_scope = a_node ;
+ scope = node;
}
/**
- * Returns true if the candidate with a_id is a descendant of the base,
+ * Returns true if the candidate with id is a descendant of the base,
* false otherwise.
*
- * @see org.apache.ldap.server.backend.db.search.IndexAssertion#assertCandidate(
- * org.apache.ldap.server.backend.db.index.IndexRecord)
+ * @see IndexAssertion#assertCandidate(IndexRecord)
*/
- public boolean assertCandidate( IndexRecord a_record )
- throws NamingException
+ public boolean assertCandidate( IndexRecord record ) throws NamingException
{
- String l_dn = m_db.getEntryDn( a_record.getEntryId() ) ;
- return l_dn.endsWith( m_scope.getBaseDn() ) ;
+ String dn = db.getEntryDn( record.getEntryId() );
+ return dn.endsWith( scope.getBaseDn() );
}
}
/**
* Asserts an entry is NOT an alias.
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
class AssertNotAlias implements IndexAssertion
{
/**
* Returns true if the candidate is not an alias, false otherwise.
*
- * @see org.apache.ldap.server.backend.db.search.IndexAssertion#assertCandidate(
- * org.apache.ldap.server.backend.db.index.IndexRecord)
+ * @see IndexAssertion#assertCandidate(IndexRecord)
*/
- public boolean assertCandidate( IndexRecord a_record )
- throws NamingException
+ public boolean assertCandidate( IndexRecord record ) throws NamingException
{
- Index l_aliasIdx = m_db.getAliasIndex() ;
+ Index aliasIdx = db.getAliasIndex();
- if ( null == l_aliasIdx.reverseLookup( a_record.getEntryId() ) )
+ if ( null == aliasIdx.reverseLookup( record.getEntryId() ) )
{
- return true ;
+ return true;
}
- return false ;
+ return false;
}
}
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.ScopeEvaluator"
- * key="scope-evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#
- * service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "looking up the scope-evaluator" ) ;
- m_evaluator = ( ScopeEvaluator ) a_manager.lookup( "scope-evaluator" ) ;
- }
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEvaluatorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEvaluatorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/ScopeEvaluatorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/ScopeEvaluatorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,207 +1,207 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright [yyyy] [name of copyright owner]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
/*
* $Id: ScopeEvaluatorImpl.java,v 1.3 2003/10/15 01:59:46 akarasulu Exp $
@@ -212,72 +212,64 @@
*
* Created on Oct 9, 2003
*/
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
+
+import java.math.BigInteger;
-import java.math.BigInteger ;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
-import javax.naming.NamingException ;
-import javax.naming.directory.SearchControls ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.ScopeNode;
+import org.apache.ldap.common.message.DerefAliasesEnum;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.ScopeNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.backend.db.index.IndexRecord;
-import org.apache.ldap.common.message.DerefAliasesEnum ;
-import org.apache.ldap.server.schema.matching.ComparatorRegistry ;
-import org.apache.ldap.server.schema.matching.NormalizerRegistry ;
+import org.apache.eve.db.Index;
+import org.apache.eve.db.Database;
+import org.apache.eve.db.IndexRecord;
+import org.apache.eve.db.ScopeEvaluator;
/**
* Evaluates ScopeNode assertions on candidates using a database.
*
- * @avalon.component name="scope-evaluator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.ScopeEvaluator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.3 $
*/
-public class ScopeEvaluatorImpl extends AbstractLogEnabled
- implements Serviceable, ScopeEvaluator
+public class ScopeEvaluatorImpl implements ScopeEvaluator
{
- /** Database used to evaluate leaf with */
- private Database m_db ;
- /** Normalizer registry for up value normalization */
- private NormalizerRegistry m_normalizerRegistry ;
- /** Comparator registry for comparing normalized values */
- private ComparatorRegistry m_comparatorRegistry ;
+ /** Database used to evaluate scope with */
+ private Database db;
+
-
/**
- * @see org.apache.ldap.server.backend.db.search.Evaluator#evaluate(
- * org.apache.ldap.common.filter.ExprNode, org.apache.ldap.server.backend.db.index.IndexRecord)
+ * Creates a scope node evaluator for search expressions.
+ *
+ * @param db the database used to evaluate scope node
*/
- public boolean evaluate( ExprNode a_node, IndexRecord a_record )
+ public ScopeEvaluatorImpl( Database db )
+ {
+ this.db = db;
+ }
+
+
+ /**
+ * @see org.apache.eve.db.Evaluator#evaluate(ExprNode, IndexRecord)
+ */
+ public boolean evaluate( ExprNode node, IndexRecord record )
throws NamingException
{
- ScopeNode l_node = ( ScopeNode ) a_node ;
+ ScopeNode snode = ( ScopeNode ) node;
- switch( l_node.getScope() )
+ switch( snode.getScope() )
{
case( SearchControls.OBJECT_SCOPE ):
- String l_dn = m_db.getEntryDn( a_record.getEntryId() ) ;
- return l_dn.equals( l_node.getBaseDn() ) ;
+ String dn = db.getEntryDn( record.getEntryId() );
+ return dn.equals( snode.getBaseDn() );
case( SearchControls.ONELEVEL_SCOPE ):
- return assertOneLevelScope( l_node, a_record.getEntryId() ) ;
+ return assertOneLevelScope( snode, record.getEntryId() );
case( SearchControls.SUBTREE_SCOPE ):
- return assertSubtreeScope( l_node, a_record.getEntryId() ) ;
+ return assertSubtreeScope( snode, record.getEntryId() );
default:
- throw new NamingException( "Unrecognized search scope!" ) ;
+ throw new NamingException( "Unrecognized search scope!" );
}
}
@@ -286,65 +278,65 @@
* Asserts whether or not a candidate has one level scope while taking
* alias dereferencing into account.
*
- * @param a_node the scope node containing the base and alias handling mode
- * @param a_id the candidate to assert which can be any db entry's id
+ * @param node the scope node containing the base and alias handling mode
+ * @param id the candidate to assert which can be any db entry's id
* @return true if the candidate is within one level scope whether or not
* alias dereferencing is enabled.
* @throws NamingException if the index lookups fail.
*/
- public boolean assertSubtreeScope( final ScopeNode a_node,
- final BigInteger a_id ) throws NamingException
+ public boolean assertSubtreeScope( final ScopeNode node,
+ final BigInteger id ) throws NamingException
{
- String l_dn = m_db.getEntryDn( a_id ) ;
- DerefAliasesEnum l_mode = a_node.getDerefAliases() ;
- Object l_baseId = m_db.getEntryId( a_node.getBaseDn() ) ;
- boolean l_isDescendant = l_dn.endsWith( a_node.getBaseDn() ) ;
+ String dn = db.getEntryDn( id );
+ DerefAliasesEnum mode = node.getDerefAliases();
+ Object baseId = db.getEntryId( node.getBaseDn() );
+ boolean isDescendant = dn.endsWith( node.getBaseDn() );
/*
- * The candidate a_id could be any entry in the db. If search
+ * The candidate id could be any entry in the db. If search
* dereferencing is not enabled then we return the results of the
* descendant test.
*/
- if ( ! l_mode.derefInSearching() )
+ if ( ! mode.derefInSearching() )
{
- return l_isDescendant ;
+ return isDescendant;
}
/*
* From here down alias dereferencing is enabled. We determine if the
- * candidate a_id is an alias, if so we reject it since aliases should
+ * candidate id is an alias, if so we reject it since aliases should
* not be returned.
*/
- Index l_idx = m_db.getAliasIndex() ;
- if ( null != l_idx.reverseLookup( a_id ) )
+ Index idx = db.getAliasIndex();
+ if ( null != idx.reverseLookup( id ) )
{
- return false ;
+ return false;
}
/*
* The candidate is NOT an alias at this point. So if it is a
* descendant we just return it since it is in normal subtree scope.
*/
- if ( l_isDescendant )
+ if ( isDescendant )
{
- return true ;
+ return true;
}
/*
* At this point the candidate is not a descendant and it is not an
* alias. We need to check if the candidate is in extended subtree
* scope by performing a lookup on the subtree alias index. This index
- * stores a tuple mapping the l_baseId to the ids of objects brought
+ * stores a tuple mapping the baseId to the ids of objects brought
* into subtree scope of the base by an alias:
*
- * ( l_baseId, l_aliasedObjId )
+ * ( baseId, aliasedObjId )
*
- * If the candidate a_id is an object brought into subtree scope then
+ * If the candidate id is an object brought into subtree scope then
* the lookup returns true accepting the candidate. Otherwise the
* candidate is rejected with a false return because it is not in scope.
*/
- l_idx = m_db.getSubAliasIndex() ;
- return l_idx.hasValue( l_baseId, a_id ) ;
+ idx = db.getSubAliasIndex();
+ return idx.hasValue( baseId, id );
}
@@ -352,101 +344,61 @@
* Asserts whether or not a candidate has one level scope while taking
* alias dereferencing into account.
*
- * @param a_node the scope node containing the base and alias handling mode
- * @param a_id the candidate to assert which can be any db entry's id
+ * @param node the scope node containing the base and alias handling mode
+ * @param id the candidate to assert which can be any db entry's id
* @return true if the candidate is within one level scope whether or not
* alias dereferencing is enabled.
* @throws NamingException if the index lookups fail.
*/
- public boolean assertOneLevelScope( final ScopeNode a_node,
- final BigInteger a_id ) throws NamingException
+ public boolean assertOneLevelScope( final ScopeNode node,
+ final BigInteger id ) throws NamingException
{
- DerefAliasesEnum l_mode = a_node.getDerefAliases() ;
- Object l_baseId = m_db.getEntryId( a_node.getBaseDn() ) ;
- Index l_idx = m_db.getHeirarchyIndex() ;
- boolean l_isChild = l_idx.hasValue( l_baseId, a_id ) ;
+ DerefAliasesEnum mode = node.getDerefAliases();
+ Object baseId = db.getEntryId( node.getBaseDn() );
+ Index idx = db.getHeirarchyIndex();
+ boolean isChild = idx.hasValue( baseId, id );
/*
- * The candidate a_id could be any entry in the db. If search
+ * The candidate id could be any entry in the db. If search
* dereferencing is not enabled then we return the results of the child
* test.
*/
- if ( ! l_mode.derefInSearching() )
+ if ( ! mode.derefInSearching() )
{
- return l_isChild ;
+ return isChild;
}
/*
* From here down alias dereferencing is enabled. We determine if the
- * candidate a_id is an alias, if so we reject it since aliases should
+ * candidate id is an alias, if so we reject it since aliases should
* not be returned.
*/
- l_idx = m_db.getAliasIndex() ;
- if ( null != l_idx.reverseLookup( a_id ) )
+ idx = db.getAliasIndex();
+ if ( null != idx.reverseLookup( id ) )
{
- return false ;
+ return false;
}
/*
* The candidate is NOT an alias at this point. So if it is a child we
* just return it since it is in normal one level scope.
*/
- if ( l_isChild )
+ if ( isChild )
{
- return true ;
+ return true;
}
/*
* At this point the candidate is not a child and it is not an alias.
* We need to check if the candidate is in extended one level scope by
* performing a lookup on the one level alias index. This index stores
- * a tuple mapping the l_baseId to the id of objects brought into the
- * one level scope of the base by an alias: ( l_baseId, l_aliasedObjId )
- * If the candidate a_id is an object brought into one level scope then
+ * a tuple mapping the baseId to the id of objects brought into the
+ * one level scope of the base by an alias: ( baseId, aliasedObjId )
+ * If the candidate id is an object brought into one level scope then
* the lookup returns true accepting the candidate. Otherwise the
* candidate is rejected with a false return because it is not in scope.
*/
- l_idx = m_db.getOneAliasIndex() ;
- return l_idx.hasValue( l_baseId, a_id ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- }
-
-
- // ------------------------------------------------------------------------
- // AVALON LIFE-CYCLE METHODS
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.NormalizerRegistry"
- * key="normalizer-registry" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.ComparatorRegistry"
- * key="comparator-registry" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "Looking up normalizer-registry" ) ;
- m_normalizerRegistry = ( NormalizerRegistry ) a_manager
- .lookup( "normalizer-registry" ) ;
-
- getLogger().debug( "Looking up comparator-registry" ) ;
- m_comparatorRegistry = ( ComparatorRegistry ) a_manager
- .lookup( "comparator-registry" ) ;
+ idx = db.getOneAliasIndex();
+ return idx.hasValue( baseId, id );
}
}
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEnumeratorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEnumeratorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEnumeratorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEnumeratorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,207 +1,207 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright [yyyy] [name of copyright owner]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
/*
* $Id: SubstringEnumeratorImpl.java,v 1.2 2003/10/17 00:10:46 akarasulu Exp $
@@ -212,66 +212,64 @@
*
* Created on Oct 13, 2003
*/
-package org.apache.ldap.server.backend.db.search ;
+package org.apache.eve.db.jdbm;
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
-import org.apache.regexp.RE ;
-import org.apache.regexp.RESyntaxException ;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.common.filter.SubstringNode ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.SubstringNode;
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
+import org.apache.eve.db.*;
/**
* Enumerator that creates a NamingEnumeration over the set of candidates that
* satisfy a substring filter expression.
*
- * @avalon.component name="substring-enumerator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.SubstringEnumerator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.2 $
*/
-public class SubstringEnumeratorImpl extends AbstractLogEnabled
- implements SubstringEnumerator, Serviceable
+public class SubstringEnumeratorImpl implements SubstringEnumerator
{
/** Database used */
- private Database m_db = null ;
+ private Database db = null;
/** Evaluator used is an Avalon dependent object */
- private SubstringEvaluator m_evaluator = null ;
-
-
+ private SubstringEvaluator evaluator = null;
+
+
+ /**
+ * Creates a SubstringEnumerator for a database.
+ *
+ * @param db the database
+ * @param evaluator a substring evaluator
+ */
+ public SubstringEnumeratorImpl( Database db, SubstringEvaluator evaluator )
+ {
+ this.db = db;
+ this.evaluator = evaluator;
+ }
+
+
// ------------------------------------------------------------------------
// SubstringEnumerator Methods
// ------------------------------------------------------------------------
/**
- * @see org.apache.ldap.server.backend.db.search.Enumerator#enumerate(
+ * @see Enumerator#enumerate(
* org.apache.ldap.common.filter.ExprNode)
*/
- public NamingEnumeration enumerate( final ExprNode a_node )
+ public NamingEnumeration enumerate( final ExprNode node )
throws NamingException
{
- RE l_regex = null ;
- Index l_idx = null ;
- final SubstringNode l_node = ( SubstringNode ) a_node ;
+ RE regex = null;
+ Index idx = null;
+ final SubstringNode snode = ( SubstringNode ) node;
- if ( m_db.hasUserIndexOn( l_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( snode.getAttribute() ) )
{
/*
* Build out regex in this block so we do not do it twice in the
@@ -279,14 +277,14 @@
*/
try
{
- l_regex = l_node.getRegex() ;
+ regex = snode.getRegex();
}
catch ( RESyntaxException e )
{
- NamingException l_ne = new NamingException( "SubstringNode '"
- + a_node + "' had incorrect syntax" ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException( "SubstringNode '"
+ + node + "' had incorrect syntax" );
+ ne.setRootCause( e );
+ throw ne;
}
/*
@@ -294,14 +292,14 @@
* compiled regular expression. Try to constrain even further if
* an initial term is available in the substring expression.
*/
- l_idx = m_db.getUserIndex( l_node.getAttribute() ) ;
- if ( null == l_node.getInitial() )
+ idx = db.getUserIndex( snode.getAttribute() );
+ if ( null == snode.getInitial() )
{
- return l_idx.listIndices( l_regex ) ;
+ return idx.listIndices( regex );
}
else
{
- return l_idx.listIndices( l_regex, l_node.getInitial() ) ;
+ return idx.listIndices( regex, snode.getInitial() );
}
}
@@ -314,47 +312,15 @@
* underlying enumeration. An evaluator in an assertion is used to
* constrain the result set.
*/
- NamingEnumeration l_underlying = m_db.getNdnIndex().listIndices() ;
- IndexAssertion l_assertion = new IndexAssertion()
+ NamingEnumeration underlying = db.getNdnIndex().listIndices();
+ IndexAssertion assertion = new IndexAssertion()
{
- public boolean assertCandidate( final IndexRecord a_record )
- throws NamingException
+ public boolean assertCandidate( final IndexRecord record ) throws NamingException
{
- return m_evaluator.evaluate( a_node, a_record ) ;
+ return evaluator.evaluate( node, record );
}
- } ;
+ };
- return new IndexAssertionEnumeration( l_underlying, l_assertion ) ;
- }
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
- {
- m_db = a_db ;
- }
-
-
- // ------------------------------------------------------------------------
- // A V A L O N L I F E - C Y C L E M E T H O D S
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.backend.db.search.SubstringEvaluator"
- * key="substring-evaluator" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- m_evaluator = ( SubstringEvaluator ) a_manager
- .lookup( "substring-evaluator" ) ;
+ return new IndexAssertionEnumeration( underlying, assertion );
}
-}
+}
\ No newline at end of file
Copied: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEvaluatorImpl.java (from rev 47436, incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEvaluatorImpl.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/sandbox/backend-database-impl/src/java/org/apache/ldap/server/backend/db/search/SubstringEvaluatorImpl.java (original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/jdbm/SubstringEvaluatorImpl.java Wed Sep 29 19:00:03 2004
@@ -1,292 +1,56 @@
-/*
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright [yyyy] [name of copyright owner]
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*
- * $Id: SubstringEvaluatorImpl.java,v 1.4 2003/10/17 01:08:56 akarasulu Exp $
- *
- * -- (c) LDAPd Group --
- * -- Please refer to the LICENSE.txt file in the root directory of --
- * -- any LDAPd project for copyright and distribution information. --
- *
- * Created on Oct 9, 2003
- */
-package org.apache.ldap.server.backend.db.search ;
-
-
-import java.util.Comparator ;
-
-import javax.naming.NamingException ;
-import javax.naming.NamingEnumeration ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.Attributes ;
-
-import org.apache.avalon.framework.service.Serviceable ;
-import org.apache.avalon.framework.service.ServiceManager ;
-import org.apache.avalon.framework.service.ServiceException ;
-import org.apache.avalon.framework.logger.AbstractLogEnabled ;
-
-import org.apache.regexp.RE ;
-import org.apache.regexp.RESyntaxException ;
+package org.apache.eve.db.jdbm;
-import org.apache.ldap.common.filter.ExprNode ;
-import org.apache.ldap.common.filter.SubstringNode ;
-import org.apache.ldap.server.backend.db.Database ;
-import org.apache.ldap.server.backend.db.index.Index ;
-import org.apache.ldap.server.schema.matching.Normalizer ;
-import org.apache.ldap.server.backend.db.index.IndexRecord ;
-import org.apache.ldap.server.schema.matching.ComparatorRegistry ;
-import org.apache.ldap.server.schema.matching.NormalizerRegistry ;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.schema.Normalizer;
+import org.apache.ldap.common.filter.SubstringNode;
+
+import org.apache.eve.db.Index;
+import org.apache.eve.db.Database;
+import org.apache.eve.db.IndexRecord;
+import org.apache.eve.db.SubstringEvaluator;
+import org.apache.eve.schema.NormalizerRegistry;
/**
* Evaluates substring filter assertions on an entry.
*
- * @avalon.component name="substring-evaluator" lifestyle="transient"
- *
- * @avalon.service type="org.apache.ldap.server.backend.db.search.SubstringEvaluator"
- * version="1.0"
- *
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.4 $
*/
-public class SubstringEvaluatorImpl extends AbstractLogEnabled
- implements Serviceable, SubstringEvaluator
+public class SubstringEvaluatorImpl implements SubstringEvaluator
{
/** Database used while evaluating candidates */
- private Database m_db ;
+ private Database db;
/** Normalizer registry for up value normalization */
- private NormalizerRegistry m_normalizerRegistry ;
- /** Comparator registry for comparing normalized values */
- private ComparatorRegistry m_comparatorRegistry ;
-
-
- /**
- * @see org.apache.ldap.server.backend.db.DatabaseEnabled#enableDatabase(
- * org.apache.ldap.server.backend.db.Database)
- */
- public void enableDatabase( Database a_db )
+ private NormalizerRegistry normalizerRegistry;
+
+
+ public SubstringEvaluatorImpl( Database db, NormalizerRegistry normReg )
{
- m_db = a_db ;
+ this.db = db;
+ this.normalizerRegistry = normReg;
}
-
-
+
+
/**
- * @see org.apache.ldap.server.backend.db.search.Evaluator#evaluate(
- * org.apache.ldap.common.filter.ExprNode, org.apache.ldap.server.backend.db.index.IndexRecord)
+ * @see org.apache.eve.db.Evaluator#evaluate(ExprNode, IndexRecord)
*/
- public boolean evaluate( ExprNode a_node, IndexRecord a_record )
+ public boolean evaluate( ExprNode node, IndexRecord record )
throws NamingException
{
- RE l_regex = null ;
- SubstringNode l_node = ( SubstringNode ) a_node ;
+ RE regex = null;
+ SubstringNode snode = ( SubstringNode ) node;
- if ( m_db.hasUserIndexOn( l_node.getAttribute() ) )
+ if ( db.hasUserIndexOn( snode.getAttribute() ) )
{
- Index l_idx = m_db.getUserIndex( l_node.getAttribute() ) ;
+ Index idx = db.getUserIndex( snode.getAttribute() );
/*
* Note that this is using the reverse half of the index giving a
@@ -295,76 +59,72 @@
* no reverse lookups.
*/
- NamingEnumeration l_list = l_idx
- .listReverseIndices( a_record.getEntryId() ) ;
+ NamingEnumeration list = idx.listReverseIndices( record.getEntryId() );
// compile the regular expression to search for a matching attribute
try
{
- l_regex = l_node.getRegex() ;
+ regex = snode.getRegex();
}
catch ( RESyntaxException e )
{
- NamingException l_ne = new NamingException( "SubstringNode '"
- + a_node + "' had " + "incorrect syntax" ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException( "SubstringNode '"
+ + node + "' had " + "incorrect syntax" );
+ ne.setRootCause( e );
+ throw ne;
}
// cycle through the attribute values testing for a match
- while ( l_list.hasMore() )
+ while ( list.hasMore() )
{
- IndexRecord l_rec = ( IndexRecord ) l_list.next() ;
+ IndexRecord rec = ( IndexRecord ) list.next();
// once match is found cleanup and return true
- if ( l_regex.match( ( String ) l_rec.getIndexKey() ) )
+ if ( regex.match( ( String ) rec.getIndexKey() ) )
{
- l_list.close() ;
- return true ;
+ list.close();
+ return true;
}
}
// we fell through so a match was not found - assertion was false.
- return false ;
+ return false;
}
// --------------------------------------------------------------------
// Index not defined beyond this point
// --------------------------------------------------------------------
- Attribute l_attr = null ;
- Normalizer l_normalizer =
- m_normalizerRegistry.getSubstring( l_node.getAttribute() ) ;
- Comparator l_comparator =
- m_comparatorRegistry.getSubstring( l_node.getAttribute() ) ;
-
+ Attribute attr = null;
+ Normalizer normalizer = normalizerRegistry.getSubstring( snode.getAttribute() );
+
// resusitate the entry if it has not been and set entry in IndexRecord
- if ( null == a_record.getAttributes() )
+ if ( null == record.getAttributes() )
{
- Attributes l_attrs = m_db.lookup( a_record.getEntryId() ) ;
- a_record.setAttributes( l_attrs ) ;
+ Attributes attrs = db.lookup( record.getEntryId() );
+ record.setAttributes( attrs );
}
// get the attribute
- l_attr = a_record.getAttributes().get( l_node.getAttribute() ) ;
+ attr = record.getAttributes().get( snode.getAttribute() );
// if the attribute does not exist just return false
- if ( null == l_attr )
+ if ( null == attr )
{
- return false ;
+ return false;
}
// compile the regular expression to search for a matching attribute
try
{
- l_regex = l_node.getRegex() ;
+ regex = snode.getRegex();
}
catch ( RESyntaxException e )
{
- NamingException l_ne = new NamingException( "SubstringNode '"
- + a_node + "' had " + "incorrect syntax" ) ;
- l_ne.setRootCause( e ) ;
- throw l_ne ;
+ NamingException ne = new NamingException( "SubstringNode '"
+ + node + "' had " + "incorrect syntax" );
+ ne.setRootCause( e );
+ throw ne;
}
/*
@@ -373,51 +133,21 @@
* The test uses the comparator obtained from the appropriate
* substring matching rule.
*/
- NamingEnumeration l_list = l_attr.getAll() ;
- while ( l_list.hasMore() )
+ NamingEnumeration list = attr.getAll();
+ while ( list.hasMore() )
{
- String l_value = ( String )
- l_normalizer.normalize( l_list.next() ) ;
+ String value = ( String )
+ normalizer.normalize( list.next() );
// Once match is found cleanup and return true
- if ( l_regex.match( l_value ) )
+ if ( regex.match( value ) )
{
- l_list.close() ;
- return true ;
+ list.close();
+ return true;
}
}
// we fell through so a match was not found - assertion was false.
- return false ;
- }
-
-
- // ------------------------------------------------------------------------
- // AVALON LIFE-CYCLE METHODS
- // ------------------------------------------------------------------------
-
-
- /**
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.NormalizerRegistry"
- * key="normalizer-registry" version="1.0"
- *
- * @avalon.dependency
- * type="org.apache.ldap.server.schema.matching.ComparatorRegistry"
- * key="comparator-registry" version="1.0"
- *
- * @see org.apache.avalon.framework.service.Serviceable#service(
- * org.apache.avalon.framework.service.ServiceManager)
- */
- public void service( ServiceManager a_manager )
- throws ServiceException
- {
- getLogger().debug( "Looking up normalizer-registry" ) ;
- m_normalizerRegistry = ( NormalizerRegistry ) a_manager
- .lookup( "normalizer-registry" ) ;
-
- getLogger().debug( "Looking up comparator-registry" ) ;
- m_comparatorRegistry = ( ComparatorRegistry ) a_manager
- .lookup( "comparator-registry" ) ;
+ return false;
}
}