directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r191765 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
Date Wed, 22 Jun 2005 05:23:55 GMT
Author: elecharny
Date: Tue Jun 21 22:23:51 2005
New Revision: 191765

URL: http://svn.apache.org/viewcvs?rev=191765&view=rev
Log:
Deleted the useless LENGTH transitions

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java?rev=191765&r1=191764&r2=191765&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java Tue Jun 21 22:23:51 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.asn1.ldap.codec.grammars;
 
-import org.apache.asn1.Asn1Object;
 import org.apache.asn1.DecoderException;
 import org.apache.asn1.ber.containers.IAsn1Container;
 import org.apache.asn1.ber.grammar.AbstractGrammar;
@@ -148,7 +147,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA0] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_AND_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_AND_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -156,7 +155,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA1] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_OR_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_OR_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -164,7 +163,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA2] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_NOT_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_NOT_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -172,7 +171,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA3] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EQUALITY_MATCH_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -180,7 +179,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA4] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -188,7 +187,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA5] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_GREATER_OR_EQUAL_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -196,7 +195,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA6] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_LESS_OR_EQUAL_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -204,7 +203,7 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0x87] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_PRESENT_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_PRESENT_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
@@ -212,21 +211,22 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA8] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_APPROX_MATCH_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_APPROX_MATCH_VALUE, null );
 
         // Filter ::= CHOICE {
         //     ...
         //     extensibleMatch [9] ExtensibleMatchFilter } (Tag)
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA9] = new GrammarTransition(
-                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH, null );
+                LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE, null );
 
         // Filter ::= CHOICE {
-        //     and             [0] SET OF Filter, (Length)
+        //     and             [0] SET OF Filter, (Value)
         //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_AND_LENGTH][0xA0] = new GrammarTransition(
-                LdapStatesEnum.FILTER_AND_LENGTH, LdapStatesEnum.FILTER_AND_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][0xA0] = new GrammarTransition(
+                LdapStatesEnum.FILTER_AND_VALUE, LdapStatesEnum.FILTER_TAG, 
                 new GrammarAction( "Init And Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -248,48 +248,29 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(andFilter);
                             andFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
-
-                            searchRequest.setCurrentFilter(andFilter);
                             searchRequest.setFilter(andFilter);
                             andFilter.setParent( searchRequest );
                         }
 
-                        // As this is a new Constructed object, we have to init its length
-                        int expectedLength = tlv.getLength().getLength();
-
-                        andFilter.setExpectedLength( expectedLength );
-                        andFilter.setCurrentLength( 0 );
+                        searchRequest.setCurrentFilter(andFilter);
                     }
-                } );
+                });
 
         // Filter ::= CHOICE {
-        //     and             [0] SET OF Filter, (Value)
+        //     ...
+        //     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_AND_VALUE][0xA0] = new GrammarTransition(
-                LdapStatesEnum.FILTER_AND_VALUE, LdapStatesEnum.FILTER_TAG, null);
-
-        // Filter ::= CHOICE {
-        //     ...
-        //     or              [1] SET OF Filter, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_OR_LENGTH][0xA1] = new GrammarTransition(
-                LdapStatesEnum.FILTER_OR_LENGTH, LdapStatesEnum.FILTER_OR_VALUE,
+        super.transitions[LdapStatesEnum.FILTER_OR_VALUE][0xA1] = new GrammarTransition(
+                LdapStatesEnum.FILTER_OR_VALUE, LdapStatesEnum.FILTER_TAG, 
                 new GrammarAction( "Init Or Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -311,49 +292,29 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(orFilter);
                             orFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
                             searchRequest.setFilter(orFilter);
                             orFilter.setParent( searchRequest );
                         }
 
                         searchRequest.setCurrentFilter(orFilter);
-                        
-                        // As this is a new Constructed object, we have to init its length
-                        int expectedLength = tlv.getLength().getLength();
-
-                        orFilter.setExpectedLength( expectedLength );
-                        orFilter.setCurrentLength( 0 );
                     }
-                } );
+                });
 
         // Filter ::= CHOICE {
         //     ...
