directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r575783 [1/4] - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ apacheds/trunk/core/src/main/java/org/apache/directory/server...
Date Fri, 14 Sep 2007 20:15:03 GMT
Author: elecharny
Date: Fri Sep 14 13:14:59 2007
New Revision: 575783

URL: http://svn.apache.org/viewvc?rev=575783&view=rev
Log:
o Modified the Filter inheritence tree by adding new specialized classes :
- AndNode, orNode, NotNode
- PresenceNode, ApproximativeNode, LesserEqNode, GreaterEqNode, SubstringNode

o Using StringBuilder instead of StringBuffer

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SearchEngine.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/sp/LdapClassLoader.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
    directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
    directory/shared/trunk/ldap/src/main/antlr/filter-parser.g
    directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecification.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitorTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/FilterParserImplTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java Fri Sep 14 13:14:59 2007
@@ -32,9 +32,9 @@
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.constants.ServerDNConstants;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
 import org.apache.directory.shared.ldap.filter.BranchNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -130,9 +130,9 @@
         // search all naming contexts for static groups and generate
         // normalized sets of members to cache within the map
 
-        BranchNode filter = new BranchNode( AssertionEnum.OR );
-        filter.addNode( new SimpleNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.GROUP_OF_NAMES_OC, AssertionEnum.EQUALITY ) );
-        filter.addNode( new SimpleNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.GROUP_OF_UNIQUE_NAMES_OC, AssertionEnum.EQUALITY ) );
+        BranchNode filter = new OrNode();
+        filter.addNode( new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.GROUP_OF_NAMES_OC ) );
+        filter.addNode( new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.GROUP_OF_UNIQUE_NAMES_OC) );
 
         Iterator<String> suffixes = nexus.listSuffixes( null );
         

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java Fri Sep 14 13:14:59 2007
@@ -47,9 +47,8 @@
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -135,7 +134,7 @@
         {
             String suffix = suffixes.next();
             LdapDN baseDn = parseNormalized( suffix );
-            ExprNode filter = new SimpleNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC, AssertionEnum.EQUALITY );
+            ExprNode filter = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC );
             SearchControls ctls = new SearchControls();
             ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             NamingEnumeration<SearchResult> results = 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventService.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventService.java Fri Sep 14 13:14:59 2007
@@ -59,10 +59,11 @@
 import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.message.DerefAliasesEnum;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
@@ -156,9 +157,9 @@
             }
 
             // Now for AND & OR nodes with a single child left replace them with their child
-            if ( child.getChildren().size() == 1 && child.getOperator() != AssertionEnum.NOT )
+            if ( child.getChildren().size() == 1 && ! ( child instanceof NotNode ) )
             {
-                filter = child.getChild();
+                filter = child.getFirstChild();
             }
         }
         
