You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/07/31 20:44:07 UTC

svn commit: r427198 [1/2] - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec: ./ abandon/ add/ bind/ compare/ del/ extended/ extended/operations/ modify/ modifyDn/ search/ search/controls/

Author: elecharny
Date: Mon Jul 31 11:44:03 2006
New Revision: 427198

URL: http://svn.apache.org/viewvc?rev=427198&view=rev
Log:
Merging changes form optimization branch of shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec back into this 1.1 trunks
branch.  Here's the merge command used: svn merge -r 414084:427187 https://svn.apache.org/repos/asf/directory/branches/shared/optimization .

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlValueAction.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixEncoder.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponseGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControlGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControlGrammar.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlValueAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlValueAction.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlValueAction.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlValueAction.java Mon Jul 31 11:44:03 2006
@@ -47,6 +47,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( ControlValueAction.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     private static Map controlDecoders = new HashMap();
 
 
@@ -104,7 +107,7 @@
         // We can have an END transition
         ldapMessageContainer.grammarEndAllowed( true );
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             if ( control.getControlValue() instanceof byte[] )
             {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java Mon Jul 31 11:44:03 2006
@@ -51,6 +51,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( LdapControlGrammar.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** The instance of grammar. LdapControlGrammar is a singleton */
     private static IGrammar instance = new LdapControlGrammar();
 
@@ -208,7 +211,7 @@
                     // We can have an END transition
                     ldapMessageContainer.grammarEndAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Control OID : " + control.getControlType() );
                     }
@@ -267,7 +270,7 @@
                     // We can have an END transition
                     ldapMessageContainer.grammarEndAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Control criticality : " + control.getCriticality() );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Mon Jul 31 11:44:03 2006
@@ -48,6 +48,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( LdapMessageGrammar.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** The instance of grammar. LdapMessageGrammar is a singleton */
     private static IGrammar instance = new LdapMessageGrammar();
 
@@ -147,7 +150,7 @@
 
                         ldapMessage.setMessageId( messageId );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Ldap Message Id has been decoded : " + messageId );
                         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultGrammar.java Mon Jul 31 11:44:03 2006
@@ -59,6 +59,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( LdapResultGrammar.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** The instance of grammar. LdapResultGrammar is a singleton */
     private static IGrammar instance = new LdapResultGrammar();
 
@@ -220,7 +223,7 @@
                             ldapResult.setResultCode( LdapResultEnum.OTHER );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The result code is set to " + LdapResultEnum.errorCode( resultCode ) );
                     }
@@ -288,7 +291,7 @@
                         }
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The matchedDN is " + ldapResult.getMatchedDN() );
                     }
@@ -349,7 +352,7 @@
                     // We can pop this grammar
                     container.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The error message is : " + ldapResult.getErrorMessage() );
                     }
@@ -455,7 +458,7 @@
                     // We can have a Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         Iterator urls = ldapResult.getReferrals().iterator();
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java Mon Jul 31 11:44:03 2006
@@ -1,3 +1,19 @@
+/*
+ *   Copyright 2006 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.directory.shared.ldap.codec;
 
 
@@ -26,6 +42,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( TwixDecoder.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The associated Provider */
     private final Provider provider;
 