-        //     or              [1] SET OF Filter, (Value)
+        //     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_OR_VALUE][0xA1] = new GrammarTransition(
-                LdapStatesEnum.FILTER_OR_VALUE, LdapStatesEnum.FILTER_TAG, null);
-
-        // Filter ::= CHOICE {
-        //     ...
-        //     not             [2] Filter, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_NOT_LENGTH][0xA2] = new GrammarTransition(
-                LdapStatesEnum.FILTER_NOT_LENGTH, LdapStatesEnum.FILTER_NOT_VALUE,
+        super.transitions[LdapStatesEnum.FILTER_NOT_VALUE][0xA2] = new GrammarTransition(
+                LdapStatesEnum.FILTER_NOT_VALUE, LdapStatesEnum.FILTER_TAG, 
                 new GrammarAction( "Init Not Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -375,58 +336,20 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(notFilter);
                             notFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
-
-                            searchRequest.setCurrentFilter(notFilter);
                             searchRequest.setFilter(notFilter);
                             notFilter.setParent( searchRequest );
                         }
 
                         searchRequest.setCurrentFilter(notFilter);
-                        
-                        // As this is a new Constructed object, we have to init its length
-                        int expectedLength = tlv.getLength().getLength();
-
-                        notFilter.setExpectedLength( expectedLength );
-                        notFilter.setCurrentLength( 0 );
                     }
-                } );
-
-        // Filter ::= CHOICE {
-        //     ...
-        //     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][0xA2] = new GrammarTransition(
-                LdapStatesEnum.FILTER_NOT_VALUE, LdapStatesEnum.FILTER_TAG, null);
-
-        // Filter ::= CHOICE {
-        //     ...
-        //     equalityMatch   [3] AttributeValueAssertion, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_EQUALITY_MATCH_LENGTH][0xA3] = new GrammarTransition(
-                LdapStatesEnum.FILTER_EQUALITY_MATCH_LENGTH, LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE,
-                new GrammarAction( "Init Equality Match Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        compareFilterAction(container);
-                    }
-                } );
+                });
 
         // Filter ::= CHOICE {
         //     ...
@@ -435,23 +358,15 @@
         // We will create the filter container (as this is an equalityMatch filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE][0xA3] = new GrammarTransition(
-                LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, null); 
-                
-        // Filter ::= CHOICE {
-        //     ...
-        //     greaterOrEqual  [5] AttributeValueAssertion, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_GREATER_OR_EQUAL_LENGTH][0xA5] = new GrammarTransition(
-                LdapStatesEnum.FILTER_GREATER_OR_EQUAL_LENGTH, LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE,
-                new GrammarAction( "Init Greater Or Equal Filter" )
+                LdapStatesEnum.FILTER_EQUALITY_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, 
+                new GrammarAction( "Init Equality Match Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
                         compareFilterAction(container);
                     }
-                } );
-
+                }); 
+                
         // Filter ::= CHOICE {
         //     ...
         //     greaterOrEqual  [5] AttributeValueAssertion, (Value)
@@ -459,23 +374,15 @@
         // 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][0xA5] = new GrammarTransition(
-                LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, null); 
-                
-        // Filter ::= CHOICE {
-        //     ...
-        //     lessOrEqual    [6] AttributeValueAssertion, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_LESS_OR_EQUAL_LENGTH][0xA6] = new GrammarTransition(
-                LdapStatesEnum.FILTER_LESS_OR_EQUAL_LENGTH, LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE,
-                new GrammarAction( "Init Less Or Equal Filter" )
+                LdapStatesEnum.FILTER_GREATER_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, 
+                new GrammarAction( "Init Greater Or Equal Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
                         compareFilterAction(container);
                     }
-                } );
-
+                } ); 
+                
         // Filter ::= CHOICE {
         //     ...
         //     lessOrEqual    [6] AttributeValueAssertion, (Value)
@@ -483,23 +390,15 @@
         // 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][0xA6] = new GrammarTransition(
-                LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, null); 
-                
-        // Filter ::= CHOICE {
-        //     ...
-        //     approxMatch    [8] AttributeValueAssertion, (Length)
-        //     ...
-        // We have to control the length to know if we have a completed level or not.
-        super.transitions[LdapStatesEnum.FILTER_APPROX_MATCH_LENGTH][0xA8] = new GrammarTransition(
-                LdapStatesEnum.FILTER_APPROX_MATCH_LENGTH, LdapStatesEnum.FILTER_APPROX_MATCH_VALUE,
-                new GrammarAction( "Init ApproxMatch Filter" )
+                LdapStatesEnum.FILTER_LESS_OR_EQUAL_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, 
+                new GrammarAction( "Init Less Or Equal Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
                         compareFilterAction(container);
                     }
-                } );
-
+                } ); 
+                
         // Filter ::= CHOICE {
         //     ...
         //     approxMatch    [8] AttributeValueAssertion, (Value)