@@ -168,7 +169,7 @@
         
         if ( filter != null )
         {
-            BranchNode and = new BranchNode( AssertionEnum.AND );
+            BranchNode and = new AndNode();
             and.addNode( scope );
             and.addNode( filter );
             filter = and;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java Fri Sep 14 13:14:59 2007
@@ -20,15 +20,16 @@
 package org.apache.directory.server.core.event;
 
 
-import java.util.Iterator;
-
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 
 
 
@@ -102,46 +103,42 @@
 
         BranchNode bnode = ( BranchNode ) node;
 
-        switch ( bnode.getOperator() )
+        if ( bnode instanceof OrNode )
         {
-            case OR :
-                Iterator children = bnode.getChildren().iterator();
-
-                while ( children.hasNext() )
+            for ( ExprNode child: bnode.getChildren() )
+            {
+                if ( evaluate( child, dn, entry ) )
                 {
-                    ExprNode child = ( ExprNode ) children.next();
-
-                    if ( evaluate( child, dn, entry ) )
-                    {
-                        return true;
-                    }
+                    return true;
                 }
+            }
 
-                return false;
-                
-            case AND :
-                children = bnode.getChildren().iterator();
-                while ( children.hasNext() )
+            return false;
+        }
+        else if ( bnode instanceof AndNode )
+        {
+            for ( ExprNode child: bnode.getChildren() )
+            {
+                if ( !evaluate( child, dn, entry ) )
                 {
-                    ExprNode child = ( ExprNode ) children.next();
-
-                    if ( !evaluate( child, dn, entry ) )
-                    {
-                        return false;
-                    }
+                    return false;
                 }
+            }
 
-                return true;
-                
-            case NOT :
-                if ( null != bnode.getChild() )
-                {
-                    return !evaluate( bnode.getChild(), dn, entry );
-                }
+            return true;
+        }
+        else if ( bnode instanceof NotNode )
+        {
+            if ( null != bnode.getFirstChild() )
+            {
+                return !evaluate( bnode.getFirstChild(), dn, entry );
+            }
 
-                throw new NamingException( "Negation has no child: " + node );
-            default:
-                throw new NamingException( "Unrecognized branch node operator: " + bnode.getOperator() );
+            throw new NamingException( "Negation has no child: " + node );
+        }
+        else
+        {
+                throw new NamingException( "Unrecognized branch node operator: " + bnode );
         }
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java Fri Sep 14 13:14:59 2007
@@ -30,11 +30,16 @@
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
@@ -64,6 +69,10 @@
     private SubstringEvaluator substringEvaluator;
     /** ScopeNode evaluator we depend on */
     private ScopeEvaluator scopeEvaluator;
+    
+    /** Constants used for comparisons */
+    private static final boolean COMPARE_GREATER = true;
+    private static final boolean COMPARE_LESSER = false;
 
 
     /**
@@ -103,32 +112,34 @@
             return scopeEvaluator.evaluate( node, dn, entry );
         }
 
-        switch ( ( ( LeafNode ) node ).getAssertionType() )
+        if ( node instanceof PresenceNode )
         {
-            case APPROXIMATE :
-                return evalEquality( ( SimpleNode ) node, entry );
-                
-            case EQUALITY :
-                return evalEquality( ( SimpleNode ) node, entry );
-                
-            case EXTENSIBLE :
-                throw new NotImplementedException();
-                
-            case GREATEREQ :
-                return evalGreater( ( SimpleNode ) node, entry, true );
-                
-            case LESSEQ :
-                return evalGreater( ( SimpleNode ) node, entry, false );
-                
-            case PRESENCE :
-                String attrId = ( ( PresenceNode ) node ).getAttribute();
-                return evalPresence( attrId, entry );
-                
-            case SUBSTRING :
-                return substringEvaluator.evaluate( node, dn, entry );
-                
-            default:
-                throw new NamingException( "Unrecognized leaf node type: " + ( ( LeafNode ) node ).getAssertionType() );
+            String attrId = ((PresenceNode)node).getAttribute();
+            return evalPresence( attrId, entry );
+        }
+        else if ( ( node instanceof EqualityNode ) || ( node instanceof ApproximateNode ) )
+        {
+        	return evalEquality( ( EqualityNode ) node, entry );
+        }
+        else if ( node instanceof GreaterEqNode )
+        {
+        	return evalGreaterOrLesser( ( GreaterEqNode ) node, entry, COMPARE_GREATER );
+        }
+        else if ( node instanceof LessEqNode )
+        {
+        	return evalGreaterOrLesser( ( LessEqNode ) node, entry, COMPARE_LESSER );
+        }
+        else if ( node instanceof SubstringNode )
+        {
+        	return substringEvaluator.evaluate( node, dn, entry );
+        }
+        else if ( node instanceof ExtensibleNode )
+        {
+        	throw new NotImplementedException();
+        }
+        else
+        {
+        	throw new NamingException( "Unrecognized leaf node type: " + node );
         }
     }
 
@@ -144,7 +155,7 @@
      * @return the ava evaluation on the perspective candidate
      * @throws javax.naming.NamingException if there is a database access failure
      */
-    private boolean evalGreater( SimpleNode node, Attributes entry, boolean isGreater ) throws NamingException
+    private boolean evalGreaterOrLesser( SimpleNode node, Attributes entry, boolean isGreaterOrLesser ) throws NamingException
     {
         String attrId = node.getAttribute();
 
@@ -171,7 +182,7 @@
          * Cheaper to not check isGreater in one loop - better to separate
          * out into two loops which you choose to execute based on isGreater
          */
-        if ( isGreater )
+        if ( isGreaterOrLesser == COMPARE_GREATER )
         {
             while ( list.hasMore() )
             {
@@ -232,7 +243,7 @@
      * @return the ava evaluation on the perspective candidate
      * @throws javax.naming.NamingException if there is a database access failure
      */
-    private boolean evalEquality( SimpleNode node, Attributes entry ) throws NamingException
+    private boolean evalEquality( EqualityNode node, Attributes entry ) throws NamingException
     {
         Normalizer normalizer = getNormalizer( node.getAttribute() );
         Comparator comparator = getComparator( node.getAttribute() );
@@ -268,6 +279,7 @@
          * to determine if a match exists.
          */
         NamingEnumeration list = attr.getAll();
+        
         while ( list.hasMore() )
         {
             Object value = normalizer.normalize( list.next() );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java Fri Sep 14 13:14:59 2007
@@ -69,7 +69,7 @@
     public boolean evaluate( ExprNode node, String dn, Attributes entry ) throws NamingException
     {
         Pattern regex = null;
-        SubstringNode snode = ( SubstringNode ) node;
+        SubstringNode snode = (SubstringNode)node;
         String oid = oidRegistry.getOid( snode.getAttribute() );
         AttributeType type = attributeTypeRegistry.lookup( oid );
         Normalizer normalizer = type.getSubstr().getNormalizer();

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Fri Sep 14 13:14:59 2007
@@ -48,8 +48,9 @@
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexusProxy;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParserImpl;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
@@ -558,11 +559,11 @@
                 
                 if ( value instanceof byte[] )
                 {
-                    node = new SimpleNode( attr.getID(), ( byte [] ) value, AssertionEnum.EQUALITY );
+                    node = new EqualityNode( attr.getID(), ( byte [] ) value );
                 }
                 else 
                 {
-                    node = new SimpleNode( attr.getID(), ( String ) value, AssertionEnum.EQUALITY );
+                    node = new EqualityNode( attr.getID(), ( String ) value );
                 }
 
                 return doSearchOperation( target, getEnvironment(), node, ctls );
@@ -575,7 +576,7 @@
          */
         Attribute attr;
         SimpleNode node;
-        BranchNode filter = new BranchNode( AssertionEnum.AND );
+        BranchNode filter = new AndNode();
         NamingEnumeration list = matchingAttributes.getAll();
 
         // Loop through each attribute value pair
@@ -605,7 +606,7 @@
                 // Add simpel AVA node if its value is a String 
                 if ( val instanceof String )
                 {
-                    node = new SimpleNode( attr.getID(), ( String ) val, AssertionEnum.EQUALITY );
+                    node = new EqualityNode( attr.getID(), ( String ) val );
                     filter.addNode( node );
                 }
             }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java Fri Sep 14 13:14:59 2007
@@ -26,14 +26,17 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.ExtensibleNode;
 import org.apache.directory.shared.ldap.filter.FilterVisitor;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 
@@ -98,7 +101,7 @@
                         // create a new OR node to hold all descendent forms
                         // add to this node the generalized leaf node and 
                         // replace the old leaf with the new OR branch node
-                        BranchNode orNode = new BranchNode( AssertionEnum.OR );
+                        BranchNode orNode = new OrNode();
                         orNode.getChildren().add( leaf );
                         children.set( childNumber++, orNode );
                         
@@ -110,56 +113,110 @@
                             LeafNode newLeaf = null;
                             AttributeType descendant = ( AttributeType ) descendants.next();
                             
-                            switch( leaf.getAssertionType() )
+                            if ( leaf instanceof PresenceNode )
                             {
-                                case EXTENSIBLE :
-                                    ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
-                                    newLeaf = new ExtensibleNode( descendant.getOid(), 
-                                        extensibleNode.getValue(), 
-                                        extensibleNode.getMatchingRuleId(), 
-                                        extensibleNode.dnAttributes() );
-                                    break;
-                                    
-                                case PRESENCE :
-                                    newLeaf = new PresenceNode( descendant.getOid() );
-                                    break;
-                                    
-                                case SUBSTRING :
-                                    SubstringNode substringNode = ( SubstringNode ) leaf;
-                                    newLeaf = new SubstringNode( descendant.getOid(), 
-                                        substringNode.getInitial(), 
-                                        substringNode.getFinal() );
-                                    break;
-                                    
-                                case APPROXIMATE :
-                                case EQUALITY :
-                                case GREATEREQ :
-                                case LESSEQ :
-                                    SimpleNode simpleNode = ( SimpleNode ) leaf;
-                                    if ( simpleNode.getValue() instanceof String )
-                                    {
-                                        newLeaf = new SimpleNode( descendant.getOid(), 
-                                            ( String ) simpleNode.getValue(), 
-                                            simpleNode.getAssertionType() );
-                                    }
-                                    else if ( simpleNode.getValue() instanceof byte[] )
-                                    {
-                                        newLeaf = new SimpleNode( descendant.getOid(), 
-                                            ( byte[] ) simpleNode.getValue(), 
-                                            simpleNode.getAssertionType() );
-                                    }
-                                    else
-                                    {
-                                        newLeaf = new SimpleNode( descendant.getOid(), 
-                                            simpleNode.getValue().toString(), 
-                                            simpleNode.getAssertionType() );
-                                    }
-                                    break;
-                                    
-                                default:
-                                    throw new IllegalStateException( "Unknown assertion type: " 
-                                        + leaf.getAssertionType() );
+                                newLeaf = new PresenceNode( descendant.getOid() );
                             }
+                            else if ( leaf instanceof ApproximateNode ) 
+                            {
+                            	ApproximateNode approximateNode = ( ApproximateNode ) leaf;
+                                
+                                if ( approximateNode.getValue() instanceof String )
+                                {
+                                    newLeaf = new ApproximateNode( descendant.getOid(), 
+                                        ( String ) approximateNode.getValue() );
+                                }
+                                else if ( approximateNode.getValue() instanceof byte[] )
+                                {
+                                    newLeaf = new ApproximateNode( descendant.getOid(), 
+                                        ( byte[] ) approximateNode.getValue() );
+                                }
+                                else
+                                {
+                                    newLeaf = new ApproximateNode( descendant.getOid(), 
+                                    		approximateNode.getValue().toString() );
+                                }
+                            }
+                            else if ( leaf instanceof EqualityNode )
+                            {
+                            	EqualityNode equalityNode = ( EqualityNode ) leaf;
+                                
+                                if ( equalityNode.getValue() instanceof String )
+                                {
+                                    newLeaf = new EqualityNode( descendant.getOid(), 
+                                        ( String ) equalityNode.getValue() );
+                                }
+                                else if ( equalityNode.getValue() instanceof byte[] )
+                                {
+                                    newLeaf = new EqualityNode( descendant.getOid(), 
+                                        ( byte[] ) equalityNode.getValue() );
+                                }
+                                else
+                                {
+                                    newLeaf = new EqualityNode( descendant.getOid(), 
+                                    		equalityNode.getValue().toString() );
+                                }
+                            }
+                            else if ( leaf instanceof GreaterEqNode )
+                            {
+                            	GreaterEqNode greaterEqNode = ( GreaterEqNode ) leaf;
+                                
+                                if ( greaterEqNode.getValue() instanceof String )
+                                {
+                                    newLeaf = new GreaterEqNode( descendant.getOid(), 
+                                        ( String ) greaterEqNode.getValue() );
+                                }
+                                else if ( greaterEqNode.getValue() instanceof byte[] )
+                                {
+                                    newLeaf = new GreaterEqNode( descendant.getOid(), 
+                                        ( byte[] ) greaterEqNode.getValue() );
+                                }
+                                else
+                                {
+                                    newLeaf = new GreaterEqNode( descendant.getOid(), 
+                                    		greaterEqNode.getValue().toString() );
+                                }
+                            }
+                            else if ( leaf instanceof LessEqNode )
+                            {
+                            	LessEqNode lessEqNode = ( LessEqNode ) leaf;
+                                
+                                if ( lessEqNode.getValue() instanceof String )
+                                {
+                                    newLeaf = new LessEqNode( descendant.getOid(), 
+                                        ( String ) lessEqNode.getValue() );
+                                }
+                                else if ( lessEqNode.getValue() instanceof byte[] )
+                                {
+                                    newLeaf = new LessEqNode( descendant.getOid(), 
+                                        ( byte[] ) lessEqNode.getValue() );
+                                }
+                                else
+                                {
+                                    newLeaf = new LessEqNode( descendant.getOid(), 
+                                    		lessEqNode.getValue().toString() );
+                                }
+                            }
+                            else if ( leaf instanceof ExtensibleNode )
+                            {
+                                ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
+                                newLeaf = new ExtensibleNode( descendant.getOid(), 
+                                    extensibleNode.getValue(), 
+                                    extensibleNode.getMatchingRuleId(), 
+                                    extensibleNode.dnAttributes() );
+                            }
+                            else if ( leaf instanceof SubstringNode )
+                            {
+                                SubstringNode substringNode = ( SubstringNode ) leaf;
+                                newLeaf = new SubstringNode( descendant.getOid(), 
+                                    substringNode.getInitial(), 
+                                    substringNode.getFinal() );
+                            }
+                            else
+                            {
+                                    throw new IllegalStateException( "Unknown assertion type: " + leaf );
+                            }
+
                             orNode.addNode( newLeaf );
                         }
                     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java Fri Sep 14 13:14:59 2007
@@ -52,13 +52,18 @@
 import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
@@ -165,7 +170,6 @@
         nextInterceptor.moveAndRename( opContext );
     }
 
-
     public NamingEnumeration<SearchResult> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws NamingException
     {
         LdapDN base = opContext.getDn();
@@ -210,6 +214,7 @@
                 }
 
                 filter.accept( normVisitor );
+                
                 isFailure = false;
             }
             catch( UndefinedFilterAttributeException e )
@@ -226,21 +231,21 @@
                 // note that in this case the undefined node will not be removed.
                 BranchNode bnode = ( BranchNode ) filter;
                 
-                if ( bnode.isNegation() )
+                if ( bnode instanceof NotNode )
                 {
                     return new EmptyEnumeration<SearchResult>();
                 }
                 
                 bnode.getChildren().remove( e.getUndefinedFilterNode() );
                 
-                if ( bnode.getOperator() == AssertionEnum.AND )
+                if ( bnode instanceof AndNode )
                 {
                     return new EmptyEnumeration<SearchResult>();
                 }
                 
                 if ( bnode.getChildren().size() < 2 )
                 {
-                    filter = bnode.getChild();
+                    filter = bnode.getFirstChild();
                 }
             }
         }
@@ -259,9 +264,9 @@
             }
 
             // now for AND & OR nodes with a single child left replace them with their child