@@ -86,7 +105,7 @@
             {
                 ldapDecoder.decode( buf, ldapMessageContainer );
     
-                if ( log.isDebugEnabled() )
+                if ( IS_DEBUG )
                 {
                     log.debug( "Decoding the PDU : " );
     
@@ -107,7 +126,7 @@
                 
                 if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
                 {
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Decoded LdapMessage : " + ldapMessageContainer.getLdapMessage() );
                         buf.mark();
@@ -118,7 +137,7 @@
                 }
                 else
                 {
-                	if ( log.isDebugEnabled() )
+                	if ( IS_DEBUG )
                 	{
                 		
                 	}
@@ -189,7 +208,7 @@
 
             if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
             {
-                if ( log.isDebugEnabled() )
+                if ( IS_DEBUG )
                 {
                     log.debug( "Decoded LdapMessage : " + ldapMessageContainer.getLdapMessage() );
                 }
@@ -228,7 +247,7 @@
 
             if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
             {
-                if ( log.isDebugEnabled() )
+                if ( IS_DEBUG )
                 {
                     log.debug( "Decoded LdapMessage : " + ldapMessageContainer.getLdapMessage() );
                 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixEncoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixEncoder.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixEncoder.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixEncoder.java Mon Jul 31 11:44:03 2006
@@ -46,6 +46,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( TwixEncoder.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** The associated Provider */
     private final Provider provider;
 
@@ -82,7 +85,7 @@
     {
         try
         {
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Encoding this LdapMessage : " + obj );
             }
@@ -113,14 +116,14 @@
     {
         try
         {
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Encoding this LdapMessage : " + obj );
             }
 
             ByteBuffer pdu = ( ( LdapMessage ) obj ).encode( null );
 
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Encoded PDU : " + StringTools.dumpBytes( pdu.array() ) );
             }
@@ -152,14 +155,14 @@
     {
         try
         {
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Encoding this LdapMessage : " + obj );
             }
 
             byte[] pdu = ( ( LdapMessage ) obj ).encode( null ).array();
 
-            if ( log.isDebugEnabled() )
+            if ( IS_DEBUG )
             {
                 log.debug( "Encoded PDU : " + StringTools.dumpBytes( pdu ) );
             }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Mon Jul 31 11:44:03 2006
@@ -122,6 +122,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( TwixTransformer.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** the provider this transformer is part of */
     private final Provider provider;
 
@@ -663,7 +666,7 @@
         LdapMessage twixMessage = ( LdapMessage ) obj;
         int messageId = twixMessage.getMessageId();
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Transforming LdapMessage <" + messageId + ", " + twixMessage.getMessageTypeName()
                 + "> from Twix to Snickers." );
@@ -1139,7 +1142,7 @@
      */
     public Object transform( Message msg )
     {
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Transforming message type " + msg.getType() );
         }
@@ -1195,7 +1198,7 @@
             transformControls( twixMessage, msg );
         }
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Transformed message : " + twixMessage );
         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java Mon Jul 31 11:44:03 2006
@@ -40,6 +40,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( AbandonRequest.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     // ~ Instance fields
     // ----------------------------------------------------------------------------
 
@@ -105,7 +108,7 @@
     {
         int length = 1 + 1 + Value.getNbBytes( abandonedMessageId );
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Message length : {}", new Integer( length ) );
         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -52,6 +52,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( AbandonRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. AbandonRequestGrammar is a singleton */
     private static IGrammar instance = new AbandonRequestGrammar();
 
@@ -121,7 +124,7 @@
                         abandonRequest.setAbandonedMessageId( abandonnedMessageId );
                         ldapMessage.setProtocolOP( abandonRequest );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "AbandonMessage Id has been decoded : {}", new Integer( abandonnedMessageId ) );
                         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Mon Jul 31 11:44:03 2006
@@ -60,6 +60,9 @@
     /** The logger */
     private transient static final Logger log = LoggerFactory.getLogger( AddRequest.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     // ~ Instance fields
     // ----------------------------------------------------------------------------
 
@@ -273,7 +276,7 @@
         // Return the result.
         int result = 1 + Length.getNbBytes( addRequestLength ) + addRequestLength;
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "AddRequest PDU length = {}", new Integer( result ) );
         }
@@ -375,7 +378,7 @@
             throw new EncoderException( "The PDU buffer size is too small !" );
         }
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "AddRequest encoding : {}", StringTools.dumpBytes( buffer.array() ) );
             log.debug( "AddRequest initial value : {}", toString() );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -34,9 +34,7 @@
 import org.apache.directory.shared.ldap.codec.LdapStatesEnum;
 import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.codec.util.LdapStringEncodingException;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
-import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -58,6 +56,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( AddRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. AddRequestGrammar is a singleton */
     private static IGrammar instance = new AddRequestGrammar();
 
@@ -261,7 +262,7 @@
                         }
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Adding type {}", type );
                     }
@@ -328,7 +329,7 @@
                         {
                             value = tlv.getValue().getData();
 
-                            if ( log.isDebugEnabled() )
+                            if ( IS_DEBUG )
                             {
                                 log.debug( "Adding value {}", StringTools.dumpBytes( ( byte[] ) value ) );
                             }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -58,6 +58,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( BindRequestGrammar.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     /** The instance of grammar. BindRequestGrammar is a singleton */
     private static IGrammar instance = new BindRequestGrammar();
 
@@ -163,7 +166,7 @@
                             throw new DecoderException( "Ldap Version " + version + " is not supported" );
                         }
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Ldap version ", new Integer( version ) );
                         }
@@ -228,7 +231,7 @@
                         bindRequestMessage.setName( name );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( " The Bind name is {}", bindRequestMessage.getName() );
                     }
@@ -291,7 +294,7 @@
                     // We can have an pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The simple authentication is : {}", authentication.getSimple() );
                     }
@@ -356,7 +359,10 @@
 
                     bindRequestMessage.setAuthentication( authentication );
 
-                    log.debug( "The SaslCredential has been created" );
+                    if ( IS_DEBUG ) 
+                    {
+                        log.debug( "The SaslCredential has been created" );
+                    }
 
                     return;
                 }
@@ -422,7 +428,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The mechanism is : {}", authentication.getMechanism() );
                     }
@@ -499,7 +505,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The credentials are : {}", credentials.getCredentials() );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponseGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponseGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponseGrammar.java Mon Jul 31 11:44:03 2006
@@ -49,6 +49,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( BindResponseGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. BindResponseGrammar is a singleton */
     private static IGrammar instance = new BindResponseGrammar();
 
@@ -181,7 +184,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "The SASL credentials value is : {}", bindResponseMessage.getServerSaslCreds()
                             .toString() );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java Mon Jul 31 11:44:03 2006
@@ -39,6 +39,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( SimpleAuthentication.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     // ~ Instance fields
     // ----------------------------------------------------------------------------
 
@@ -127,7 +130,7 @@
         int saslLength = 1 + Length.getNbBytes( mechanismLength + credentialsLength ) + mechanismLength
             + credentialsLength;
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "SASL Authentication length : {}", new Integer( saslLength ) );
         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java Mon Jul 31 11:44:03 2006
@@ -37,6 +37,9 @@
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( SimpleAuthentication.class );
 
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    
     // ~ Instance fields
     // ----------------------------------------------------------------------------
 
@@ -81,7 +84,7 @@
 
         length += Length.getNbBytes( simple.length ) + simple.length;
 
-        if ( log.isDebugEnabled() )
+        if ( IS_DEBUG )
         {
             log.debug( "Simple Authentication length : {}", new Integer( length ) );
         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -55,6 +55,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( CompareRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. CompareRequest is a singleton */
     private static IGrammar instance = new CompareRequestGrammar();
 
@@ -149,7 +152,7 @@
                         compareRequest.setEntry( entry );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Comparing DN {}", entry );
                     }
@@ -223,7 +226,7 @@
                         }
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Comparing attribute description {}", compareRequest.getAttributeDesc() );
                     }
@@ -269,7 +272,7 @@
                         {
                             compareRequest.setAssertionValue( tlv.getValue().getData() );
 
-                            if ( log.isDebugEnabled() )
+                            if ( IS_DEBUG )
                             {
                                 log.debug( "Comparing attribute value {}", StringTools
                                     .dumpBytes( ( byte[] ) compareRequest.getAssertionValue() ) );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -52,6 +52,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( DelRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. DelRequestGrammar is a singleton */
     private static IGrammar instance = new DelRequestGrammar();
 
@@ -129,7 +132,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Deleting DN {}", entry );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -50,6 +50,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( ExtendedRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. ExtendedRequest is a singleton */
     private static IGrammar instance = new ExtendedRequestGrammar();
 
@@ -139,7 +142,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "OID read : {}", extendedRequest.getRequestName() );
                     }
@@ -190,7 +193,7 @@
                     // We can have an Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Extended value : {}", extendedRequest.getRequestValue() );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseGrammar.java Mon Jul 31 11:44:03 2006
@@ -51,6 +51,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( ExtendedResponseGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. ExtendedResponseGrammar is a singleton */
     private static IGrammar instance = new ExtendedResponseGrammar();
 
@@ -158,7 +161,7 @@
                     // We can have a Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "OID read : {}", extendedResponse.getResponseName() );
                     }
@@ -210,7 +213,7 @@
                     // We can have a Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Extended value : {}", extendedResponse.getResponse() );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java Mon Jul 31 11:44:03 2006
@@ -60,6 +60,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( GracefulDisconnectGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. GracefulDisconnectnGrammar is a singleton */
     private static IGrammar instance = new GracefulDisconnectGrammar();
 
@@ -144,7 +147,7 @@
                     {
                         int timeOffline = IntegerDecoder.parse( value, 0, 720 );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Time Offline = " + timeOffline );
                         }
@@ -188,7 +191,7 @@
                     {
                         int delay = IntegerDecoder.parse( value, 0, 86400 );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Delay = " + delay );
                         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java Mon Jul 31 11:44:03 2006
@@ -51,6 +51,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( GracefulShutdownGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. GracefulShutdownGrammar is a singleton */
     private static IGrammar instance = new GracefulShutdownGrammar();
 
@@ -123,7 +126,7 @@
                     {
                         int timeOffline = IntegerDecoder.parse( value, 0, 720 );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Time Offline = " + timeOffline );
                         }
@@ -167,7 +170,7 @@
                     {
                         int delay = IntegerDecoder.parse( value, 0, 86400 );
 
-                        if ( log.isDebugEnabled() )
+                        if ( IS_DEBUG )
                         {
                             log.debug( "Delay = " + delay );
                         }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -56,6 +56,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( ModifyRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. ModifyRequestGrammar is a singleton */
     private static IGrammar instance = new ModifyRequestGrammar();
 
@@ -153,7 +156,7 @@
                         modifyRequest.setObject( object );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Modification of DN {}", modifyRequest.getObject() );
                     }
@@ -268,7 +271,7 @@
                     // Store the current operation.
                     modifyRequest.setCurrentOperation( operation );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         switch ( operation )
                         {
@@ -350,7 +353,7 @@
                         }
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Modifying type : {}", type );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java Mon Jul 31 11:44:03 2006
@@ -57,6 +57,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( ModifyDNRequestGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. ModifyDNRequestGrammar is a singleton */
     private static IGrammar instance = new ModifyDNRequestGrammar();
 
@@ -153,7 +156,7 @@
                         modifyDNRequest.setEntry( entry );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Modifying DN {}", entry );
                     }
@@ -219,7 +222,7 @@
                         modifyDNRequest.setNewRDN( newRdn );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "Modifying with new RDN {}", newRdn );
                     }
@@ -281,7 +284,7 @@
                     // We can have a Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         if ( modifyDNRequest.isDeleteOldRDN() )
                         {
@@ -367,7 +370,7 @@
                     // We can have a Pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "New superior DN {}", newSuperior );
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java Mon Jul 31 11:44:03 2006
@@ -70,109 +70,106 @@
         // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_FILTER_STATE][256];
 
-        // ============================================================================================
+        //============================================================================================
         // Search Request And Filter
         // This is quite complicated, because we have a tree structure to build,
-        // and we may have many elements on each node. For instance, considering
-        // the
+        // and we may have many elements on each node. For instance, considering the 
         // search filter :
         // (& (| (a = b) (c = d)) (! (e = f)) (attr =* h))
         // We will have to create an And filter with three children :
-        // - an Or child,
-        // - a Not child
-        // - and a Present child.
+        //  - an Or child,
+        //  - a Not child
+        //  - and a Present child.
         // The Or child will also have two children.
         //
-        // We know when we have a children while decoding the PDU, because the
-        // length
+        // We know when we have a children while decoding the PDU, because the length
         // of its parent has not yet reached its expected length.
         //
         // This search filter :
         // (&(|(objectclass=top)(ou=contacts))(!(objectclass=ttt))(objectclass=*top))
         // is encoded like this :
-        // +----------------+---------------+
-        // | ExpectedLength | CurrentLength |
-        // +-----------------------------+----------------+---------------+
-        // |A0 52 | 82 | 0 | new level 1
-        // | A1 24 | 82 36 | 0 0 | new level 2
-        // | A3 12 | 82 36 18 | 0 0 0 | new level 3
-        // | 04 0B 'objectclass' | 82 36 18 | 0 0 13 |
-        // | 04 03 'top' | 82 36 18 | 0 20 18 |
-        // | | ^ ^ |
-        // | | | | |
-        // | | +---------------+ |
-        // +-----------------------------* end level 3 -------------------*
-        // | A3 0E | 82 36 14 | 0 0 0 | new level 3
-        // | 04 02 'ou' | 82 36 14 | 0 0 4 |
-        // | 04 08 'contacts' | 82 36 14 | 38 36 14 |
-        // | | ^ ^ ^ ^ |
-        // | | | | | | |
-        // | | | +-------------|--+ |
-        // | | +----------------+ |
-        // +-----------------------------* end level 3, end level 2 ------*
-        // | A2 14 | 82 20 | 38 0 | new level 2
-        // | A3 12 | 82 20 18 | 38 0 0 | new level 3
-        // | 04 0B 'objectclass' | 82 20 18 | 38 0 13 |
-        // | 04 03 'ttt' | 82 20 18 | 60 20 18 |
-        // | | ^ ^ ^ ^ |
-        // | | | | | | |
-        // | | | +-------------|--+ |
-        // | | +----------------+ |
-        // +-----------------------------* end level 3, end level 2 ------*
-        // | A4 14 | 82 20 | 60 0 | new level 2
-        // | 04 0B 'objectclass' | 82 20 | 60 13 |
-        // | 30 05 | 82 20 | 60 13 |
-        // | 82 03 'top' | 82 20 | 82 20 |
-        // | | ^ ^ ^ ^ |
-        // | | | | | | |
-        // | | | +-------------|--+ |
-        // | | +----------------+ |
-        // +-----------------------------* end level 2, end level 1 ------*
-        // +-----------------------------+----------------+---------------+
+        //                              +----------------+---------------+
+        //                              | ExpectedLength | CurrentLength |
+        //+-----------------------------+----------------+---------------+
+        //|A0 52                        | 82             | 0             | new level 1
+        //|   A1 24                     | 82 36          | 0 0           | new level 2
+        //|      A3 12                  | 82 36 18       | 0 0 0         | new level 3
+        //|         04 0B 'objectclass' | 82 36 18       | 0 0 13        |
+        //|         04 03 'top'         | 82 36 18       | 0 20 18       | 
+        //|                             |       ^               ^        |
+        //|                             |       |               |        |
+        //|                             |       +---------------+        |
+        //+-----------------------------* end level 3 -------------------*
+        //|      A3 0E                  | 82 36 14       | 0 0 0         | new level 3
+        //|         04 02 'ou'          | 82 36 14       | 0 0 4         |
+        //|         04 08 'contacts'    | 82 36 14       | 38 36 14      | 
+        //|                             |    ^  ^             ^  ^       |
+        //|                             |    |  |             |  |       |
+        //|                             |    |  +-------------|--+       |
+        //|                             |    +----------------+          |
+        //+-----------------------------* end level 3, end level 2 ------*
+        //|   A2 14                     | 82 20          | 38 0          | new level 2
+        //|      A3 12                  | 82 20 18       | 38 0 0        | new level 3
+        //|         04 0B 'objectclass' | 82 20 18       | 38 0 13       | 
+        //|         04 03 'ttt'         | 82 20 18       | 60 20 18      |
+        //|                             |    ^  ^             ^  ^       |
+        //|                             |    |  |             |  |       |
+        //|                             |    |  +-------------|--+       |
+        //|                             |    +----------------+          |
+        //+-----------------------------* end level 3, end level 2 ------*
+        //|   A4 14                     | 82 20          | 60 0          | new level 2
+        //|      04 0B 'objectclass'    | 82 20          | 60 13         |
+        //|      30 05                  | 82 20          | 60 13         |
+        //|         82 03 'top'         | 82 20          | 82 20         | 
+        //|                             | ^  ^             ^  ^          |
+        //|                             | |  |             |  |          |
+        //|                             | |  +-------------|--+          |
+        //|                             | +----------------+             |
+        //+-----------------------------* end level 2, end level 1 ------*
+        //+-----------------------------+----------------+---------------+
         //
         // When the current length equals the expected length of the parent PDU,
-        // then we are able to 'close' the parent : it has all its children.
-        // This
+        // then we are able to 'close' the parent : it has all its children. This
         // is propagated through all the tree, until either there are no more
         // parents, or the expected length of the parent is different from the
         // current length.
         //                              
-        // ============================================================================================
+        //============================================================================================
         // Filter ::= CHOICE {
-        // and [0] SET OF Filter, (Tag)
-        // ...
+        //     and             [0] SET OF Filter, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.AND_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_AND_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // or [1] SET OF Filter, (Tag)
-        // ...
+        //     ...
+        //     or              [1] SET OF Filter, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.OR_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_OR_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // not [2] Filter, (Tag)
-        // ...
+        //     ...
+        //     not             [2] Filter, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.NOT_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_NOT_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // equalityMatch [3] AttributeValueAssertion, (Tag)
-        // ...
+        //     ...
+        //     equalityMatch   [3] AttributeValueAssertion, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.EQUALITY_MATCH_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // substrings [4] SubstringFilter, (Tag)
-        // ...
+        //     ...
+        //     substrings      [4] SubstringFilter, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.SUBSTRINGS_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.SUBSTRING_FILTER_GRAMMAR_SWITCH, new GrammarAction( "Allow pop" )
@@ -184,40 +181,40 @@
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // greaterOrEqual [5] AttributeValueAssertion, (Tag)
-        // ...
+        //     ...
+        //     greaterOrEqual  [5] AttributeValueAssertion, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.GREATER_OR_EQUAL_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // lessOrEqual [6] AttributeValueAssertion, (Tag)
-        // ...
+        //     ...
+        //     lessOrEqual     [6] AttributeValueAssertion, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.LESS_OR_EQUAL_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // present [7] AttributeDescription, (Tag)
-        // ...
+        //     ...
+        //     present         [7] AttributeDescription, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.PRESENT_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_PRESENT_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // approxMatch [8] AttributeValueAssertion, (Tag)
-        // ...
+        //     ...
+        //     approxMatch     [8] AttributeValueAssertion, (Tag)
+        //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.APPROX_MATCH_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_APPROX_MATCH_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // extensibleMatch [9] ExtensibleMatchFilter } (Tag)
+        //     ...
+        //     extensibleMatch [9] ExtensibleMatchFilter } (Tag)
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][LdapConstants.EXTENSIBLE_MATCH_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_TAG, LdapStatesEnum.MATCHING_RULE_ASSERTION_GRAMMAR_SWITCH, new GrammarAction(
@@ -230,10 +227,9 @@
             } );
 
         // Filter ::= CHOICE {
-        // and [0] SET OF Filter, (Value)
-        // ...
-        // We just have to switch to the initial state of Filter, because this
-        // is what
+        //     and             [0] SET OF Filter, (Value)
+        //     ...
+        // We just have to switch to the initial state of Filter, because this is what
         // we will get !
         super.transitions[LdapStatesEnum.FILTER_AND_VALUE][LdapConstants.AND_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_AND_VALUE, LdapStatesEnum.FILTER_TAG, new GrammarAction( "Init And Filter" )
@@ -256,33 +252,16 @@
                     // We can allocate the SearchRequest
                     Filter andFilter = new AndFilter();
 
-                    // Get the parent, if any
-                    Filter currentFilter = searchRequest.getCurrentFilter();
-
-                    if ( currentFilter != null )
-                    {
-                        // Ok, we have a parent. The new Filter will be added to
-                        // this parent, then.
-                        ( ( ConnectorFilter ) currentFilter ).addFilter( andFilter );
-                        andFilter.setParent( currentFilter );
-                    }
-                    else
-                    {
-                        // No parent. This Filter will become the root.
-                        searchRequest.setFilter( andFilter );
-                        andFilter.setParent( searchRequest );
-                    }
-
-                    searchRequest.setCurrentFilter( andFilter );
+                    // Set the filter
+                    searchRequest.addCurrentFilter( andFilter );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // or [1] SET OF Filter, (Value)
-        // ...
-        // We just have to switch to the initial state of Filter, because this
-        // is what
+        //     ...
+        //     or              [1] SET OF Filter, (Value)
+        //     ...
+        // We just have to switch to the initial state of Filter, because this is what
         // we will get !
         super.transitions[LdapStatesEnum.FILTER_OR_VALUE][LdapConstants.OR_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_OR_VALUE, LdapStatesEnum.FILTER_TAG, new GrammarAction( "Init Or Filter" )
@@ -305,33 +284,16 @@
                     // We can allocate the SearchRequest
                     Filter orFilter = new OrFilter();
 
-                    // Get the parent, if any
-                    Filter currentFilter = searchRequest.getCurrentFilter();
-
-                    if ( currentFilter != null )
-                    {
-                        // Ok, we have a parent. The new Filter will be added to
-                        // this parent, then.
-                        ( ( ConnectorFilter ) currentFilter ).addFilter( orFilter );
-                        orFilter.setParent( currentFilter );
-                    }
-                    else
-                    {
-                        // No parent. This Filter will become the root.
-                        searchRequest.setFilter( orFilter );
-                        orFilter.setParent( searchRequest );
-                    }
-
-                    searchRequest.setCurrentFilter( orFilter );
+                    // Set the filter
+                    searchRequest.addCurrentFilter( orFilter );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // not [2] Filter, (Value)
-        // ...
-        // We just have to switch to the initial state of Filter, because this
-        // is what
+        //     ...
+        //     not             [2] Filter, (Value)
+        //     ...
+        // We just have to switch to the initial state of Filter, because this is what
         // we will get !
         super.transitions[LdapStatesEnum.FILTER_NOT_VALUE][LdapConstants.NOT_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_NOT_VALUE, LdapStatesEnum.FILTER_TAG, new GrammarAction( "Init Not Filter" )
@@ -354,33 +316,16 @@
                     // We can allocate the SearchRequest
                     Filter notFilter = new NotFilter();
 
-                    // Get the parent, if any
-                    Filter currentFilter = searchRequest.getCurrentFilter();
-
-                    if ( currentFilter != null )
-                    {
-                        // Ok, we have a parent. The new Filter will be added to
-                        // this parent, then.
-                        ( ( ConnectorFilter ) currentFilter ).addFilter( notFilter );
-                        notFilter.setParent( currentFilter );
-                    }
-                    else
-                    {
-                        // No parent. This Filter will become the root.
-                        searchRequest.setFilter( notFilter );
-                        notFilter.setParent( searchRequest );
-                    }
-
-                    searchRequest.setCurrentFilter( notFilter );
+                    // Set the filter
+                    searchRequest.addCurrentFilter( notFilter );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // equalityMatch [3] AttributeValueAssertion, (Value)
-        // ...
-        // We will create the filter container (as this is an equalityMatch
-        // filter,
+        //     ...
+        //     equalityMatch   [3] AttributeValueAssertion, (Value)
+        //     ...
+        // We will create the filter container (as this is an equalityMatch filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE][LdapConstants.EQUALITY_MATCH_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, new GrammarAction(
@@ -388,16 +333,15 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-                    compareFilterAction( container, LdapConstants.EQUALITY_MATCH_FILTER );
+                    terminalFilterAction( container, LdapConstants.EQUALITY_MATCH_FILTER );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // greaterOrEqual [5] AttributeValueAssertion, (Value)
-        // ...
-        // We will create the filter container (as this is an GreaterOrEqual
-        // filter,
+        //     ...
+        //     greaterOrEqual  [5] AttributeValueAssertion, (Value)
+        //     ...
+        // We will create the filter container (as this is an GreaterOrEqual filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE][LdapConstants.GREATER_OR_EQUAL_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, new GrammarAction(
@@ -405,16 +349,15 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-                    compareFilterAction( container, LdapConstants.GREATER_OR_EQUAL_FILTER );
+                    terminalFilterAction( container, LdapConstants.GREATER_OR_EQUAL_FILTER );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // lessOrEqual [6] AttributeValueAssertion, (Value)
-        // ...
-        // We will create the filter container (as this is an lessOrEqual
-        // filter,
+        //     ...
+        //     lessOrEqual    [6] AttributeValueAssertion, (Value)
+        //     ...
+        // We will create the filter container (as this is an lessOrEqual filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE][LdapConstants.LESS_OR_EQUAL_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, new GrammarAction(
@@ -422,16 +365,15 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-                    compareFilterAction( container, LdapConstants.LESS_OR_EQUAL_FILTER );
+                    terminalFilterAction( container, LdapConstants.LESS_OR_EQUAL_FILTER );
                 }
             } );
 
         // Filter ::= CHOICE {
-        // ...
-        // approxMatch [8] AttributeValueAssertion, (Value)
-        // ...
-        // We will create the filter container (as this is an approxMatch
-        // filter,
+        //     ...
+        //     approxMatch    [8] AttributeValueAssertion, (Value)
+        //     ...
+        // We will create the filter container (as this is an approxMatch filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_APPROX_MATCH_VALUE][LdapConstants.APPROX_MATCH_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_APPROX_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, new GrammarAction(
@@ -439,20 +381,20 @@
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
-                    compareFilterAction( container, LdapConstants.APPROX_MATCH_FILTER );
+                    terminalFilterAction( container, LdapConstants.APPROX_MATCH_FILTER );
                 }
             } );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // attributeDesc AttributeDescription, (TAG)
-        // ...
+        //    attributeDesc   AttributeDescription, (TAG)
+        //     ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE, null );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // attributeDesc AttributeDescription, (VALUE)
-        // ...
+        //    attributeDesc   AttributeDescription, (VALUE)
+        //     ...
         // We have to set the attribute description in the current filter.
         // It could be an equalityMatch, greaterOrEqual, lessOrEqual or an
         // approxMatch filter.
@@ -482,22 +424,22 @@
                         throw new DecoderException( "Invalid assertion description " + msg + ", : " + lsee.getMessage() );
                     }
 