@@ -507,41 +406,21 @@
         // We will create the filter container (as this is an approxMatch filter,
         // we will create an AttributeValueAssertionFilter).
         super.transitions[LdapStatesEnum.FILTER_APPROX_MATCH_VALUE][0xA8] = new GrammarTransition(
-                LdapStatesEnum.FILTER_APPROX_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, null); 
+                LdapStatesEnum.FILTER_APPROX_MATCH_VALUE, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, 
+                new GrammarAction( "Init ApproxMatch Filter" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        compareFilterAction(container);
+                    }
+                } ); 
                 
         // AttributeValueAssertion ::= SEQUENCE {
         //    attributeDesc   AttributeDescription, (TAG)
         //     ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_LENGTH, null);
-
-        // AttributeValueAssertion ::= SEQUENCE {
-        //    attributeDesc   AttributeDescription, (LENGTH)
-        //     ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.FILTER_ATTRIBUTE_DESC_LENGTH][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ATTRIBUTE_DESC_LENGTH, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE, 
-                new GrammarAction( "Check AttributeDesc length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        // We will check the length against the current filter
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        Filter     currentFilter =
-                            searchRequest.getCurrentFilter();
-                        
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( currentFilter, tlv );
-                        return;
-                    }
-                });
+                LdapStatesEnum.FILTER_ATTRIBUTE_DESC_TAG, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE, null);
 
         // AttributeValueAssertion ::= SEQUENCE {
         //    attributeDesc   AttributeDescription, (VALUE)
@@ -577,34 +456,7 @@
         //    assertionValue  AssertionValue } (TAG)
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_LENGTH, null);
-
-        // AttributeValueAssertion ::= SEQUENCE {
-        //     ...
-        //    assertionValue  AssertionValue } (LENGTH)
-        // We have to check the length
-        super.transitions[LdapStatesEnum.FILTER_ASSERTION_VALUE_LENGTH][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ASSERTION_VALUE_LENGTH, LdapStatesEnum.FILTER_ASSERTION_VALUE_VALUE, 
-                new GrammarAction( "Check AssertionValue length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        // We will check the length against the current filter
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        Filter     currentFilter =
-                            searchRequest.getCurrentFilter();
-                        
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( currentFilter, tlv );
-                        return;
-                    }
-                });
+                LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_VALUE, null);
 
         // AttributeValueAssertion ::= SEQUENCE {
         //     ...
@@ -634,34 +486,7 @@
                         assertion.setAssertionValue(assertionValue);
                         
                         // We now have to get back to the nearest filter which is not terminal.
-                        unstackCurrent(searchRequest);
-                    }
-                });
-
-        // AttributeValueAssertion ::= SEQUENCE {
-        //    attributeDesc   AttributeDescription, (LENGTH)
-        //     ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.FILTER_ATTRIBUTE_DESC_LENGTH][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ATTRIBUTE_DESC_LENGTH, LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE, 
-                new GrammarAction( "Check AttributeDesc length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        // We will check the length against the current filter
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        Filter     currentFilter =
-                            searchRequest.getCurrentFilter();
-                        
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( currentFilter, tlv );
-                        return;
+                        unstackFilters( container );
                     }
                 });
 
@@ -699,15 +524,7 @@
         //    assertionValue  AssertionValue } (TAG)
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_LENGTH, null);
-
-        // Filter ::= CHOICE {
-        //     ...
-        //     present    [7] AttributeDescription, (Length)
-        //     ...
-        // nothing to do.
-        super.transitions[LdapStatesEnum.FILTER_PRESENT_LENGTH][0x87] = new GrammarTransition(
-                LdapStatesEnum.FILTER_PRESENT_LENGTH, LdapStatesEnum.FILTER_PRESENT_VALUE, null);
+                LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, LdapStatesEnum.FILTER_ASSERTION_VALUE_VALUE, null);
 
         // Filter ::= CHOICE {
         //     ...
@@ -736,21 +553,14 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(presentFilter);
                             presentFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
-
-                            searchRequest.setCurrentFilter(presentFilter);
+                            //searchRequest.setCurrentFilter(presentFilter);
                             presentFilter.setParent( searchRequest );
                             searchRequest.setFilter(presentFilter);
                         }