-            if ( child.getChildren().size() == 1 && child.getOperator() != AssertionEnum.NOT )
+            if ( child.getChildren().size() == 1 && ! ( child instanceof NotNode ) )
             {
-                filter = child.getChild();
+                filter = child.getFirstChild();
             }
         }
         
@@ -282,7 +287,7 @@
             {
                 // create new OR node and add the filter leaf to it 
                 // and set filter to this new branch node
-                BranchNode bnode = new BranchNode( AssertionEnum.OR );
+                BranchNode bnode = new OrNode();
                 bnode.getChildren().add( filter );
                 filter = bnode;
                 
@@ -294,55 +299,111 @@
                     LeafNode newLeaf = null;
                     AttributeType descendant = ( AttributeType ) descendants.next();
                     
-                    switch( leaf.getAssertionType() )
+                    if ( leaf instanceof PresenceNode )
+                    {
+                    	newLeaf = new PresenceNode( descendant.getOid() );
+                    } 
+                    else if ( leaf instanceof EqualityNode )
+                    {
+                    	EqualityNode equalityNode = ( EqualityNode ) leaf;
+                    	
+                        if ( equalityNode.getValue() instanceof String )
+                        {
+                            newLeaf = new EqualityNode( descendant.getOid(), 
+                                ( String ) equalityNode.getValue() );
+                        }
+                        else if ( equalityNode.getValue() instanceof byte[] )
+                        {
+                            newLeaf = new EqualityNode( descendant.getOid(), 
+                                ( byte[] ) equalityNode.getValue() );
+                        }
+                        else
+                        {
+                            newLeaf = new EqualityNode( descendant.getOid(), 
+                            		equalityNode.getValue().toString() );
+                        }
+                    }
+                    else if ( leaf instanceof GreaterEqNode )
+                    {
+                    	GreaterEqNode greaterEqNode = ( GreaterEqNode ) leaf;
+                    	
+                        if ( greaterEqNode.getValue() instanceof String )
+                        {
+                            newLeaf = new GreaterEqNode( descendant.getOid(), 
+                                ( String ) greaterEqNode.getValue() );
+                        }
+                        else if ( greaterEqNode.getValue() instanceof byte[] )
+                        {
+                            newLeaf = new GreaterEqNode( descendant.getOid(), 
+                                ( byte[] ) greaterEqNode.getValue() );
+                        }
+                        else
+                        {
+                            newLeaf = new GreaterEqNode( descendant.getOid(), 
+                            		greaterEqNode.getValue().toString() );
+                        }
+                    }
+                    else if ( leaf instanceof LessEqNode )
+                    {
+                    	LessEqNode lessEqNode = ( LessEqNode ) leaf;
+                    	
+                        if ( lessEqNode.getValue() instanceof String )
+                        {
+                            newLeaf = new LessEqNode( descendant.getOid(), 
+                                ( String ) lessEqNode.getValue() );
+                        }
+                        else if ( lessEqNode.getValue() instanceof byte[] )
+                        {
+                            newLeaf = new LessEqNode( descendant.getOid(), 
+                                ( byte[] ) lessEqNode.getValue() );
+                        }
+                        else
+                        {
+                            newLeaf = new LessEqNode( descendant.getOid(), 
+                            		lessEqNode.getValue().toString() );
+                        }
+                    }
+                    else if ( leaf instanceof ApproximateNode )
+                    {
+                    	ApproximateNode approximateNode = ( ApproximateNode ) leaf;
+                    	
+                        if ( approximateNode.getValue() instanceof String )
+                        {
+                            newLeaf = new ApproximateNode( descendant.getOid(), 
+                                ( String ) approximateNode.getValue()  );
+                        }
+                        else if ( approximateNode.getValue() instanceof byte[] )
+                        {
+                            newLeaf = new ApproximateNode( descendant.getOid(), 
+                                ( byte[] ) approximateNode.getValue()  );
+                        }
+                        else
+                        {
+                            newLeaf = new ApproximateNode( descendant.getOid(), 
+                            		approximateNode.getValue().toString() );
+                        }
+                    }
+                    else if ( leaf instanceof SubstringNode )
+                    {
+                        SubstringNode substringNode = ( SubstringNode ) leaf;
+                        
+                        newLeaf = new SubstringNode( descendant.getOid(), 
+                            substringNode.getInitial(), 
+                            substringNode.getFinal() );
+                    }
+                    else if ( leaf instanceof ExtensibleNode )
+                    {
+                        ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
+                        
+                        newLeaf = new ExtensibleNode( descendant.getOid(), 
+                            extensibleNode.getValue(), 
+                            extensibleNode.getMatchingRuleId(), 
+                            extensibleNode.dnAttributes() );
+                    	
+                    }
+                    else
                     {
-                        case EXTENSIBLE :
-                            ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
-                            newLeaf = new ExtensibleNode( descendant.getOid(), 
-                                extensibleNode.getValue(), 
-                                extensibleNode.getMatchingRuleId(), 
-                                extensibleNode.dnAttributes() );
-                            break;
-                            
-                        case PRESENCE :
-                            newLeaf = new PresenceNode( descendant.getOid() );
-                            break;
-                            
-                        case SUBSTRING :
-                            SubstringNode substringNode = ( SubstringNode ) leaf;
-                            newLeaf = new SubstringNode( descendant.getOid(), 
-                                substringNode.getInitial(), 
-                                substringNode.getFinal() );
-                            break;
-                            
-                        case APPROXIMATE :
-                        case EQUALITY :
-                        case GREATEREQ :
-                        case LESSEQ :
-                            SimpleNode simpleNode = ( SimpleNode ) leaf;
-                            if ( simpleNode.getValue() instanceof String )
-                            {
-                                newLeaf = new SimpleNode( descendant.getOid(), 
-                                    ( String ) simpleNode.getValue(), 
-                                    simpleNode.getAssertionType() );
-                            }
-                            else if ( simpleNode.getValue() instanceof byte[] )
-                            {
-                                newLeaf = new SimpleNode( descendant.getOid(), 
-                                    ( byte[] ) simpleNode.getValue(), 
-                                    simpleNode.getAssertionType() );
-                            }
-                            else
-                            {
-                                newLeaf = new SimpleNode( descendant.getOid(), 
-                                    simpleNode.getValue().toString(), 
-                                    simpleNode.getAssertionType() );
-                            }
-                            break;
-                            
-                        default:
-                            throw new IllegalStateException( "Unknown assertion type: " 
-                                + leaf.getAssertionType() );
+                        throw new IllegalStateException( "Unknown assertion type: " + leaf );
                     }
                     
                     bnode.getChildren().add( newLeaf );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java Fri Sep 14 13:14:59 2007
@@ -21,11 +21,12 @@
 
 
 import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterVisitor;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
@@ -206,14 +207,15 @@
                         // remove the child at ii
                         bnode.getChildren().remove( child );
                         
-                        if ( bnode.getOperator() != AssertionEnum.AND )
+                        if ( bnode instanceof AndNode )
                         {
-                            bnode.set( "undefined", Boolean.TRUE );
+                            bnode.set( "undefined", Boolean.FALSE );
                         }
                         else
                         {
-                            bnode.set( "undefined", Boolean.FALSE );
+                            bnode.set( "undefined", Boolean.TRUE );
                         }
+
                         ii--; // decrement so we can evaluate next child which has shifted to ii
                         continue;
                     }
