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/10 00:53:25 UTC

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

Author: elecharny
Date: Thu Jun  9 15:53:24 2005
New Revision: 189845

URL: http://svn.apache.org/viewcvs?rev=189845&view=rev
Log:
Added the last two grammar productions, the ones that we have after the Filter in LDAP grammar

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=189845&r1=189844&r2=189845&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 Thu Jun  9 15:53:24 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1.ldap.codec.grammars;
 
+import java.util.ArrayList;
+
 import org.apache.asn1.DecoderException;
 import org.apache.asn1.ber.containers.IAsn1Container;
 import org.apache.asn1.ber.grammar.AbstractGrammar;
@@ -27,6 +29,7 @@
 import org.apache.asn1.ldap.codec.LdapConstants;
 import org.apache.asn1.ldap.codec.LdapMessageContainer;
 import org.apache.asn1.ldap.codec.primitives.LdapDN;
+import org.apache.asn1.ldap.codec.primitives.LdapString;
 import org.apache.asn1.ldap.codec.utils.IntegerDecoder;
 import org.apache.asn1.ldap.pojo.LdapMessage;
 import org.apache.asn1.ldap.pojo.SearchRequest;
@@ -705,6 +708,126 @@
                 LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
                 null );
 
+
+        // ...
+        //    attributes      AttributeDescriptionList }
+        // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Tag)
+        //    ...
+        // 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,
+                null);
+        
+        // ...
+        //    attributes      AttributeDescriptionList }
+        // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
+        //    ...
+        // We have to check the length
+        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 );
+                        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.
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE][0x30] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG,
+                new GrammarAction( "store Attribute Description List value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequest     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        searchRequest.setAttributes( new ArrayList() );
+
+                        return;
+                    }
+                } );
+        
+        // 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,
+                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();
+
+                        // checkLength( searchRequest, tlv );
+                        // TODO : Fix the check, as we need to check length against the SEQ OF.
+                        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.
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE][0x04] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG,
+                new GrammarAction( "store Attribute Description value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequest     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+                        
+                        searchRequest.addAttribute( LdapString.parse(tlv.getValue().getData()));
+
+                        return;
+                    }
+                } );
+        
     }
 
     //~ Methods ------------------------------------------------------------------------------------