@@ -760,7 +570,7 @@
                         //searchRequest.setCurrentFilter(presentFilter);
                         
                         // We now have to get back to the nearest filter which is not terminal.
-                        unstackCurrent(searchRequest);
+                        unstackFilters( container );
                     }
                 } );
 
@@ -773,12 +583,11 @@
         //
         // Filter ::= CHOICE {
         //     ...
-        //     substrings      [4] SubstringFilter, (Length)
+        //     substrings      [4] SubstringFilter, (Value)
         //     ...
-        //
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_LENGTH][0xA4] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_VALUE, 
+        // Store the substring
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_VALUE][0xA4] = new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG, 
                 new GrammarAction( "Init Substring Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -800,80 +609,33 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(substringFilter);
                             substringFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
 
-                            searchRequest.setCurrentFilter(substringFilter);
                             searchRequest.setFilter(substringFilter);
                             substringFilter.setParent( searchRequest );
                         }
 
+                        searchRequest.setCurrentFilter(substringFilter);
+                        
                         // As this is a new Constructed object, we have to init its length
                         int expectedLength = tlv.getLength().getLength();
 
                         substringFilter.setExpectedLength( expectedLength );
-                        substringFilter.setCurrentLength( 0 );
-                    }
+                        substringFilter.setCurrentLength( 0 );                    }
                 } );
 
-        // Filter ::= CHOICE {
-        //     ...
-        //     substrings      [4] SubstringFilter, (Value)
-        //     ...
-        // Nothing to do.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_VALUE][0xA4] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG, null);
-
         // SubstringFilter ::= SEQUENCE {
         //     type            AttributeDescription, (Tag)
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_LENGTH, null );
-
-        // SubstringFilter ::= SEQUENCE {
-        //     type            AttributeDescription, (Length)
-        //     ...
-        // 
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_LENGTH][0x04] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_VALUE, 
-                new GrammarAction( "Init Substring type Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
-                        // Get the filter
-                        Filter currentFilter = searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        checkLength(currentFilter, tlv);
-
-                        // This is a constructed object, so we have to store its length
-                        int expectedLength = tlv.getLength().getLength();
-
-                        currentFilter.setExpectedLength( expectedLength );
-                        currentFilter.setCurrentLength( 0 );
-                        currentFilter.setParent( searchRequest );
-                    }
-                } );
+                LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_VALUE, null );
 
         // SubstringFilter ::= SEQUENCE {
         //     type            AttributeDescription, (Value)
@@ -896,6 +658,9 @@
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
                         substringFilter.setType(new LdapString(tlv.getValue().getData()));
+
+                        // We now have to get back to the nearest filter which is not terminal.
+                        unstackFilters( container );
                     }
                 } );
 
@@ -906,37 +671,7 @@
         //          ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_TAG][0x30] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_LENGTH, null );
-
-        // SubstringFilter ::= SEQUENCE {
-        //     ...
-        //     -- at least one must be present
-        //     substrings      SEQUENCE OF CHOICE { (Length)
-        //          ...
-        // Check the length.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_LENGTH][0x30] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_VALUE, 
-                new GrammarAction( "Init Substring Substring Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
-                        Filter currentFilter = searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        checkLength(currentFilter, tlv);
-                        
-                        // We have to store the length of the substring filter
-                        ((SubstringFilter)currentFilter).setSubstringsLength(tlv.getLength().getLength());
-                    }
-                } );
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_VALUE, null );
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -956,45 +691,7 @@
         //          ...
         // We have an "initial" value. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x80] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_LENGTH, null );
-
-        // SubstringFilter ::= SEQUENCE {
-        //     ...
-        //     -- at least one must be present
-        //     substrings      SEQUENCE OF CHOICE {
-        //          initial [0] LDAPString, (Length)
-        //          ...
-        // We have an "initial" value. Check the length.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_LENGTH][0x80] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_VALUE, 
-                new GrammarAction( "Init Substring Substring Initial Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
-                        SubstringFilter currentFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int newLength = currentFilter.getSubstringsLength() - tlv.getLength().getLength() - tlv.getLength().getSize() -1; 
-                        
-                        if (newLength < 0) 
-                        {
-                            throw new DecoderException("The substring filter length is exceeded by the 'initial' length");
-                        }
-                        else
-                        {
-                            currentFilter.setSubstringsLength(newLength);
-                        }
-                        
-                    }
-                });
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_VALUE, null );
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1020,6 +717,9 @@
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
                         substringFilter.setInitialSubstrings(new LdapString(tlv.getValue().getData()));