@@ -230,14 +232,16 @@
                 catch( UndefinedFilterAttributeException e )
                 {
                     bnode.getChildren().remove( ii );
-                    if ( bnode.getOperator() != AssertionEnum.AND )
+                    
+                    if ( bnode instanceof AndNode )
                     {
-                        bnode.set( "undefined", Boolean.TRUE );
+                        bnode.set( "undefined", Boolean.FALSE );
                     }
                     else
                     {
-                        bnode.set( "undefined", Boolean.FALSE );
+                        bnode.set( "undefined", Boolean.TRUE );
                     }
+
                     ii--;
                     continue;
                 }
@@ -266,16 +270,16 @@
                     
                     // now for AND & OR nodes with a single child left replace them
                     // with their child at the same index they AND/OR node was in
-                    if ( child.getChildren().size() == 1 && child.getOperator() != AssertionEnum.NOT )
+                    if ( child.getChildren().size() == 1 && ! ( child instanceof NotNode ) )
                     {
                         bnode.getChildren().remove( child );
                         if ( ii >= bnode.getChildren().size() )
                         {
-                            bnode.getChildren().add( child.getChild() );
+                            bnode.getChildren().add( child.getFirstChild() );
                         }
                         else
                         {
-                            bnode.getChildren().add( ii, child.getChild() );
+                            bnode.getChildren().add( ii, child.getFirstChild() );
                         }
                     }
                 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java Fri Sep 14 13:14:59 2007