-                    AttributeValueAssertionFilter currentFilter = ( AttributeValueAssertionFilter ) searchRequest
-                        .getCurrentFilter();
-                    currentFilter.setAssertion( assertion );
+                    AttributeValueAssertionFilter comparisonFilter = ( AttributeValueAssertionFilter ) searchRequest
+                        .getTerminalFilter();
+                    comparisonFilter.setAssertion( assertion );
                 }
             } );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // ...
-        // assertionValue AssertionValue } (TAG)
+        //     ...
+        //    assertionValue  AssertionValue } (TAG)
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_VALUE, null );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // ...
-        // assertionValue AssertionValue } (VALUE)
+        //     ...
+        //    assertionValue  AssertionValue } (VALUE)
         // We have to set the attribute description in the current filter.
         // It could be an equalityMatch, greaterOrEqual, lessOrEqual or an
         // approxMatch filter.
@@ -522,9 +464,9 @@
                         assertionValue = tlv.getValue().getData();
                     }
 
-                    AttributeValueAssertionFilter currentFilter = ( AttributeValueAssertionFilter ) searchRequest
-                        .getCurrentFilter();
-                    AttributeValueAssertion assertion = currentFilter.getAssertion();
+                    AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) searchRequest
+                        .getTerminalFilter();
+                    AttributeValueAssertion assertion = terminalFilter.getAssertion();
 
                     if ( ldapMessageContainer.isBinary( assertion.getAttributeDesc() ) )
                     {
@@ -537,14 +479,15 @@
 
                     // We now have to get back to the nearest filter which is
                     // not terminal.
-                    unstackFilters( container );
+                    searchRequest.unstackFilters( container );
+
                     container.grammarPopAllowed( true );
                 }
             } );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // attributeDesc AttributeDescription, (VALUE)