+
+                        // We now have to get back to the nearest filter which is not terminal.
+                        unstackFilters( container );
                     }
                 });
                 
@@ -1032,7 +732,7 @@
         //          ...
         // We have an 'any' value without an 'initial' value. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x81] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH, null);
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE, null);
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1043,46 +743,7 @@
         //          ...
         // We had an 'initial' substring, and now we have an 'any' substring. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x81] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH, null );
-
-        // SubstringFilter ::= SEQUENCE {
-        //     ...
-        //     -- at least one must be present
-        //     substrings      SEQUENCE OF CHOICE { 
-        //          ...
-        //          any     [1] LDAPString, (Length)
-        //          ...
-        // We had an 'initial' substring, and now we have an 'any' substring. Nothing to do.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH][0x81] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE, 
-                new GrammarAction( "Init Substring Substring any Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
-                        SubstringFilter currentFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int newLength = currentFilter.getSubstringsLength() - tlv.getLength().getLength() - tlv.getLength().getSize() -1; 
-                        
-                        if (newLength < 0) 
-                        {
-                            throw new DecoderException("The substring filter length is exceeded by the 'any' length");
-                        }
-                        else
-                        {
-                            currentFilter.setSubstringsLength(newLength);
-                        }
-                        
-                    }
-                });
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE, null );
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1109,6 +770,9 @@
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
                         substringFilter.addAnySubstrings(new LdapString(tlv.getValue().getData()));
+
+                        // We now have to get back to the nearest filter which is not terminal.
+                        unstackFilters( container );
                     }
                 });
                 
@@ -1123,7 +787,7 @@
         //
         // We have an 'final' value after an 'any' value. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH, null);
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE, null);
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1135,7 +799,7 @@
         //
         // We have an 'final' value only. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH, null);
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE, null);
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1146,45 +810,7 @@
         //     }
         // We had an 'initial' substring, and now we have an 'final' substring. Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH, null );
-
-        // SubstringFilter ::= SEQUENCE {
-        //     ...
-        //     -- at least one must be present
-        //     substrings      SEQUENCE OF CHOICE {
-        //          ...
-        //          final     [2] LDAPString, (Length)
-        // We have a "final" value. Check the length.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE, 
-                new GrammarAction( "Init Substring Substring Final Filter" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
-                        SubstringFilter currentFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int newLength = currentFilter.getSubstringsLength() - tlv.getLength().getLength() - tlv.getLength().getSize() -1; 
-                        
-                        if (newLength < 0) 
-                        {
-                            throw new DecoderException("The substring filter length is exceeded by the 'finzl' length");
-                        }
-                        else
-                        {
-                            currentFilter.setSubstringsLength(newLength);
-                        }
-                        
-                    }
-                });
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE, null );
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1210,6 +836,9 @@
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
                         substringFilter.setFinalSubstrings(new LdapString(tlv.getValue().getData()));
+
+                        // We now have to get back to the nearest filter which is not terminal.
+                        unstackFilters( container );
                     }
                 });
                 
@@ -1333,11 +962,11 @@
         //
         // Filter ::= CHOICE {
         //     ...