@@ -25,13 +25,22 @@
 import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.AssertionNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
 
 
 /**
@@ -42,12 +51,9 @@
  */
 public class DefaultOptimizer implements Optimizer
 {
-    /** the maximum size for a count Integer.MAX_VALUE as a BigInteger */
-    private static final Long MAX = Long.MAX_VALUE;
     /** the database this optimizer operates on */
     private BTreePartition db;
 
-
     /**
      * Creates an optimizer on a database.
      *
@@ -70,7 +76,7 @@
     public void annotate( ExprNode node ) throws NamingException
     {
         // Start off with the worst case unless scan count says otherwise.
-        Long count = MAX;
+        long count = Long.MAX_VALUE;
 
         /* --------------------------------------------------------------------
          *                 H A N D L E   L E A F   N O D E S          
@@ -101,40 +107,40 @@
         {
             LeafNode leaf = ( LeafNode ) node;
 
-            switch ( leaf.getAssertionType() )
+            if ( node instanceof PresenceNode )
+            {
+                count = getPresenceScan( ( PresenceNode ) leaf );
+            }
+            else if ( node instanceof EqualityNode )
+            {
+                count = getEqualityScan( ( EqualityNode ) leaf );
+            }
+            else if ( node instanceof GreaterEqNode )
+            {
+                count = getGreaterLessScan( ( GreaterEqNode ) leaf, SimpleNode.EVAL_GREATER );
+            }
+            else if ( node instanceof LessEqNode )
+            {
+                count = getGreaterLessScan( ( SimpleNode ) leaf, SimpleNode.EVAL_LESSER );
+            }
+            else if ( node instanceof SubstringNode )
+            {
+                /** Cannot really say so we presume the total index count */
+                count = getFullScan( leaf );
+            }
+            else if ( node instanceof ExtensibleNode )
+            {
+                /** Cannot really say so we presume the total index count */
+                count = getFullScan( leaf );
+            }
+            else if ( node instanceof ApproximateNode )
             {
-                case APPROXIMATE :
-                    /** Feature not implemented so we just use equality matching */
-                    count = getEqualityScan( ( SimpleNode ) leaf );
-                    break;
-                    
-                case EQUALITY :
-                    count = getEqualityScan( ( SimpleNode ) leaf );
-                    break;
-                    
-                case EXTENSIBLE :
-                    /** Cannot really say so we presume the total index count */
-                    count = getFullScan( leaf );
-                    break;
-                    
-                case GREATEREQ :
-                    count = getGreaterLessScan( ( SimpleNode ) leaf, true );
-                    break;
-                    
-                case LESSEQ :
-                    count = getGreaterLessScan( ( SimpleNode ) leaf, false );
-                    break;
-                case PRESENCE :
-                    count = getPresenceScan( ( PresenceNode ) leaf );
-                    break;
-                    
-                case SUBSTRING :
-                    /** Cannot really say so we presume the total index count */
-                    count = getFullScan( leaf );
-                    break;
-                    
-                default:
-                    throw new IllegalArgumentException( "Unrecognized leaf node" );
+                /** Feature not implemented so we just use equality matching */
+                count = getEqualityScan( ( ApproximateNode ) leaf );
+            }
+            else
+            {
+                throw new IllegalArgumentException( "Unrecognized leaf node" );
             }
         }
         // --------------------------------------------------------------------
