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 2005/06/22 07:27:32 UTC

svn commit: r191769 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java

Author: elecharny
Date: Tue Jun 21 22:27:32 2005
New Revision: 191769

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

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java?rev=191769&r1=191768&r2=191769&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java Tue Jun 21 22:27:32 2005
@@ -79,13 +79,13 @@
         //     ...
         // Nothing to do
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_TAG][0x63] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_TAG, LdapStatesEnum.SEARCH_REQUEST_LENGTH, null );
+                LdapStatesEnum.SEARCH_REQUEST_TAG, LdapStatesEnum.SEARCH_REQUEST_VALUE, null );
 
         // LdapMessage   ::= ... SearchRequest ...
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE { ... (Length)
-        // We have to allocate a SearchRequest.
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_LENGTH][0x63] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_LENGTH, LdapStatesEnum.SEARCH_REQUEST_VALUE,
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE { ... (Value)
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_VALUE][0x63] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_VALUE, LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_TAG,
                 new GrammarAction( "Init SearchRequest" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -96,74 +96,21 @@
                         LdapMessage      ldapMessage          =
                             ldapMessageContainer.getLdapMessage();
 
-                        checkLength( ldapMessageContainer.getLdapMessage(),
-                            ldapMessageContainer.getCurrentTLV() );
-
                         // Now, we can allocate the SearchRequest
-                        SearchRequest searchRequest = new SearchRequest();
-
-                        // As this is a new Constructed object, we have to init its length
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        int expectedLength = tlv.getLength().getLength();
-
-                        searchRequest.setExpectedLength( expectedLength );
-                        searchRequest.setCurrentLength( 0 );
-                        searchRequest.setParent( ldapMessage );
-
                         // And we associate it to the ldapMessage Object
-                        ldapMessage.setProtocolOP( searchRequest );
+                        ldapMessage.setProtocolOP( new SearchRequest() );
                     }
-                } );
-
-        // LdapMessage   ::= ... SearchRequest ...
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE { ... (Value)
-        // Nothing to do.
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_VALUE][0x63] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_VALUE, LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_TAG,
-                null);
+                });
 
         // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
         //    baseObject      LDAPDN, (Tag)
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_TAG, LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_TAG, LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
-        //    baseObject      LDAPDN, (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_LENGTH][0x04] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_VALUE,
-                new GrammarAction( "Check base object length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-
-                        // We have to handle the special case of a 0 length base object,
-                        // which is not permitted
-                        if ( tlv.getLength().getLength() == 0 )
-                        {
-                            throw new DecoderException("The base object must not be null");
-                        }
-
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
         //    baseObject      LDAPDN, (Value)
         //    ...
         // We have a value for the base object, we will store it in the message
@@ -186,6 +133,13 @@
                         // We have to check that this is a correct DN
                         LdapDN baseObject = null;
                         
+                        // We have to handle the special case of a 0 length base object,
+                        // which is not permitted
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            throw new DecoderException("The base object must not be null");
+                        }
+
                         try
                         {
                             baseObject = new LdapDN(tlv.getValue().getData());
@@ -211,40 +165,11 @@
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG][0x0A] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG, LdapStatesEnum.SEARCH_REQUEST_SCOPE_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG, LdapStatesEnum.SEARCH_REQUEST_SCOPE_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
         //    ...