-        //     extensibleMatch [9] ExtensibleMatchFilter} (Length)
+        //     extensibleMatch [9] MatchingRuleAssertion} (Value)
         //
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH][0xA9] = new GrammarTransition(
-                LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH, LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE, 
+        // Nothing to do
+        super.transitions[LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE][0xA9] = new GrammarTransition(
+                LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG, 
                 new GrammarAction( "Init extensible match Filter" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -1359,78 +988,29 @@
                         if (currentFilter != null)
                         {
                             // Ok, we have a parent. The new Filter will be added to
-                            // this parent, then. We also have to check the length
-                            // against the parent.
-                            checkLength( currentFilter, tlv );
+                            // this parent, then. 
                             ((ConnectorFilter)currentFilter).addFilter(extensibleMatchFilter);
                             extensibleMatchFilter.setParent( currentFilter );
                         }
                         else
                         {
                             // No parent. This Filter will become the root.
-                            // First, check the length to see if it does not exceed its parent
-                            // expected length. (If there is no parent, we have to check the
-                            // length against the SearchRequest )
-                            checkLength( searchRequest, tlv );
-
-                            searchRequest.setCurrentFilter(extensibleMatchFilter);
                             searchRequest.setFilter(extensibleMatchFilter);
                             extensibleMatchFilter.setParent( searchRequest );
                         }
 
-                        // As this is a new Constructed object, we have to init its length
-                        int expectedLength = tlv.getLength().getLength();
+                        searchRequest.setCurrentFilter(extensibleMatchFilter);
 
-                        extensibleMatchFilter.setExpectedLength( expectedLength );
-                        extensibleMatchFilter.setCurrentLength( 0 );
+                        // We now have to get back to the nearest filter which is not terminal.
+                        unstackFilters( container );
                     }
-                } );
-
-        // Here we are dealing with extensible matches 
-        //
-        // Filter ::= CHOICE {
-        //     ...
-        //     extensibleMatch [9] MatchingRuleAssertion} (Value)
-        //
-        // Nothing to do
-        super.transitions[LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE][0xA9] = new GrammarTransition(
-                LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG, null); 
+                } ); 
 
         // MatchingRuleAssertion ::= SEQUENCE { (Tag)
         //          ...
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG][0x30] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH, null );
-
-        // MatchingRuleAssertion ::= SEQUENCE { (Length)
-        //          ...
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH][0x30] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_VALUE, 
-                new GrammarAction( "Init matching rule assertion" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        
-                        // Get the parent
-                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        checkLength(currentFilter, tlv);
-
-                        // As this is a new Constructed object, we have to init its length
-                        int expectedLength = tlv.getLength().getLength();
-
-                        currentFilter.setExpectedMatchingRuleLength( expectedLength );
-                    }
-                } );
+                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { (Value)
         //          ...
@@ -1445,43 +1025,7 @@
         //			...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG][0x81] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH, null );
-
-        // MatchingRuleAssertion ::= SEQUENCE { 
-        //          matchingRule    [1] MatchingRuleId OPTIONAL, (Length)
-        //			...
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH][0x81] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH, LdapStatesEnum.FILTER_MATCHING_RULE_VALUE, 
-                new GrammarAction( "matching rule assertion length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        
-                        // Get the parent
-                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
-                        int length = tlv.getSize();
-                        
-                        if (expectedLength < length)
-                        {
-                            throw new DecoderException("The matching rule length is larger than expected");
-                        }
-                        else
-                        {
-                            currentFilter.setExpectedMatchingRuleLength(expectedLength - length);
-                        }
-                    }
-                } );
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { 
         //          matchingRule    [1] MatchingRuleId OPTIONAL, (Value)
@@ -1513,7 +1057,7 @@
         //			...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH, null );
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { 
         //			matchingRule    [1] MatchingRuleId OPTIONAL,
@@ -1521,44 +1065,7 @@
         //			...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_MATCHING_TYPE_OR_MATCH_VALUE_TAG][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH, null );
-
-        // MatchingRuleAssertion ::= SEQUENCE {
-        //          ...
-        //          type            [2] AttributeDescription OPTIONAL, (Length)
-        //			...
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH][0x82] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH, LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE, 
-                new GrammarAction( "matching rule assertion length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        
-                        // Get the parent
-                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
-                        int length = tlv.getSize();
-                        
-                        if (expectedLength < length)
-                        {
-                            throw new DecoderException("The matching rule length is larger than expected");
-                        }
-                        else
-                        {
-                            currentFilter.setExpectedMatchingRuleLength(expectedLength - length);
-                        }
-                    }
-                } );
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { 
         //          ...
@@ -1591,44 +1098,7 @@
         //			...
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG][0x83] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH, null );
-
-        // MatchingRuleAssertion ::= SEQUENCE { 
-        //			...
-        //          matchValue      [3] AssertionValue, (Length)
-        //			...
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH][0x83] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_VALUE, 
-                new GrammarAction( "matching match value length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        
-                        // Get the parent
-                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
-                        int length = tlv.getSize();
-                        
-                        if (expectedLength < length)
-                        {
-                            throw new DecoderException("The matching rule length is larger than expected");
-                        }
-                        else
-                        {
-                            currentFilter.setExpectedMatchingRuleLength(expectedLength - length);
-                        }
-                    }
-                } );
+                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { 
         //          ...
@@ -1660,43 +1130,7 @@
         //          dnAttributes    [4] BOOLEAN DEFAULT FALSE } (Tag)
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG][0x84] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH, null );
-
-        // MatchingRuleAssertion ::= SEQUENCE { 
-        //			...
-        //          dnAttributes    [4] BOOLEAN DEFAULT FALSE } (Length)
-        // Check the length
-        super.transitions[LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH][0x84] = new GrammarTransition(
-                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_VALUE, 
-                new GrammarAction( "matching dnAttributes length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        
-                        // Get the parent
-                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        
-                        // Check the length
-                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
-                        int length = tlv.getSize();
-                        
-                        if (expectedLength < length)
-                        {
-                            throw new DecoderException("The matching rule length is larger than expected");
-                        }
-                        else
-                        {
-                            currentFilter.setExpectedMatchingRuleLength(expectedLength - length);
-                        }
-                    }
-                } );
+                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_VALUE, null );
 
         // MatchingRuleAssertion ::= SEQUENCE { 
         //          ...