@@ -142,31 +148,28 @@
         // --------------------------------------------------------------------
         else
         {
-            BranchNode bnode = ( BranchNode ) node;
-
-            switch ( bnode.getOperator() )
+            if ( node instanceof AndNode )
+            {
+            	count = getConjunctionScan( (AndNode)node );
+            }
+            else if ( node instanceof OrNode )
+            {
+            	count = getDisjunctionScan( (OrNode)node );
+            }
+            else if ( node instanceof NotNode )
+            {
+            	count = getNegationScan( (NotNode)node );
+            }
+            else
             {
-                case AND :
-                    count = getConjunctionScan( bnode );
-                    break;
-                    
-                case NOT :
-                    count = getNegationScan( bnode );
-                    break;
-                    
-                case OR :
-                    count = getDisjunctionScan( bnode );
-                    break;
-                    
-                default:
-                    throw new IllegalArgumentException( "Unrecognized branch node type" );
+            	throw new IllegalArgumentException( "Unrecognized branch node type" );
             }
         }
 
         // Protect against overflow when counting.
-        if ( count.compareTo( 0L ) < 0 )
+        if ( count < 0L )
         {
-            count = MAX;
+            count = Long.MAX_VALUE;
         }
 
         node.set( "count", count );
@@ -184,9 +187,9 @@
      * @return the calculated scan count
      * @throws NamingException if there is an error
      */
-    private Long getConjunctionScan( BranchNode node ) throws NamingException
+    private long getConjunctionScan( BranchNode node ) throws NamingException
     {
-        Long count = MAX;
+        long count = Long.MAX_VALUE;
         List<ExprNode> children = node.getChildren();
 
         for ( int ii = 0; ii < children.size(); ii++ )
@@ -209,9 +212,9 @@
      * @return the scan count
      * @throws NamingException if there is an error
      */
-    private Long getNegationScan( BranchNode node ) throws NamingException
+    private long getNegationScan( BranchNode node ) throws NamingException
     {
-        return MAX;
+        return Long.MAX_VALUE;
     }
 
 
@@ -224,10 +227,10 @@
      * @return the scan count on the OR node
      * @throws NamingException if there is an error
      */
-    private Long getDisjunctionScan( BranchNode node ) throws NamingException
+    private long getDisjunctionScan( BranchNode node ) throws NamingException
     {
         List<ExprNode> children = node.getChildren();
-        Long total = 0L;
+        long total = 0L;
 
         for ( int ii = 0; ii < children.size(); ii++ )
         {
@@ -236,12 +239,6 @@
             total += ( Long ) child.get( "count" );
         }
         
-        // we don't want values bigger than Integer.MAX_VALUE
-        if ( total.compareTo( MAX ) > 0 )
-        {
-            total = MAX;
-        }
-
         return total;
     }
 
@@ -254,7 +251,7 @@
      * @return the worst case
      * @throws NamingException if there is an error accessing an index
      */
-    private Long getEqualityScan( SimpleNode node ) throws NamingException
+    private long getEqualityScan( SimpleNode node ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
@@ -263,7 +260,7 @@
         }
 
         // count for non-indexed attribute is unknown so we presume da worst
-        return MAX;
+        return Long.MAX_VALUE;
     }
 
 
@@ -276,7 +273,7 @@
      * @return the scan count of all nodes satisfying the AVA
      * @throws NamingException if there is an error accessing an index
      */
-    private Long getGreaterLessScan( SimpleNode node, boolean isGreaterThan ) throws NamingException
+    private long getGreaterLessScan( SimpleNode node, boolean isGreaterThan ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
@@ -286,7 +283,7 @@
         }
 
         // count for non-indexed attribute is unknown so we presume da worst
-        return MAX;
+        return Long.MAX_VALUE;
     }
 
 
@@ -299,7 +296,7 @@
      * @return the worst case full scan count
      * @throws NamingException if there is an error access database indices
      */
-    private Long getFullScan( LeafNode node ) throws NamingException
+    private long getFullScan( LeafNode node ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
@@ -308,7 +305,7 @@
             return Long.valueOf( count );
         }
 
-        return MAX;
+        return Long.MAX_VALUE;
     }
 
 
@@ -320,7 +317,7 @@
      * @return the number of entries matched for the presence of an attribute
      * @throws NamingException if errors result
      */
-    private Long getPresenceScan( PresenceNode node ) throws NamingException
+    private long getPresenceScan( PresenceNode node ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
@@ -329,7 +326,7 @@
             return Long.valueOf( count );
         }
 
-        return MAX;
+        return Long.MAX_VALUE;
     }
 
 
@@ -340,7 +337,7 @@
      * @return the scan count for scope
      * @throws NamingException if any errors result
      */