-        // ...
+        //    attributeDesc   AttributeDescription, (VALUE)
+        //     ...
         // We have to set the attribute description in the current filter.
         // It could be an equalityMatch, greaterOrEqual, lessOrEqual or an
         // approxMatch filter.
@@ -581,24 +524,24 @@
                             throw new DecoderException( "Invalid assertion value " + msg + ", : " + lsee.getMessage() );
                         }
 
-                        AttributeValueAssertionFilter currentFilter = ( AttributeValueAssertionFilter ) searchRequest
-                            .getCurrentFilter();
-                        currentFilter.setAssertion( assertion );
+                        AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) searchRequest
+                            .getTerminalFilter();
+                        terminalFilter.setAssertion( assertion );
                     }
                 }
             } );
 
         // AttributeValueAssertion ::= SEQUENCE {
-        // ...
-        // assertionValue AssertionValue } (TAG)
+        //     ...
+        //    assertionValue  AssertionValue } (TAG)
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_VALUE, null );
 
         // Filter ::= CHOICE {
-        // ...
-        // present [7] AttributeDescription, (Value)
-        // ...
+        //     ...
+        //     present    [7] AttributeDescription, (Value)
+        //     ...
         super.transitions[LdapStatesEnum.FILTER_PRESENT_VALUE][LdapConstants.PRESENT_FILTER_TAG] = new GrammarTransition(
             LdapStatesEnum.FILTER_PRESENT_VALUE, LdapStatesEnum.FILTER_TAG, new GrammarAction(
                 "Init present filter Value" )
@@ -614,23 +557,9 @@
                     // We can allocate the Attribute Value Assertion
                     PresentFilter presentFilter = new PresentFilter();
 
-                    // Get the parent, if any
-                    Filter currentFilter = searchRequest.getCurrentFilter();
-
-                    if ( currentFilter != null )
-                    {
-                        // Ok, we have a parent. The new Filter will be added to
-                        // this parent, then.
-                        ( ( ConnectorFilter ) currentFilter ).addFilter( presentFilter );
-                        presentFilter.setParent( currentFilter );
-                    }
-                    else
-                    {
-                        // No parent. This Filter will become the root.
-                        // searchRequest.setCurrentFilter(presentFilter);
-                        presentFilter.setParent( searchRequest );
-                        searchRequest.setFilter( presentFilter );
-                    }
+                    // add the filter to the request filter
+                    searchRequest.addCurrentFilter( presentFilter );
+                    searchRequest.setTerminalFilter( presentFilter );
 
                     String value = StringTools.utf8ToString( tlv.getValue().getData() );
 
@@ -657,7 +586,8 @@
 
                     // We now have to get back to the nearest filter which is
                     // not terminal.
-                    unstackFilters( container );
+                    searchRequest.unstackFilters( container );
+                    
                     container.grammarPopAllowed( true );
                 }
             } );