@@ -1758,52 +1192,44 @@
      *  - it's a final element (ie an element which cannot contains a Filter)
      *  - its current length equals its expected length.
      * 
-     * @param searchRequest The request being decoded
+     * @param IAsn1Container The container being decoded
      */
-    private void unstackCurrent(SearchRequest searchRequest)
+    private void unstackFilters( IAsn1Container container ) throws DecoderException
     {
-        Filter currentFilter = searchRequest.getCurrentFilter();
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage      ldapMessage          =   ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
         
-        while (currentFilter != null)
-        {
-            if ( ( currentFilter instanceof AndFilter ) | ( currentFilter instanceof OrFilter ) | ( currentFilter instanceof NotFilter ) )
-            {
-                if ( currentFilter.getExpectedLength() == currentFilter.getCurrentLength())
-                {
-                    // The current element is not terminal, but it has been fully decoded
-                    // so we will pop it from the stack
-                    Asn1Object element = currentFilter.getParent();
-                    
-                    // We have to check that the parent is a Filter.
-                    if (element instanceof Filter)
-                    {
-                        currentFilter = (Filter)element;
-                    }
-                    else
-                    {
-                        // The element is a SearchRequest, so the stack is
-                        // empty. It's over !
-                        currentFilter = null;
-                        return;
-                    }
-                }
-                else
-                {
-                    // Ok, we have a non terminal element which is not fully decoded.
-                    searchRequest.setCurrentFilter(currentFilter);
-                    return;
-                }
-            } 
-            else
-            {
-                // The current element is a terminal element
-                currentFilter = (Filter)currentFilter.getParent();
-            }
-        }
+        TLV tlv            = ldapMessageContainer.getCurrentTLV();
         
-        return;
-    }
+        // 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.getParent() instanceof Filter )
+	            {
+	                currentFilter = (Filter)currentFilter.getParent();
+	            }
+	            else
+	            {
+	                currentFilter = null;
+	                break;
+	            }
+	        }
+	        
+	        searchRequest.setCurrentFilter(currentFilter);
+	    }
+    }
+    
     /**
      * This method is used by each comparaison filters (=, <=, >= or ~=).
      * 
@@ -1829,31 +1255,18 @@
         if (currentFilter != null)
         {
             // Ok, we have a parent. The new Filter will be added to
-            // this parent, then. We also have to check the length
-            // against the parent.
-            checkLength( currentFilter, tlv );
+            // this parent, then. 
             ((ConnectorFilter)currentFilter).addFilter(filter);
             filter.setParent( currentFilter );
         }
         else
         {
             // No parent. This Filter will become the root.
-            // First, check the length to see if it does not exceed its parent
-            // expected length. (If there is no parent, we have to check the
-            // length against the SearchRequest )
-            checkLength( searchRequest, tlv );
-
-            searchRequest.setCurrentFilter(filter);
+            //searchRequest.setCurrentFilter(filter);
             filter.setParent( searchRequest );
             searchRequest.setFilter(filter);
         }
 
         searchRequest.setCurrentFilter(filter);
-
-        // As this is a new Constructed object, we have to init its length
-        int expectedLength = tlv.getLength().getLength();
-
-        filter.setExpectedLength( expectedLength );
-        filter.setCurrentLength( 0 );
     }
 }



Mime
View raw message