-    private Long getScopeScan( ScopeNode node ) throws NamingException
+    private long getScopeScan( ScopeNode node ) throws NamingException
     {
         switch ( node.getScope() )
         {
@@ -348,7 +345,7 @@
                 return 1L;
             
             case ( SearchControls.ONELEVEL_SCOPE  ):
-                Long id = db.getEntryId( node.getBaseDn() );
+                long id = db.getEntryId( node.getBaseDn() );
                 return Long.valueOf( db.getChildCount( id ) );
                 
             case ( SearchControls.SUBTREE_SCOPE  ):

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java Fri Sep 14 13:14:59 2007
@@ -27,7 +27,7 @@
 import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
@@ -125,7 +125,7 @@
         }
 
         // Add the scope node using the eective base to the ilter
-        BranchNode root = new BranchNode( AssertionEnum.AND );
+        BranchNode root = new AndNode();
         ExprNode node = new ScopeNode( env, effectiveBase.toString(), searchCtls.getSearchScope() );
         root.getChildren().add( node );
         root.getChildren().add( filter );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java Fri Sep 14 13:14:59 2007
@@ -27,13 +27,22 @@
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.AssertionNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
 
 
 /**
@@ -96,60 +105,59 @@
         {
             LeafNode leaf = ( LeafNode ) node;
 
-            switch ( leaf.getAssertionType() )
+            if ( node instanceof PresenceNode )
             {
-                case APPROXIMATE :
-                    list = enumEquality( ( SimpleNode ) node );
-                    break;
-                    
-                case EQUALITY :
-                    list = enumEquality( ( SimpleNode ) node );
-                    break;
-                    
-                case EXTENSIBLE :
-                    // N O T   I M P L E M E N T E D   Y E T !
-                    throw new NotImplementedException();
-                
-                case GREATEREQ :
-                    list = enumGreater( ( SimpleNode ) node, true );
-                    break;
-                    
-                case LESSEQ :
-                    list = enumGreater( ( SimpleNode ) node, false );
-                    break;
-                    
-                case PRESENCE :
-                    list = enumPresence( ( PresenceNode ) node );
-                    break;
-                    
-                case SUBSTRING :
-                    list = substringEnumerator.enumerate( leaf );
-                    break;
-                    
-                default:
-                    throw new IllegalArgumentException( "Unknown leaf assertion" );
+                list = enumPresence( ( PresenceNode ) node );
+            }
+            else if ( node instanceof EqualityNode )
+            {
+                list = enumEquality( ( EqualityNode ) node );
+            }
+            else if ( node instanceof GreaterEqNode )
+            {
+                list = enumGreaterOrLesser( ( SimpleNode ) node, SimpleNode.EVAL_GREATER );
+            }
+            else if ( node instanceof LessEqNode )
+            {
+                list = enumGreaterOrLesser( ( SimpleNode ) node, SimpleNode.EVAL_LESSER );
+            }
+            else if ( node instanceof SubstringNode )
+            {
+                list = substringEnumerator.enumerate( leaf );
+            }
+            else if ( node instanceof ExtensibleNode )
+            {
+                // N O T   I M P L E M E N T E D   Y E T !
+                throw new NotImplementedException();
+            }
+            else if ( node instanceof ApproximateNode )
+            {
+                list = enumEquality( ( EqualityNode ) node );
+            }
+            else
+            {
+                throw new IllegalArgumentException( "Unknown leaf assertion" );
             }
         }
         else
         {
             BranchNode branch = ( BranchNode ) node;
 
-            switch ( branch.getOperator() )
+            if ( node instanceof AndNode )
+            {
+                list = enumConj( (AndNode)branch );
+            }
+            else if ( node instanceof OrNode )
             {
-                case AND :
-                    list = enumConj( branch );
-                    break;
-                    
-                case NOT :
-                    list = enumNeg( branch );
-                    break;
-                    
-                case OR :
-                    list = enumDisj( branch );
-                    break;
-                    
-                default:
-                    throw new IllegalArgumentException( "Unknown branch logical operator" );
+                list = enumDisj( (OrNode)branch );
+            }
+            else if ( node instanceof NotNode )
+            {
+                list = enumNeg( (NotNode)branch );
+            }
+            else
+            {
+                throw new IllegalArgumentException( "Unknown branch logical operator" );
             }
         }
 
@@ -162,7 +170,7 @@
      *
      * @param node the disjunction expression branch node
      */
-    private NamingEnumeration<IndexRecord> enumDisj( BranchNode node ) throws NamingException
+    private NamingEnumeration<IndexRecord> enumDisj( OrNode node ) throws NamingException
     {
         List<ExprNode> children = node.getChildren();
         NamingEnumeration[] childEnumerations = new NamingEnumeration[children.size()];
@@ -196,7 +204,7 @@
                 // NOTICE THE ! HERE
                 // The candidate is valid if it does not pass assertion. A
                 // candidate that passes assertion is therefore invalid.
-                return !evaluator.evaluate( node.getChild(), rec );
+                return !evaluator.evaluate( node.getFirstChild(), rec );
             }
         };
 
@@ -210,7 +218,7 @@
      *
      * @param node a conjunction expression branch node
      */