-        //    scope           ENUMERATED { 
-        //        baseObject              (0),
-        //        singleLevel             (1),
-        //        wholeSubtree            (2) },  (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_SCOPE_LENGTH][0x0A] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_SCOPE_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_SCOPE_VALUE,
-                new GrammarAction( "Check scope length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
-        //    ...
         //    scope           ENUMERATED {
         //        baseObject              (0),
         //        singleLevel             (1),
@@ -288,7 +213,7 @@
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_TAG][0x0A] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_TAG, LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_TAG, LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE {
@@ -297,36 +222,6 @@
         //        neverDerefAliases       (0),
         //        derefInSearching        (1),
         //        derefFindingBaseObj     (2),
-        //        derefAlways             (3) }, (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_LENGTH][0x0A] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_VALUE,
-                new GrammarAction( "Check derefAliases length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-        //    ...
-        //    derefAliases    ENUMERATED {
-        //        neverDerefAliases       (0),
-        //        derefInSearching        (1),
-        //        derefFindingBaseObj     (2),
         //        derefAlways             (3) }, (Value)
         //    ...
         // We have a value for the derefAliases, we will store it in the message
@@ -363,37 +258,11 @@
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_TAG][0x02] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_TAG, LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_TAG, LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE {
         //    ...
-        //    sizeLimit  INTEGER (0 .. maxInt), (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_LENGTH][0x02] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_VALUE,
-                new GrammarAction( "Check sizeLimit length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-        //    ...
         //    sizeLimit  INTEGER (0 .. maxInt), (Value)
         //    ...
         // We have a value for the sizeLimit, we will store it in the message
@@ -431,37 +300,11 @@
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_TAG][0x02] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_TAG, LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_TAG, LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE {
         //    ...
-        //    timeLimit  INTEGER (0 .. maxInt), (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_LENGTH][0x02] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_VALUE,
-                new GrammarAction( "Check timeLimit length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-        //    ...
         //    timeLimit  INTEGER (0 .. maxInt), (Value)
         //    ...
         // We have a value for the timeLimit, we will store it in the message
@@ -499,37 +342,11 @@
         //    ...
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_TAG][0x01] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_TAG, LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_TAG, LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_VALUE,
                 null);
         
         // SearchRequest ::= [APPLICATION 3] SEQUENCE {
         //    ...
-        //    typesOnly       BOOLEAN, (Length)
-        //    ...
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_LENGTH][0x01] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_VALUE,
-                new GrammarAction( "Check typesOnly length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        return;
-                    }
-                } );
-        
-        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
-        //    ...
         //    typesOnly       BOOLEAN, (Value)
         //    ...
         // We have a value for the typesOnly, we will store it in the message.
@@ -711,41 +528,13 @@
         //    ...
         // We have to check that the filter has been created.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0x30] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
                 null);
         
         // ...
         //    attributes      AttributeDescriptionList }
         // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
         //    ...
-        // We have to check the length
-        // We also have to store the expected length of the list.
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_LENGTH][0x30] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
-                new GrammarAction( "Check Attribute Description list length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( searchRequest, tlv );
-                        searchRequest.setAttributesExpectedLength(tlv.getLength().getLength());
-                        return;
-                    }
-                } );
-        
-        // ...
-        //    attributes      AttributeDescriptionList }
-        // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
-        //    ...
         // We have to create an array of elements to store the list of attributes
         // to retrieve. We don't know yet how many attributes we will read so we
         // will allocate an ArrayList.
@@ -772,40 +561,8 @@
         // AttributeDescription ::= LDAPString
         // Nothing to do.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG][0x04] = new GrammarTransition(
-                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG, LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LENGTH,
+                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG, LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE,
                 null);
-        
-        // AttributeDescription ::= LDAPString
-        // We have to check the length
-        super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LENGTH][0x04] =
-            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LENGTH,
-                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE,
-                new GrammarAction( "Check Attribute Description length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
-                            container;
-
-                        SearchRequest     searchRequest =
-                            ldapMessageContainer.getLdapMessage().getSearchRequest();
-
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        int expectedLength = searchRequest.getAttributesExpectedLength();
-
-                        int currentLength  = tlv.getLength().getLength() + tlv.getSize();
-
-                        if ( expectedLength < currentLength )
-                        {
-                            throw new DecoderException(
-                                "The current length is longer than the expected length" );
-                        }
-
-                        return;
-                    }
-                } );
         
         // ...
         //    attributes      AttributeDescriptionList }