@@ -680,60 +610,22 @@
 
 
     /**
-     * This method is used to clear the filter's stack for terminated elements.
-     * An element is considered as terminated either if : - it's a final element
-     * (ie an element which cannot contains a Filter) - its current length
-     * equals its expected length.
-     * 
-     * @param container
-     *            The container being decoded
-     */
-    private void unstackFilters( IAsn1Container container )
-    {
-        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
-        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-        TLV tlv = ldapMessageContainer.getCurrentTLV();
-
-        // Get the parent, if any
-        Filter currentFilter = searchRequest.getCurrentFilter();
-
-        // We now have to check if the parent has been completed
-        if ( tlv.getParent().getExpectedLength() == 0 )
-        {
-            TLV parent = tlv.getParent();
-
-            // The parent has been completed, we have to switch it
-            while ( ( parent != null ) && ( parent.getExpectedLength() == 0 ) )
-            {
-                parent = parent.getParent();
-
-                if ( ( currentFilter != null ) && ( currentFilter.getParent() instanceof Filter ) )
-                {
-                    currentFilter = ( Filter ) currentFilter.getParent();
-                }
-                else
-                {
-                    currentFilter = null;
-                    break;
-                }
-            }
-
-            searchRequest.setCurrentFilter( currentFilter );
-        }
-    }
-
-
-    /**
      * This method is used by each comparaison filters (=, <=, >= or ~=).
      * 
+     * We have two cases :
+     * 1) there is no previous current filter : this filter is the top level
+     * filter
+     * 2) there is a previous currentFilter : its necesseraly a connector,
+     * and the filter is added to its set of filters. We also update the 
+     * currentTerminalFilter, to be able to store the terminal filter value
+     * in it.
+     * 
      * @param container
      *            The LdapContainer
      * @throws DecoderException
      *             If any error occurs.
      */