-    private NamingEnumeration<IndexRecord> enumConj( final BranchNode node ) throws NamingException
+    private NamingEnumeration<IndexRecord> enumConj( final AndNode node ) throws NamingException
     {
         int minIndex = 0;
         long minValue = Long.MAX_VALUE;
@@ -298,20 +306,13 @@
      * @return an enumeration over the index records matching the AVA
      * @throws NamingException if there is a failure while accessing the db
      */
-    private NamingEnumeration<IndexRecord> enumGreater( final SimpleNode node, final boolean isGreater ) throws NamingException
+    private NamingEnumeration<IndexRecord> enumGreaterOrLesser( final SimpleNode node, final boolean isGreaterOrLesser ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getUserIndex( node.getAttribute() );
 
-            if ( isGreater )
-            {
-                return idx.listIndices( node.getValue(), true );
-            }
-            else
-            {
-                return idx.listIndices( node.getValue(), false );
-            }
+            return idx.listIndices( node.getValue(), isGreaterOrLesser );
         }
 
         return nonIndexedScan( node );
@@ -326,7 +327,7 @@
      * @return an enumeration over the index records matching the AVA
      * @throws NamingException if there is a failure while accessing the db
      */
-    private NamingEnumeration<IndexRecord> enumEquality( final SimpleNode node ) throws NamingException
+    private NamingEnumeration<IndexRecord> enumEquality( final EqualityNode node ) throws NamingException
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEvaluator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEvaluator.java Fri Sep 14 13:14:59 2007
@@ -20,14 +20,15 @@
 package org.apache.directory.server.core.partition.impl.btree;
 
 
-import java.util.Iterator;
-
 import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
 
 
 /**
@@ -105,47 +106,42 @@
 
         BranchNode bnode = ( BranchNode ) node;
 
-        switch ( bnode.getOperator() )
+        if ( bnode instanceof OrNode )
         {
-            case OR :
-                Iterator children = bnode.getChildren().iterator();
-
-                while ( children.hasNext() )
+            for ( ExprNode child:bnode.getChildren() )
+            {
+                if ( evaluate( child, record ) )
                 {
-                    ExprNode child = ( ExprNode ) children.next();
-
-                    if ( evaluate( child, record ) )
-                    {
-                        return true;
-                    }
+                    return true;
                 }
+            }
 
-                return false;
-                
-            case AND :
-                children = bnode.getChildren().iterator();
-                while ( children.hasNext() )
+            return false;
+        }
+        else if ( bnode instanceof AndNode )
+        {
+            for ( ExprNode child:bnode.getChildren() )
+            {
+                if ( !evaluate( child, record ) )
                 {
-                    ExprNode child = ( ExprNode ) children.next();
-
-                    if ( !evaluate( child, record ) )
-                    {
-                        return false;
-                    }
+                    return false;
                 }
+            }
 
-                return true;
-                
-            case NOT :
-                if ( null != bnode.getChild() )
-                {
-                    return !evaluate( bnode.getChild(), record );
-                }
+            return true;
+        }
+        else if ( bnode instanceof NotNode )
+        {
+            if ( null != bnode.getFirstChild() )
+            {
+                return !evaluate( bnode.getFirstChild(), record );
+            }
 
-                throw new NamingException( "Negation has no child: " + node );
-                
-            default:
-                throw new NamingException( "Unrecognized branch node operator: " + bnode.getOperator() );
+            throw new NamingException( "Negation has no child: " + node );
+        }
+        else
+        {
+                throw new NamingException( "Unrecognized branch node operator: " + bnode );
         }
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java Fri Sep 14 13:14:59 2007
@@ -30,11 +30,16 @@
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -69,7 +74,6 @@
     /** ScopeNode evaluator we depend on */
     private ScopeEvaluator scopeEvaluator;
 
-
     /**
      * Creates a leaf expression node evaluator.
      *
@@ -111,33 +115,39 @@
             return scopeEvaluator.evaluate( node, record );
         }
 
-        switch ( ( ( LeafNode ) node ).getAssertionType() )
+        if ( node instanceof PresenceNode )
+        {
+            String attrId = ( ( PresenceNode ) node ).getAttribute();
+            return evalPresence( attrId, record );
+        }
+        else if ( node instanceof EqualityNode )
+        {
+            return evalEquality( ( EqualityNode ) node, record );
+        }
+        else if ( node instanceof GreaterEqNode )
+        {
+        	return evalGreaterOrLesser( ( SimpleNode ) node, record, SimpleNode.EVAL_GREATER );
+        }
+        else if ( node instanceof LessEqNode )
         {
-            case APPROXIMATE :
-                return evalEquality( ( SimpleNode ) node, record );
-            
-            case EQUALITY :
-                return evalEquality( ( SimpleNode ) node, record );
-            
-            case EXTENSIBLE :
-                throw new NotImplementedException();
-            
-            case GREATEREQ :
-                return evalGreater( ( SimpleNode ) node, record, true );
-            
-            case LESSEQ :
-                return evalGreater( ( SimpleNode ) node, record, false );
-            
-            case PRESENCE :
-                String attrId = ( ( PresenceNode ) node ).getAttribute();
-                return evalPresence( attrId, record );
-                
-            case SUBSTRING :
-                return substringEvaluator.evaluate( node, record );
-            
-            default:
-                throw new NamingException( "Unrecognized leaf node type: " + ( ( LeafNode ) node ).getAssertionType() );
+        	return evalGreaterOrLesser( ( SimpleNode ) node, record, SimpleNode.EVAL_LESSER );
         }
+        else if ( node instanceof SubstringNode )
+        {
+            return substringEvaluator.evaluate( node, record );
+        }
+        else if ( node instanceof ExtensibleNode )
+        {
+        	throw new NotImplementedException();
+        }
+        else if ( node instanceof ApproximateNode )
+        {
+        	return evalEquality( ( ApproximateNode ) node, record );
+        }
+        else
+        {
+        	throw new NamingException( "Unrecognized leaf node type: " + node );
+    	}        
     }
 
 
@@ -152,7 +162,7 @@
      * @return the ava evaluation on the perspective candidate
      * @throws NamingException if there is a database access failure
      */
-    private boolean evalGreater( SimpleNode node, IndexRecord record, boolean isGreater ) throws NamingException
+    private boolean evalGreaterOrLesser( SimpleNode node, IndexRecord record, boolean isGreaterOrLesser ) throws NamingException
     {
         String attrId = node.getAttribute();
         Long id = (Long)record.getEntryId();
@@ -161,7 +171,7 @@
         {
             Index idx = db.getUserIndex( attrId );
 
-            if ( isGreater )
+            if ( isGreaterOrLesser = SimpleNode.EVAL_GREATER )
             {
                 return idx.hasValue( node.getValue(), id, true );
             }
@@ -198,7 +208,7 @@
          * Cheaper to not check isGreater in one loop - better to separate
          * out into two loops which you choose to execute based on isGreater
          */
-        if ( isGreater )
+        if ( isGreaterOrLesser == SimpleNode.EVAL_GREATER )
         {
             while ( list.hasMore() )
             {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SearchEngine.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SearchEngine.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SearchEngine.java Fri Sep 14 13:14:59 2007
@@ -85,7 +85,7 @@
      * @return enumeration over SearchResults
      * @throws NamingException if the search fails
      */
-    NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException;
+    NamingEnumeration search( Name base, Map<?, ?> env, ExprNode filter, SearchControls searchCtls ) throws NamingException;
 
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java?rev=575783&r1=575782&r2=575783&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java Fri Sep 14 13:14:59 2007
@@ -70,9 +70,8 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapReferralException;
-import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -868,7 +867,7 @@
 
     static ExprNode getReferralFilter()
     {
-        return new SimpleNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.REFERRAL_OC, AssertionEnum.EQUALITY );
+        return new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.REFERRAL_OC );
     }
 
 



Mime
View raw message