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/07 00:27:23 UTC

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

Author: elecharny
Date: Mon Jun  6 15:27:21 2005
New Revision: 185065

URL: http://svn.apache.org/viewcvs?rev=185065&view=rev
Log:
Added the very first draft of the searchRequest grammar. A lot of work need to be done, 
as half of the grammar is not implemented, but it's already working for a subset, so, consider
this commit as a backup.

(it took me three days to reach this point, I don't want to loose everything if my computer crash !)

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

Added: 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=185065&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java Mon Jun  6 15:27:21 2005
@@ -0,0 +1,721 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ldap.codec.grammars;
+
+import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ber.grammar.AbstractGrammar;
+import org.apache.asn1.ber.grammar.GrammarAction;
+import org.apache.asn1.ber.grammar.GrammarTransition;
+import org.apache.asn1.ber.grammar.IGrammar;
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ber.tlv.Value;
+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.utils.IntegerDecoder;
+import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
+import org.apache.asn1.ldap.pojo.SearchRequestPOJO;
+import org.apache.asn1.util.MutableString;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * This class implements the SearchRequest LDAP message. All the actions are declared in this
+ * class. As it is a singleton, these declaration are only done once.
+ * 
+ * If an action is to be added or modified, this is where the work is to be done !
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchRequestGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = Logger.getLogger( SearchRequestGrammar.class );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. SearchRequestGrammar is a singleton */
+    private static IGrammar instance = new SearchRequestGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchRequestGrammar object.
+     */
+    private SearchRequestGrammar()
+    {
+        name       = SearchRequestGrammar.class.getName();
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // Initialisation of the transitions table
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_REQUEST_STATE][256];
+
+        //============================================================================================
+        // SearchRequest Message
+        //============================================================================================
+        // LdapMessage   ::= ... SearchRequest ...
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE { (Tag)
+        //     ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_TAG][0x63] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_TAG, LdapStatesEnum.SEARCH_REQUEST_LENGTH, null );
+
+        // LdapMessage   ::= ... SearchRequest ...
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE { ... (Length)
+        // We have to allocate a SearchRequestPOJO.
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_LENGTH][0x63] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_LENGTH, LdapStatesEnum.SEARCH_REQUEST_VALUE,
+                new GrammarAction( "Init SearchRequest" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessagePOJO      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        checkLength( ldapMessageContainer.getLdapMessage(),
+                            ldapMessageContainer.getCurrentTLV() );
+
+                        // Now, we can allocate the SearchRequestPOJO
+                        SearchRequestPOJO searchRequest = new SearchRequestPOJO();
+
+                        // 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.setFather( ldapMessage );
+
+                        // And we associate it to the ldapMessage POJO
+                        ldapMessage.setProtocolOP( 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,
+                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;
+
+                        SearchRequestPOJO     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
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_VALUE][0x04] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_BASE_OBJECT_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG,
+                new GrammarAction( "store base object value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // We have to check that this is a correct DN
+                        MutableString baseObject = null;
+                        
+                        try
+                        {
+                            baseObject = LdapDN.parseDN(tlv.getValue().getData());
+                        }
+                        catch (DecoderException de)
+                        {
+                            log.error("The DN " + baseObject.toString() + " is invalid");
+                            throw de;
+                        }
+                        
+                        searchRequest.setBaseObject(baseObject);
+
+                        return;
+                    }
+                } );
+
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    scope           ENUMERATED {
+        //        baseObject              (0),
+        //        singleLevel             (1),
+        //        wholeSubtree            (2) }, (Tag)
+        //    ...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG][0x0A] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_SCOPE_TAG, LdapStatesEnum.SEARCH_REQUEST_SCOPE_LENGTH,
+                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;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        checkLength( searchRequest, tlv );
+                        return;
+                    }
+                } );
+        
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE { 
+        //    ...
+        //    scope           ENUMERATED {
+        //        baseObject              (0),
+        //        singleLevel             (1),
+        //        wholeSubtree            (2) }, (Value)
+        //    ...
+        // We have a value for the scope, we will store it in the message
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_SCOPE_VALUE][0x0A] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_SCOPE_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_TAG,
+                new GrammarAction( "store scope value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // We have to check that this is a correct scope
+                        Value value   = tlv.getValue();
+
+                        int   scope = IntegerDecoder.parse( value, LdapConstants.SCOPE_BASE_OBJECT, LdapConstants.SCOPE_WHOLE_SUBTREE );
+                        
+                        searchRequest.setScope(scope);
+
+                        return;
+                    }
+                } );
+
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    derefAliases    ENUMERATED {
+        //        neverDerefAliases       (0),
+        //        derefInSearching        (1),
+        //        derefFindingBaseObj     (2),
+        //        derefAlways             (3) }, (Tag)
+        //    ...
+        // 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,
+                null);
+        
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    derefAliases    ENUMERATED {
+        //        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;
+
+                        SearchRequestPOJO     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
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_VALUE][0x0A] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_DEREF_ALIASES_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_TAG,
+                new GrammarAction( "store derefAliases value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // We have to check that this is a correct derefAliases
+                        Value value   = tlv.getValue();
+
+                        int   derefAliases = IntegerDecoder.parse( value, LdapConstants.NEVER_DEREF_ALIASES, LdapConstants.DEREF_ALWAYS );
+                        
+                        searchRequest.setDerefAliases( derefAliases );
+
+                        return;
+                    }
+                } );
+
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    sizeLimit  INTEGER (0 .. maxInt), (Tag)
+        //    ...
+        // 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,
+                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;
+
+                        SearchRequestPOJO     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
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_VALUE][0x02] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_SIZE_LIMIT_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_TAG,
+                new GrammarAction( "store sizeLimit value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // The current TLV should be a integer
+                        // We get it and store it in sizeLimit
+                        Value value     = tlv.getValue();
+
+                        int   sizeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+
+                        searchRequest.setSizeLimit( sizeLimit );
+
+                        return;
+                    }
+                } );
+
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    timeLimit  INTEGER (0 .. maxInt), (Tag)
+        //    ...
+        // 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,
+                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;
+
+                        SearchRequestPOJO     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
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_VALUE][0x02] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_TIME_LIMIT_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_TAG,
+                new GrammarAction( "store timeLimit value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // The current TLV should be a integer
+                        // We get it and store it in timeLimit
+                        Value value     = tlv.getValue();
+
+                        int   timeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+
+                        searchRequest.setTimeLimit( timeLimit );
+
+                        return;
+                    }
+                } );
+
+        // SearchRequest ::= [APPLICATION 3] SEQUENCE {
+        //    ...
+        //    typesOnly       BOOLEAN, (Tag)
+        //    ...
+        // 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,
+                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;
+
+                        SearchRequestPOJO     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.
+        // The next transition will deal with the Filter. As a filter could contains
+        // sub-filter, we will initialize the filter POJO right here. 
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_VALUE][0x01] =
+            new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_TYPES_ONLY_VALUE,
+                LdapStatesEnum.SEARCH_REQUEST_FILTER,
+                new GrammarAction( "store typesOnly value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+
+                        SearchRequestPOJO     searchRequest =
+                            ldapMessageContainer.getLdapMessage().getSearchRequest();
+
+                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+
+                        // We get the value. If it's a 0, it's a FALSE. If it's
+                        // a FF, it's a TRUE. Any other value should be an error,
+                        // but we could relax this constraint. So if we have something
+                        // which is not 0, it will be interpreted as TRUE, but we
+                        // will generate a warning.
+                        Value value     = tlv.getValue();
+
+                        int  typesOnly = IntegerDecoder.parse( value, 0, 255 );
+
+                        searchRequest.setTypesOnly( typesOnly != 0 );
+
+                        if ( ( typesOnly != 0 ) && (typesOnly != 255 ) ) 
+                        {
+                            log.warn("A boolean must be encoded with a 0x00 or a 0xFF value");
+                        }
+                        
+                        // Allocate the FilterPOJO now.
+                        // searchRequest.setFilter(new FilterPOJO());
+                        
+                        return;
+                    }
+                } );
+
+        //********************************************************************************************
+        // Here we are dealing with the Search Request filter. 
+        // If the Tag is 0xA0, then it's an and Filter
+        // If the Tag is 0xA1, then it's an or Filter
+        // If the Tag is 0xA2, then it's a not Filter
+        // If the Tag is 0xA3, then it's an equalityMatch Filter
+        // If the Tag is 0xA4, then it's a substrings Filter
+        // If the Tag is 0xA5, then it's a greaterOrEqual Filter
+        // If the Tag is 0xA6, then it's a lessOrEqual Filter
+        // If the Tag is 0x87, then it's a present Filter
+        // If the Tag is 0xA8, then it's an approxMatch Filter
+        // If the Tag is 0xA9, then it's an extensibleMatch Filter
+        //********************************************************************************************
+
+        //--------------------------------------------------------------------------------------------
+        // And Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   and             [0] SET OF Filter,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA0] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // Or Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   or             [0] SET OF Filter,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA1] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // Not Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   not             [2] Filter,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA2] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // EqualityMatch Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   equalityMatch   [3] AttributeValueAssertion,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA3] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // Substrings Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   substrings      [4] SubstringFilter,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA4] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // GreaterOrEqual Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   greaterOrEqual  [5] AttributeValueAssertion,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA5] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // LessOrEqual Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   lessOrEqual     [6] AttributeValueAssertion,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA6] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // Present Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   present         [7] AttributeDescription,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0x87] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // ApproxMatch Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   approxMatch     [8] AttributeValueAssertion,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA8] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+        //--------------------------------------------------------------------------------------------
+        // ExtensibleMatch Filter Message.
+        //--------------------------------------------------------------------------------------------
+        // Filter ::= CHOICE {
+        //   ...
+        //   extensibleMatch  [9] MatchingRuleAssertion,
+        //   ...
+        // We have to switch to the Filter grammar
+        super.transitions[LdapStatesEnum.SEARCH_REQUEST_FILTER][0xA9] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_REQUEST_FILTER, LdapStatesEnum.FILTER_GRAMMAR_SWITCH,
+                null );
+
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar
+     *
+     * @return An instance on the LdapMessage Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}