-    private void compareFilterAction( IAsn1Container container, int filterType ) throws DecoderException
+    private void terminalFilterAction( IAsn1Container container, int filterType ) throws DecoderException
     {
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
         LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
@@ -742,23 +634,10 @@
         // We can allocate the Attribute Value Assertion
         Filter filter = new AttributeValueAssertionFilter( filterType );
 
-        // Get the parent, if any
-        Filter currentFilter = searchRequest.getCurrentFilter();
-
-        if ( currentFilter != null )
-        {
-            // Ok, we have a parent. The new Filter will be added to
-            // this parent, then.
-            ( ( ConnectorFilter ) currentFilter ).addFilter( filter );
-            filter.setParent( currentFilter );
-        }
-        else
-        {
-            // No parent. This Filter will become the root.
-            filter.setParent( searchRequest );
-            searchRequest.setFilter( filter );
-        }
-
-        searchRequest.setCurrentFilter( filter );
+        searchRequest.addCurrentFilter( filter );
+        
+        // Store the filter structure that still has to be
+        // fullfiled
+        searchRequest.setTerminalFilter( filter );
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java?rev=427198&r1=427197&r2=427198&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java Mon Jul 31 11:44:03 2006
@@ -53,6 +53,9 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( MatchingRuleAssertionGrammar.class );
 
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
     /** The instance of grammar. FilterGrammar is a singleton */
     private static IGrammar instance = new MatchingRuleAssertionGrammar();
 
@@ -116,11 +119,8 @@
                         extensibleMatchFilter.setParent( searchRequest );
                     }
 
-                    searchRequest.setCurrentFilter( extensibleMatchFilter );
-
-                    // We now have to get back to the nearest filter which is
-                    // not terminal.
-                    unstackFilters( container );
+                    searchRequest.addCurrentFilter( extensibleMatchFilter );
+                    searchRequest.setTerminalFilter( extensibleMatchFilter );
                 }
             } );
 
@@ -151,7 +151,7 @@
 
                     // Store the value.
                     ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
-                        .getCurrentFilter();
+                        .getTerminalFilter();
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
@@ -219,7 +219,7 @@
                     {
                         // Store the value.
                         ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
-                            .getCurrentFilter();
+                            .getTerminalFilter();
 
                         try
                         {
@@ -266,7 +266,7 @@
             LdapStatesEnum.MATCHING_RULE_ASSERTION_DN_ATTRIBUTES_TAG, new GrammarAction(
                 "Store matching match value Value" )
             {
-                public void action( IAsn1Container container )
+                public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
                     LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
@@ -276,9 +276,12 @@
 
                     // Store the value.
                     ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
-                        .getCurrentFilter();
+                        .getTerminalFilter();
                     extensibleMatchFilter.setMatchValue( StringTools.utf8ToString( tlv.getValue().getData() ) );
 
+                    // unstack the filters if needed
+                    searchRequest.unstackFilters( container );
+                    
                     // We can have a pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
                 }
@@ -310,7 +313,7 @@
 
                     // Store the value.
                     ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
-                        .getCurrentFilter();
+                        .getTerminalFilter();
 
                     // We get the value. If it's a 0, it's a FALSE. If it's
                     // a FF, it's a TRUE. Any other value should be an error,
@@ -332,10 +335,13 @@
                         throw new DecoderException( bde.getMessage() );
                     }
 
-                    if ( log.isDebugEnabled() )
+                    if ( IS_DEBUG )
                     {
                         log.debug( "DN Attributes : {}", new Boolean( extensibleMatchFilter.isDnAttributes() ) );
                     }
+                    
+                    // unstack the filters if needed
+                    searchRequest.unstackFilters( ldapMessageContainer );
 
                     // We can have a pop transition
                     ldapMessageContainer.grammarPopAllowed( true );
@@ -355,51 +361,5 @@
     public static IGrammar getInstance()
     {
         return instance;
-    }
-
-
-    /**
-     * This method is used to clear the filter's stack for terminated elements.
-     * An element is considered as terminated either if : - it's a final element
-     * (ie an element which cannot contains a Filter) - its current length
-     * equals its expected length.
-     * 
-     * @param container
-     *            The container being decoded
-     */
-    private void unstackFilters( IAsn1Container container )
-    {
-        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
-        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-        TLV tlv = ldapMessageContainer.getCurrentTLV();
-
-        // Get the parent, if any
-        Filter currentFilter = searchRequest.getCurrentFilter();
-
-        // We know have to check if the parent has been completed
-        if ( tlv.getParent().getExpectedLength() == 0 )
-        {
-            TLV parent = tlv.getParent();
-
-            // The parent has been completed, we have to switch it
-            while ( ( parent != null ) && ( parent.getExpectedLength() == 0 ) )
-            {
-                parent = parent.getParent();
-
-                if ( ( currentFilter != null ) && ( currentFilter.getParent() instanceof Filter ) )
-                {
-                    currentFilter = ( Filter ) currentFilter.getParent();
-                }
-                else
-                {
-                    currentFilter = null;
-                    break;
-                }
-            }
-
-            searchRequest.setCurrentFilter( currentFilter );
-        }
     }
 }