directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r452497 [6/9] - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/abandon/ main/java/org/apache/directory/shared/ldap/codec/add/ main/java/org/apache/dir...
Date Tue, 03 Oct 2006 13:49:46 GMT
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectGrammar.java Tue Oct  3 06:49:43 2006
@@ -44,10 +44,10 @@
  * 
  * <pre>
  *  GracefulDisconnect ::= SEQUENCE {
- *                         timeOffline INTEGER (0..720) DEFAULT 0,
- *                         delay [0] INTEGER (0..86400) DEFAULT 0,
- *                         replicatedContexts Referral OPTIONAL
- *              }
+ *      timeOffline INTEGER (0..720) DEFAULT 0,
+ *      delay [0] INTEGER (0..86400) DEFAULT 0,
+ *      replicatedContexts Referral OPTIONAL
+ * }
  *  
  *  Referral ::= SEQUENCE OF LDAPURL
  *  
@@ -71,6 +71,100 @@
 
 
     /**
+     * The action used to store a Time Offline.
+     */
+    GrammarAction storeDelay = new GrammarAction( "Set Graceful Disconnect Delay" )
+    {
+        public void action( IAsn1Container container ) throws DecoderException
+        {
+            GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
+            Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
+    
+            try
+            {
+                int delay = IntegerDecoder.parse( value, 0, 86400 );
+    
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Delay = " + delay );
+                }
+    
+                gracefulDisconnectContainer.getGracefulDisconnect().setDelay( delay );
+                gracefulDisconnectContainer.grammarEndAllowed( true );
+            }
+            catch ( IntegerDecoderException e )
+            {
+                String msg = "failed to decode the delay, the value should be between 0 and 86400 seconds, it is '"
+                    + StringTools.dumpBytes( value.getData() ) + "'";
+                log.error( msg );
+                throw new DecoderException( msg );
+            }
+        }
+    };
+    
+    /**
+     * The action used to store a referral.
+     */
+    GrammarAction storeReferral = new GrammarAction( "Stores a referral" )
+    {
+        public void action( IAsn1Container container ) throws DecoderException
+        {
+            GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
+            Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
+
+            try
+            {
+                LdapURL url = new LdapURL( value.getData() );
+                gracefulDisconnectContainer.getGracefulDisconnect().addReplicatedContexts( url );
+                gracefulDisconnectContainer.grammarEndAllowed( true );
+                
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Stores a referral : {}", url );
+                }
+            }
+            catch ( LdapURLEncodingException e )
+            {
+                String msg = "failed to decode the URL '" + StringTools.dumpBytes( value.getData() ) + "'";
+                log.error( msg );
+                throw new DecoderException( msg );
+            }
+        }
+    };
+    
+    /**
+     * The action used to store a Time Offline.
+     */
+    GrammarAction storeTimeOffline = new GrammarAction( "Set Graceful Disconnect time offline" )
+    {
+        public void action( IAsn1Container container ) throws DecoderException
+        {
+            GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
+            Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
+
+            try
+            {
+                int timeOffline = IntegerDecoder.parse( value, 0, 720 );
+
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Time Offline = " + timeOffline );
+                }
+
+                gracefulDisconnectContainer.getGracefulDisconnect().setTimeOffline( timeOffline );
+                gracefulDisconnectContainer.grammarEndAllowed( true );
+            }
+            catch ( IntegerDecoderException e )
+            {
+                String msg = "failed to decode the timeOffline, the value should be between 0 and 720 minutes, it is '"
+                    + StringTools.dumpBytes( value.getData() ) + "'";
+                log.error( msg );
+                throw new DecoderException( msg );
+            }
+        }
+    };
+
+    /**
      * Creates a new GracefulDisconnectGrammar object.
      */
     private GracefulDisconnectGrammar()
@@ -82,19 +176,17 @@
         super.transitions = new GrammarTransition[GracefulDisconnectStatesEnum.LAST_GRACEFUL_DISCONNECT_STATE][256];
 
         /**
-         * GracefulDisconnect ::= SEQUENCE { (Tag) ... Nothing to do...
-         */
-        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_TAG,
-            GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { (Value) ... Creates the
-         * GracefulDisconnect object
-         */
-        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_VALUE,
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG, new GrammarAction(
+         * Transition from init state to graceful disconnect
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         * 
+         * Creates the GracefulDisconnect object
+         */
+        super.transitions[GracefulDisconnectStatesEnum.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.INIT_GRAMMAR_STATE,
+                                    GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE, 
+                                    UniversalTag.SEQUENCE_TAG,
+                new GrammarAction(
                 "Init Graceful Disconnect" )
             {
                 public void action( IAsn1Container container )
@@ -107,167 +199,134 @@
             } );
 
         /**
-         * GracefulDisconnect ::= SEQUENCE { timeOffline INTEGER (0..720)
-         * DEFAULT 0, (Tag) ... Nothing to do
-         */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG,
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Tag) ... We have no TimeOffline. Nothing to do.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG,
-            GracefulDisconnectStatesEnum.DELAY_VALUE, null );
+         * Transition from graceful disconnect to time offline
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     timeOffline INTEGER (0..720) DEFAULT 0, 
+         *     ... 
+         *     
+         * Set the time offline value into the GracefulDisconnect object.    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE][UniversalTag.INTEGER_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
+                                    GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE, 
+                                    UniversalTag.INTEGER_TAG, 
+                storeTimeOffline );
+        
+        /**
+         * Transition from graceful disconnect to delay
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     delay [0] INTEGER (0..86400) DEFAULT 0,
+         *     ... 
+         *     
+         * Set the delay value into the GracefulDisconnect object.    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
+                                    GracefulDisconnectStatesEnum.DELAY_STATE, 
+                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG, 
+                storeDelay );
+        
+        /**
+         * Transition from graceful disconnect to replicated Contexts
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     replicatedContexts Referral OPTIONAL } 
+         *     
+         * Referral ::= SEQUENCE OF LDAPURL
+         *     
+         * Get some replicated contexts. Nothing to do    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
+                                    GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
+                                    UniversalTag.SEQUENCE_TAG, null );
+        
+        /**
+         * Transition from time offline to delay
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     delay [0] INTEGER (0..86400) DEFAULT 0,
+         *     ... 
+         *     
+         * Set the delay value into the GracefulDisconnect object.    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE,
+                                    GracefulDisconnectStatesEnum.DELAY_STATE, 
+                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG,
+                storeDelay );
+
+        /**
+         * Transition from time offline to replicated Contexts
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     replicatedContexts Referral OPTIONAL } 
+         *     
+         * Referral ::= SEQUENCE OF LDAPURL
+         *     
+         * Get some replicated contexts. Nothing to do    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE,
+                                    GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
+                                    UniversalTag.SEQUENCE_TAG, null );
+        
+        /**
+         * Transition from delay to replicated contexts
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     replicatedContexts Referral OPTIONAL } 
+         *     
+         * Referral ::= SEQUENCE OF LDAPURL
+         *     
+         * Get some replicated contexts. Nothing to do    
+         */
+        super.transitions[GracefulDisconnectStatesEnum.DELAY_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.DELAY_STATE,
+                                    GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE, 
+                                    UniversalTag.SEQUENCE_TAG, null );
+        
+        /**
+         * Transition from replicated contexts to referral
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     replicatedContexts Referral OPTIONAL } 
+         *     
+         * Referral ::= SEQUENCE OF LDAPURL
+         *     
+         * Stores the referral
+         */
+        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
+                                    GracefulDisconnectStatesEnum.REFERRAL_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                storeReferral );
+
+        /**
+         * Transition from referral to referral
+         * 
+         * GracefulDisconnect ::= SEQUENCE { 
+         *     ... 
+         *     replicatedContexts Referral OPTIONAL } 
+         *     
+         * Referral ::= SEQUENCE OF LDAPURL
+         *     
+         * Stores the referral
+         */
+        super.transitions[GracefulDisconnectStatesEnum.REFERRAL_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.REFERRAL_STATE,
+                                    GracefulDisconnectStatesEnum.REFERRAL_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                storeReferral );
 
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... replicatedContexts Referral
-         * OPTIONAL } Referral ::= SEQUENCE OF LDAPURL (Tag) We have no
-         * TimeOffline nor delay, just a replicatedContexts. Nothing to do.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG,
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { timeOffline INTEGER (0..720)
-         * DEFAULT 0, (Value) ... Set the time offline value into the
-         * GracefulDisconnect object.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_VALUE][UniversalTag.INTEGER_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.TIME_OFFLINE_VALUE,
-            GracefulDisconnectStatesEnum.DELAY_OR_REPLICATED_OR_END_TAG, new GrammarAction(
-                "Set Graceful Disconnect time offline" )
-            {
-                public void action( IAsn1Container container ) throws DecoderException
-                {
-                    GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
-                    Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
-
-                    try
-                    {
-                        int timeOffline = IntegerDecoder.parse( value, 0, 720 );
-
-                        if ( IS_DEBUG )
-                        {
-                            log.debug( "Time Offline = " + timeOffline );
-                        }
-
-                        gracefulDisconnectContainer.getGracefulDisconnect().setTimeOffline( timeOffline );
-                        gracefulDisconnectContainer.grammarEndAllowed( true );
-                    }
-                    catch ( IntegerDecoderException e )
-                    {
-                        String msg = "failed to decode the timeOffline, the value should be between 0 and 720 minutes, it is '"
-                            + StringTools.dumpBytes( value.getData() ) + "'";
-                        log.error( msg );
-                        throw new DecoderException( msg );
-                    }
-                }
-            } );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Tag) ... We have had a TimeOffline, and now we are
-         * reading the delay. Nothing to do.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.DELAY_OR_REPLICATED_OR_END_TAG][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.DELAY_OR_REPLICATED_OR_END_TAG, GracefulDisconnectStatesEnum.DELAY_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Value) ... Set the delay value into the
-         * GracefulDisconnect object.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.DELAY_VALUE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.DELAY_VALUE, GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_OR_END_TAG,
-            new GrammarAction( "Set Graceful Disconnect Delay" )
-            {
-                public void action( IAsn1Container container ) throws DecoderException
-                {
-                    GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
-                    Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
-
-                    try
-                    {
-                        int delay = IntegerDecoder.parse( value, 0, 86400 );
-
-                        if ( IS_DEBUG )
-                        {
-                            log.debug( "Delay = " + delay );
-                        }
-
-                        gracefulDisconnectContainer.getGracefulDisconnect().setDelay( delay );
-                        gracefulDisconnectContainer.grammarEndAllowed( true );
-                    }
-                    catch ( IntegerDecoderException e )
-                    {
-                        String msg = "failed to decode the delay, the value should be between 0 and 86400 seconds, it is '"
-                            + StringTools.dumpBytes( value.getData() ) + "'";
-                        log.error( msg );
-                        throw new DecoderException( msg );
-                    }
-                }
-            } );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... replicatedContexts Referral
-         * OPTIONAL } Referral ::= SEQUENCE OF LDAPURL (Tag) We have a referral
-         * sequence. Nothing to do.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_OR_END_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_OR_END_TAG,
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... replicatedContexts Referral
-         * OPTIONAL } Referral ::= SEQUENCE OF LDAPURL (Value) We have a
-         * sequence, so we will have Octet String following. Nothing to do.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_VALUE,
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_OR_END_TAG, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... replicatedContexts Referral
-         * OPTIONAL } Referral ::= SEQUENCE OF LDAPURL LDAPURL ::= LDAPString
-         * (Tag) We have a referral. It can be the first one, or one of the
-         * following. Nothing to do
-         */
-        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_OR_END_TAG][UniversalTag.OCTET_STRING] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_OR_END_TAG,
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_VALUE, null );
-
-        /**
-         * GracefulDisconnect ::= SEQUENCE { ... replicatedContexts Referral
-         * OPTIONAL } Referral ::= SEQUENCE OF LDAPURL (Tag) LDAPURL ::=
-         * LDAPString (Tag) Read and store a referral url.
-         */
-        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_VALUE][UniversalTag.OCTET_STRING] = new GrammarTransition(
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_VALUE,
-            GracefulDisconnectStatesEnum.REPLICATED_CONTEXT_OR_END_TAG, new GrammarAction( "Replicated context URL" )
-            {
-                public void action( IAsn1Container container ) throws DecoderException
-                {
-                    GracefulDisconnectContainer gracefulDisconnectContainer = ( GracefulDisconnectContainer ) container;
-                    Value value = gracefulDisconnectContainer.getCurrentTLV().getValue();
-
-                    try
-                    {
-                        LdapURL url = new LdapURL( value.getData() );
-                        gracefulDisconnectContainer.getGracefulDisconnect().addReplicatedContexts( url );
-                        gracefulDisconnectContainer.grammarEndAllowed( true );
-                    }
-                    catch ( LdapURLEncodingException e )
-                    {
-                        String msg = "failed to decode the URL '" + StringTools.dumpBytes( value.getData() ) + "'";
-                        log.error( msg );
-                        throw new DecoderException( msg );
-                    }
-                }
-            } );
     }
 
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectStatesEnum.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectStatesEnum.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectStatesEnum.java Tue Oct  3 06:49:43 2006
@@ -38,68 +38,40 @@
     // =========================================================================
     // GracefulDisconnect grammar states
     // =========================================================================
+    /** Initial state */
+    public static final int START_STATE = 0;
 
-    /** Sequence Tag */
-    public static int GRACEFUL_DISCONNECT_SEQUENCE_TAG = 0;
+    /** Sequence */
+    public static int GRACEFUL_DISCONNECT_SEQUENCE_STATE = 1;
 
-    /** Sequence Value */
-    public static int GRACEFUL_DISCONNECT_SEQUENCE_VALUE = 1;
+    /** Time offline */
+    public static int TIME_OFFLINE_STATE = 2;
 
-    /** Time offline Tag */
-    public static int TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG = 2;
+    /** Delay */
+    public static int DELAY_STATE = 3;
 
-    /** Time offline Value */
-    public static int TIME_OFFLINE_VALUE = 3;
+    /** Replicated contexts */
+    public static int REPLICATED_CONTEXTS_STATE = 4;
 
-    /** Delay Tag */
-    public static int DELAY_OR_REPLICATED_OR_END_TAG = 4;
-
-    /** Delay Value */
-    public static int DELAY_VALUE = 5;
-
-    /** Replicated contexts Tag */
-    public static int REPLICATED_CONTEXTS_OR_END_TAG = 6;
-
-    /** Replicated contexts Value */
-    public static int REPLICATED_CONTEXTS_VALUE = 7;
-
-    /** Replicated contexts Tag */
-    public static int REPLICATED_CONTEXT_OR_END_TAG = 8;
-
-    /** Replicated contexts Value */
-    public static int REPLICATED_CONTEXT_VALUE = 9;
+    /** Referral */
+    public static int REFERRAL_STATE = 5;
 
     /** terminal state */
-    public static int LAST_GRACEFUL_DISCONNECT_STATE = 10;
-
-    // =========================================================================
-    // Grammars declaration.
-    // =========================================================================
-    /** GracefulDisconnect grammar */
-    public static final int GRACEFUL_DISCONNECT_GRAMMAR_SWITCH = 0x0100;
-
-    /** GracefulDisconnect grammar number */
-    public static final int GRACEFUL_DISCONNECT_GRAMMAR = 0;
-
-    /** The total number of grammars used */
-    public static final int NB_GRAMMARS = 1;
-
-    // =========================================================================
-    // Grammar switches debug strings
-    // =========================================================================
-    /** A string representation of grammars */
-    private static String[] GrammarSwitchString = new String[]
-        { "GRACEFUL_DISCONNECT_GRAMMAR_SWITCH" };
+    public static int LAST_GRACEFUL_DISCONNECT_STATE = 6;
 
     // =========================================================================
     // States debug strings
     // =========================================================================
     /** A string representation of all the states */
     private static String[] GracefulDisconnectString = new String[]
-        { "GRACEFUL_DISCONNECT_SEQUENCE_TAG", "GRACEFUL_DISCONNECT_SEQUENCE_VALUE",
-            "TIME_OFFLINE_OR_DELAY_OR_REPLICATED_OR_END_TAG", "TIME_OFFLINE_VALUE", "DELAY_OR_REPLICATED_OR_END_TAG",
-            "DELAY_VALUE", "REPLICATED_CONTEXTS_OR_END_TAG", "REPLICATED_CONTEXTS_VALUE",
-            "REPLICATED_CONTEXT_OR_END_TAG", "REPLICATED_CONTEXT_VALUE" };
+        { 
+        "START_STATE", 
+        "GRACEFUL_DISCONNECT_SEQUENCE_STATE",
+        "TIME_OFFLINE_STATE", 
+        "DELAY_STATE", 
+        "REPLICATED_CONTEXTS_STATE",
+        "REFERRAL_STATE"
+        };
 
     /** The instance */
     private static GracefulDisconnectStatesEnum instance = new GracefulDisconnectStatesEnum();
@@ -133,27 +105,19 @@
     /**
      * Get the grammar name
      * 
-     * @param grammar
-     *            The grammar code
+     * @param grammar The grammar code
      * @return The grammar name
      */
     public String getGrammarName( int grammar )
     {
-        switch ( grammar )
-        {
-            case GRACEFUL_DISCONNECT_GRAMMAR:
-                return "GRACEFUL_DISCONNECT_GRAMMAR";
-            default:
-                return "UNKNOWN";
-        }
+        return "GRACEFUL_DISCONNECT_GRAMMAR";
     }
 
 
     /**
      * Get the grammar name
      * 
-     * @param grammar
-     *            The grammar class
+     * @param grammar The grammar class
      * @return The grammar name
      */
     public String getGrammarName( IGrammar grammar )
@@ -170,33 +134,11 @@
     /**
      * Get the string representing the state
      * 
-     * @param grammar
-     *            The current grammar being used
-     * @param state
-     *            The state number
+     * @param state The state number
      * @return The String representing the state
      */
-    public String getState( int grammar, int state )
+    public String getState( int state )
     {
-
-        if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
-        {
-            return ( state == END_STATE ) ? "END_STATE"
-                : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
-        }
-        else
-        {
-
-            switch ( grammar )
-            {
-
-                case GRACEFUL_DISCONNECT_GRAMMAR:
-                    return ( ( state == GRAMMAR_END ) ? "GRACEFUL_DISCONNECT_END_STATE"
-                        : GracefulDisconnectString[state] );
-
-                default:
-                    return "UNKNOWN";
-            }
-        }
+        return ( ( state == GRAMMAR_END ) ? "GRACEFUL_DISCONNECT_END_STATE" : GracefulDisconnectString[state] );
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdown.java Tue Oct  3 06:49:43 2006
@@ -22,7 +22,7 @@
 
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
@@ -49,8 +49,13 @@
 
 
     /**
-     * Compute the GracefulShutdown length 0x30 L1 | +--> [0x02 0x0(1-4)
-     * [0..720] ] +--> [0x80 0x0(1-3) [0..86400] ] L1 will always be &lt 11.
+     * Compute the GracefulShutdown length 
+     * 0x30 L1 
+     *   | 
+     *   +--> [0x02 0x0(1-4) [0..720] ] 
+     *   +--> [0x80 0x0(1-3) [0..86400] ] 
+     *   
+     * L1 will always be &lt 11.
      */
     public int computeLength()
     {
@@ -74,11 +79,9 @@
     /**
      * Encodes the gracefulShutdown extended operation.
      * 
-     * @param buffer
-     *            The encoded sink
+     * @param buffer The encoded sink
      * @return A ByteBuffer that contains the encoded PDU
-     * @throws EncoderException
-     *             If anything goes wrong.
+     * @throws EncoderException If anything goes wrong.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
     {
@@ -86,7 +89,7 @@
         ByteBuffer bb = ByteBuffer.allocate( computeLength() );
 
         bb.put( UniversalTag.SEQUENCE_TAG );
-        bb.put( Length.getBytes( gracefulSequenceLength ) );
+        bb.put( TLV.getBytes( gracefulSequenceLength ) );
 
         if ( timeOffline != 0 )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownContainer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownContainer.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownContainer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownContainer.java Tue Oct  3 06:49:43 2006
@@ -22,7 +22,6 @@
 
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
 
 
 /**
@@ -43,14 +42,8 @@
     public GracefulShutdownContainer()
     {
         super();
-        currentGrammar = 0;
-        grammars = new IGrammar[GracefulShutdownStatesEnum.NB_GRAMMARS];
-        grammarStack = new IGrammar[1];
         stateStack = new int[1];
-        nbGrammars = 0;
-
-        grammars[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_GRAMMAR] = GracefulShutdownGrammar.getInstance();
-        grammarStack[currentGrammar] = grammars[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_GRAMMAR];
+        grammar = GracefulShutdownGrammar.getInstance();
         states = GracefulShutdownStatesEnum.getInstance();
     }
 
@@ -68,8 +61,7 @@
      * Set a GracefulShutdown Object into the container. It will be completed by
      * the ldapDecoder.
      * 
-     * @param control
-     *            the GracefulShutdown to set.
+     * @param control the GracefulShutdown to set.
      */
     public void setGracefulShutdown( GracefulShutdown gracefulShutdown )
     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownDecoder.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownDecoder.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownDecoder.java Tue Oct  3 06:49:43 2006
@@ -44,11 +44,9 @@
      * Decode a PDU which must contain a GracefulShutdown extended operation.
      * Note that the stream of bytes much contain a full PDU, not a partial one.
      * 
-     * @param stream
-     *            The bytes to be decoded
+     * @param stream The bytes to be decoded
      * @return An GracefulShutdown object
-     * @throws DecoderException
-     *             If the decoding failed
+     * @throws DecoderException If the decoding failed
      */
     public Asn1Object decode( byte[] stream ) throws DecoderException, NamingException
     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownGrammar.java Tue Oct  3 06:49:43 2006
@@ -42,9 +42,9 @@
  * 
  * <pre>
  *  GracefulShutdwon ::= SEQUENCE {
- *                         timeOffline INTEGER (0..720) DEFAULT 0,
- *                         delay [0] INTEGER (0..86400) DEFAULT 0
- *              }
+ *      timeOffline INTEGER (0..720) DEFAULT 0,
+ *      delay [0] INTEGER (0..86400) DEFAULT 0
+ *  }
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -73,19 +73,16 @@
         super.transitions = new GrammarTransition[GracefulShutdownStatesEnum.LAST_GRACEFUL_SHUTDOWN_STATE][256];
 
         /**
-         * GracefulShutdown ::= SEQUENCE { (Tag) ... Nothing to do...
-         */
-        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_TAG,
-            GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_VALUE, null );
-
-        /**
-         * GracefulShutdown ::= SEQUENCE { (Tag) ... Creates the
-         * GracefulShutdown object
-         */
-        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_VALUE,
-            GracefulShutdownStatesEnum.TIME_OFFLINE_OR_DELAY_OR_END_TAG, new GrammarAction( "Init GracefulShutdown" )
+         * Transition from init state to graceful shutdown
+         * 
+         * GracefulShutdown ::= SEQUENCE {
+         *     ...
+         *     
+         * Creates the GracefulShutdown object
+         */
+        super.transitions[GracefulShutdownStatesEnum.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( GracefulShutdownStatesEnum.INIT_GRAMMAR_STATE, GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, UniversalTag.SEQUENCE_TAG,
+                new GrammarAction( "Init GracefulShutdown" )
             {
                 public void action( IAsn1Container container )
                 {
@@ -97,28 +94,20 @@
             } );
 
         /**
-         * GracefulShutdown ::= SEQUENCE { timeOffline INTEGER (0..720) DEFAULT
-         * 0, (Tag) ... Nothing to do
-         */
-        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_OR_DELAY_OR_END_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.TIME_OFFLINE_OR_DELAY_OR_END_TAG, GracefulShutdownStatesEnum.TIME_OFFLINE_VALUE,
-            null );
-
-        /**
-         * GracefulShutdown ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Tag) ... We have no TimeOffline. Nothing to do.
-         */
-        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_OR_DELAY_OR_END_TAG][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.TIME_OFFLINE_OR_DELAY_OR_END_TAG, GracefulShutdownStatesEnum.DELAY_VALUE, null );
-
-        /**
-         * GracefulShutdown ::= SEQUENCE { timeOffline INTEGER (0..720) DEFAULT
-         * 0, (Value) ... Set the time offline value into the GracefulShutdown
+         * Transition from graceful shutdown to time offline
+         *
+         * GracefulShutdown ::= SEQUENCE { 
+         *     timeOffline INTEGER (0..720) DEFAULT 0,
+         *     ...
+         *     
+         * Set the time offline value into the GracefulShutdown
          * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_VALUE][UniversalTag.INTEGER_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.TIME_OFFLINE_VALUE, GracefulShutdownStatesEnum.DELAY_OR_END_TAG,
-            new GrammarAction( "Set Graceful Shutdown time offline" )
+        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE][UniversalTag.INTEGER_TAG] = 
+            new GrammarTransition( GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, 
+                                    GracefulShutdownStatesEnum.TIME_OFFLINE_STATE, 
+                                    UniversalTag.INTEGER_TAG, 
+                new GrammarAction( "Set Graceful Shutdown time offline" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
@@ -148,21 +137,65 @@
             } );
 
         /**
-         * GracefulShutdown ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Tag) ... We have had a TimeOffline, and now we are
-         * reading the delay. Nothing to do.
+         * Transition from time offline to delay
+         * 
+         * GracefulShutdown ::= SEQUENCE { 
+         *     ... 
+         *     delay [0] INTEGER (0..86400) DEFAULT 0 }
+         * 
+         * Set the delay value into the GracefulShutdown
+         * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.DELAY_OR_END_TAG][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.DELAY_OR_END_TAG, GracefulShutdownStatesEnum.DELAY_VALUE, null );
+        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+            new GrammarTransition( GracefulShutdownStatesEnum.TIME_OFFLINE_STATE, 
+                                    GracefulShutdownStatesEnum.DELAY_STATE, 
+                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG, 
 
+                new GrammarAction( "Set Graceful Shutdown Delay" )
+            {
+                public void action( IAsn1Container container ) throws DecoderException
+                {
+                    GracefulShutdownContainer gracefulShutdownContainer = ( GracefulShutdownContainer ) container;
+                    Value value = gracefulShutdownContainer.getCurrentTLV().getValue();
+
+                    try
+                    {
+                        int delay = IntegerDecoder.parse( value, 0, 86400 );
+
+                        if ( IS_DEBUG )
+                        {
+                            log.debug( "Delay = " + delay );
+                        }
+
+                        gracefulShutdownContainer.getGracefulShutdown().setDelay( delay );
+                        gracefulShutdownContainer.grammarEndAllowed( true );
+                    }
+                    catch ( IntegerDecoderException e )
+                    {
+                        String msg = "failed to decode the delay, the value should be between 0 and 86400 seconds, it is '"
+                            + StringTools.dumpBytes( value.getData() ) + "'";
+                        log.error( msg );
+                        throw new DecoderException( msg );
+                    }
+                }
+            } );
+        
         /**
-         * GracefulShutdown ::= SEQUENCE { ... delay [0] INTEGER (0..86400)
-         * DEFAULT 0, (Value) ... Set the delay value into the GracefulShutdown
+         * Transition from graceful shutdown to delay
+         * 
+         * GracefulShutdown ::= SEQUENCE { 
+         *     ... 
+         *     delay [0] INTEGER (0..86400) DEFAULT 0 }
+         * 
+         * Set the delay value into the GracefulShutdown
          * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.DELAY_VALUE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = new GrammarTransition(
-            GracefulShutdownStatesEnum.DELAY_VALUE, GracefulShutdownStatesEnum.GRAMMAR_END, new GrammarAction(
-                "Set Graceful Shutdown Delay" )
+        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+            new GrammarTransition( GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, 
+                                    GracefulShutdownStatesEnum.DELAY_STATE, 
+                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG, 
+
+                new GrammarAction( "Set Graceful Shutdown Delay" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java Tue Oct  3 06:49:43 2006
@@ -39,53 +39,32 @@
     // GracefulShutdown grammar states
     // =========================================================================
 
-    /** Sequence Tag */
-    public static int GRACEFUL_SHUTDOWN_SEQUENCE_TAG = 0;
+    /** Initial state */
+    public static final int START_STATE = 0;
 
-    /** Sequence Value */
-    public static int GRACEFUL_SHUTDOWN_SEQUENCE_VALUE = 1;
+    /** Sequence */
+    public static int GRACEFUL_SHUTDOWN_SEQUENCE_STATE = 1;
 
-    /** Time offline Tag */
-    public static int TIME_OFFLINE_OR_DELAY_OR_END_TAG = 2;
+    /** Time offline */
+    public static int TIME_OFFLINE_STATE = 2;
 
-    /** Time offline Value */
-    public static int TIME_OFFLINE_VALUE = 3;
-
-    /** Delay Tag */
-    public static int DELAY_OR_END_TAG = 4;
-
-    /** Delay Value */
-    public static int DELAY_VALUE = 5;
+    /** Delay */
+    public static int DELAY_STATE = 3;
 
     /** terminal state */
-    public static int LAST_GRACEFUL_SHUTDOWN_STATE = 6;
-
-    // =========================================================================
-    // Grammars declaration.
-    // =========================================================================
-    /** GracefulShutdown grammar */
-    public static final int GRACEFUL_SHUTDOWN_GRAMMAR_SWITCH = 0x0100;
-
-    /** GracefulShutdown grammar number */
-    public static final int GRACEFUL_SHUTDOWN_GRAMMAR = 0;
-
-    /** The total number of grammars used */
-    public static final int NB_GRAMMARS = 1;
-
-    // =========================================================================
-    // Grammar switches debug strings
-    // =========================================================================
-    /** A string representation of grammars */
-    private static String[] GrammarSwitchString = new String[]
-        { "GRACEFUL_SHUTDOWN_GRAMMAR_SWITCH" };
+    public static int LAST_GRACEFUL_SHUTDOWN_STATE = 4;
 
     // =========================================================================
     // States debug strings
     // =========================================================================
     /** A string representation of all the states */
     private static String[] GracefulShutdownString = new String[]
-        { "GRACEFUL_SHUTDOWN_SEQUENCE_TAG", "GRACEFUL_SHUTDOWN_SEQUENCE_VALUE", "TIME_OFFLINE_OR_DELAY_OR_END_TAG",
-            "TIME_OFFLINE_VALUE", "DELAY_OR_END_TAG", "DELAY_VALUE" };
+        { 
+        "START_STATE",
+        "GRACEFUL_SHUTDOWN_SEQUENCE_STATE", 
+        "TIME_OFFLINE_STATE", 
+        "DELAY_STATE" 
+        };
 
     /** The instance */
     private static GracefulShutdownStatesEnum instance = new GracefulShutdownStatesEnum();
@@ -119,27 +98,19 @@
     /**
      * Get the grammar name
      * 
-     * @param grammar
-     *            The grammar code
+     * @param grammar The grammar code
      * @return The grammar name
      */
     public String getGrammarName( int grammar )
     {
-        switch ( grammar )
-        {
-            case GRACEFUL_SHUTDOWN_GRAMMAR:
-                return "GRACEFUL_SHUTDOWN_GRAMMAR";
-            default:
-                return "UNKNOWN";
-        }
+        return "GRACEFUL_SHUTDOWN_GRAMMAR";
     }
 
 
     /**
      * Get the grammar name
      * 
-     * @param grammar
-     *            The grammar class
+     * @param grammar The grammar class
      * @return The grammar name
      */
     public String getGrammarName( IGrammar grammar )
@@ -156,32 +127,11 @@
     /**
      * Get the string representing the state
      * 
-     * @param grammar
-     *            The current grammar being used
-     * @param state
-     *            The state number
+     * @param state The state number
      * @return The String representing the state
      */
-    public String getState( int grammar, int state )
+    public String getState( int state )
     {
-
-        if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
-        {
-            return ( state == END_STATE ) ? "END_STATE"
-                : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
-        }
-        else
-        {
-
-            switch ( grammar )
-            {
-
-                case GRACEFUL_SHUTDOWN_GRAMMAR:
-                    return ( ( state == GRAMMAR_END ) ? "GRACEFUL_SHUTDOWN_END_STATE" : GracefulShutdownString[state] );
-
-                default:
-                    return "UNKNOWN";
-            }
-        }
+        return ( ( state == GRAMMAR_END ) ? "GRACEFUL_SHUTDOWN_END_STATE" : GracefulShutdownString[state] );
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java Tue Oct  3 06:49:43 2006
@@ -29,7 +29,7 @@
 import java.util.List;
 
 import org.apache.directory.shared.asn1.Asn1Object;
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
@@ -179,11 +179,11 @@
         // The language
     	byte[] languageBytes = StringTools.getBytesUtf8( language );
     	
-        int languageLength = 1 + Length.getNbBytes( languageBytes.length )
+        int languageLength = 1 + TLV.getNbBytes( languageBytes.length )
             + languageBytes.length;
     	
         // The procedure
-        int procedureLength = 1 + Length.getNbBytes( procedure.length )
+        int procedureLength = 1 + TLV.getNbBytes( procedure.length )
             + procedure.length;
     	
     	// Compute parameters length value
@@ -203,12 +203,12 @@
     			
     			StoredProcedureParameter spParam = (StoredProcedureParameter)params.next();
     			
-    			localParamTypeLength = 1 + Length.getNbBytes( spParam.type.length ) + spParam.type.length;
-    			localParamValueLength = 1 + Length.getNbBytes( spParam.value.length ) + spParam.value.length;
+    			localParamTypeLength = 1 + TLV.getNbBytes( spParam.type.length ) + spParam.type.length;
+    			localParamValueLength = 1 + TLV.getNbBytes( spParam.value.length ) + spParam.value.length;
     			
     			localParameterLength = localParamTypeLength + localParamValueLength;
     			
-    			parametersLength += 1 + Length.getNbBytes( localParameterLength ) + localParameterLength;
+    			parametersLength += 1 + TLV.getNbBytes( localParameterLength ) + localParameterLength;
     			
     			parameterLength.add( new Integer( localParameterLength ) );
     			paramTypeLength.add( new Integer( localParamTypeLength ) );
@@ -216,10 +216,10 @@
     		}
     	}
     	
-    	int localParametersLength = 1 + Length.getNbBytes( parametersLength ) + parametersLength; 
+    	int localParametersLength = 1 + TLV.getNbBytes( parametersLength ) + parametersLength; 
     	storedProcedureLength = languageLength + procedureLength + localParametersLength;
 
-    	return 1 + Length.getNbBytes( storedProcedureLength ) + storedProcedureLength; 
+    	return 1 + TLV.getNbBytes( storedProcedureLength ) + storedProcedureLength; 
     }
 
     /**
@@ -237,7 +237,7 @@
         {
             // The StoredProcedure Tag
             bb.put( UniversalTag.SEQUENCE_TAG );
-            bb.put( Length.getBytes( storedProcedureLength ) );
+            bb.put( TLV.getBytes( storedProcedureLength ) );
 
             // The language
             Value.encode( bb, language );
@@ -247,7 +247,7 @@
             
             // The parameters sequence
             bb.put( UniversalTag.SEQUENCE_TAG );
-            bb.put( Length.getBytes( parametersLength ) );
+            bb.put( TLV.getBytes( parametersLength ) );
 
             // The parameters list
             if ( ( parameters != null ) && ( parameters.size() != 0 ) )
@@ -262,7 +262,7 @@
                     // The parameter sequence
                     bb.put( UniversalTag.SEQUENCE_TAG );
                     int localParameterLength = ( ( Integer ) parameterLength.get( parameterNumber ) ).intValue();
-                    bb.put( Length.getBytes( localParameterLength ) );
+                    bb.put( TLV.getBytes( localParameterLength ) );
 
                     // The parameter type
                     Value.encode( bb, spParam.type );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java Tue Oct  3 06:49:43 2006
@@ -49,15 +49,6 @@
 
     private transient StoredProcedureParameter currentParameter;
 
-    private transient int storedProcedureCallRequestLength;
-
-    private transient int languageSchemeLength;
-
-    private transient int searchContextLength;
-
-    private transient int parametersLength;
-
-
     /**
      * TODO: Add more length variables.
      */

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,6 @@
 
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
 
 
 /**
@@ -44,17 +43,8 @@
     public StoredProcedureCallContainer()
     {
         super();
-        currentGrammar = 0;
-        grammars = new IGrammar[1];
-        grammarStack = new IGrammar[1];
         stateStack = new int[1];
-        nbGrammars = 0;
-
-        grammars[StoredProcedureCallStatesEnum.STORED_PROCEDURE_CALL_GRAMMAR] = StoredProcedureCallGrammar
-            .getInstance();
-
-        grammarStack[currentGrammar] = grammars[StoredProcedureCallStatesEnum.STORED_PROCEDURE_CALL_GRAMMAR];
-
+        grammar = StoredProcedureCallGrammar.getInstance();
         states = StoredProcedureCallStatesEnum.getInstance();
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,6 @@
 
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
 import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
-import org.apache.log4j.Logger;
 
 
 /**
@@ -34,9 +33,6 @@
 public class StoredProcedureCallGrammar extends AbstractGrammar implements IGrammar
 {
     // ~ Static fields/initializers -------------------------------------------
-
-    /** The logger */
-    private static final Logger log = Logger.getLogger( StoredProcedureCallGrammar.class );
 
     /** The instance of grammar. StoredProcedureGrammar is a singleton. */
     private static IGrammar instance = new StoredProcedureCallGrammar();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java Tue Oct  3 06:49:43 2006
@@ -37,120 +37,75 @@
     //=========================================================================
     // Tags and values
     //=========================================================================
-    /** StoredProcedureCall Tag */
-    public static int STORED_PROCEDURE_CALL_TAG = 0;
+    /** starting state */
+    public static int START_STATE = 0;
 
-    /** StoredProcedureCall Value */
-    public static int STORED_PROCEDURE_CALL_VALUE = 1;
+    /** StoredProcedureCall */
+    public static int STORED_PROCEDURE_CALL_STATE = 1;
 
     // Name -------------------------------------------------------------------
-    /** Name Tag */
-    public static int NAME_TAG = 2;
-
-    /** Name Value */
-    public static int NAME_VALUE = 3;
+    /** Name */
+    public static int NAME_STATE = 2;
 
     // Options ----------------------------------------------------------------
-    /** Options Tag */
-    public static int OPTIONS_TAG = 4;
-
-    /** Options Value */
-    public static int OPTIONS_VALUE = 5;
+    /** Options */
+    public static int OPTIONS_STATE = 3;
 
     // --- Language Scheme ----------------------------------------------------
-    /** Language Scheme Tag */
-    public static int LANGUAGE_SCHEME_TAG = 6;
-
-    /** Language Scheme Value */
-    public static int LANGUAGE_SCHEME_VALUE = 7;
+    /** Language Scheme */
+    public static int LANGUAGE_SCHEME_STATE = 4;
 
     // --- Search Context -----------------------------------------------------
-    /** Search Context Tag */
-    public static int SEARCH_CONTEXT_TAG = 8;
-
-    /** Search Context Value */
-    public static int SEARCH_CONTEXT_VALUE = 9;
+    /** Search Context */
+    public static int SEARCH_CONTEXT_STATE = 5;
 
     // ------ Context ---------------------------------------------------------
-    /** Context Tag */
-    public static int CONTEXT_TAG = 10;
-
-    /** Context Value */
-    public static int CONTEXT_VALUE = 11;
+    /** Context */
+    public static int CONTEXT_STATE = 6;
 
     // ------ Scope -----------------------------------------------------------
-    /** Scope Tag */
-    public static int SCOPE_TAG = 12;
-
-    /** Scope Value */
-    public static int SCOPE_VALUE = 13;
+    /** Scope */
+    public static int SCOPE_STATE = 7;
 
     // Parameters -------------------------------------------------------------
-    /** Parameters Tag */
-    public static int PARAMETERS_TAG = 14;
-
-    /** Parameters Value */
-    public static int PARAMETERS_VALUE = 15;
+    /** Parameters */
+    public static int PARAMETERS_STATE = 8;
 
     // --- Parameter ----------------------------------------------------------
-    /** Parameter Tag */
-    public static int PARAMETER_TAG = 16;
-
-    /** Parameter Value */
-    public static int PARAMETER_VALUE = 17;
+    /** Parameter */
+    public static int PARAMETER_STATE = 9;
 
     // ------ Parameter type --------------------------------------------------
-    /** Parameter type Tag */
-    public static int PARAMETER_TYPE_TAG = 18;
-
-    /** Parameter type Value */
-    public static int PARAMETER_TYPE_VALUE = 19;
+    /** Parameter type */
+    public static int PARAMETER_TYPE_STATE = 10;
 
     // ------ Parameter value -------------------------------------------------
-    /** Parameter value Tag */
-    public static int PARAMETER_VALUE_TAG = 20;
-
-    /** Parameter value Value */
-    public static int PARAMETER_VALUE_VALUE = 21;
-
-    public static int LAST_STORED_PROCEDURE_CALL_STATE = 22;
-
-    //=========================================================================
-    // Grammar declarations
-    //=========================================================================
-    /** Ldap Message grammar */
-    public static final int STORED_PROCEDURE_CALL_GRAMMAR_SWITCH = 0x0100;
-
-    /** Ldap Message grammar number */
-    public static final int STORED_PROCEDURE_CALL_GRAMMAR = 0;
+    /** Parameter value */
+    public static int PARAMETER_VALUE_STATE = 11;
 
-    /** The total number of grammars used */
-    public static final int NB_GRAMMARS = 1;
-
-    //=========================================================================
-    // Grammar switches debug strings 
-    //=========================================================================
-    /** A string representation of grammars */
-    private static String[] GrammarSwitchString = new String[]
-        { "STORED_PROCEDURE_CALL_GRAMMAR_SWITCH", };
+    public static int LAST_STORED_PROCEDURE_CALL_STATE = 12;
 
     //=========================================================================
     // States debug strings 
     //=========================================================================
     /** A string representation of all the states */
     private static String[] StoredProcedureCallString = new String[]
-        { "STORED_PROCEDURE_CALL_TAG", "STORED_PROCEDURE_CALL_VALUE",
-          "NAME_TAG", "NAME_VALUE",
-          "OPTIONS_TAG", "OPTIONS_VALUE",
-          "LANGUAGE_SCHEME_TAG", "LANGUAGE_SCHEME_VALUE",
-          "SEARCH_CONTEXT_TAG", "SEARCH_CONTEXT_VALUE",
-          "CONTEXT_TAG", "CONTEXT_VALUE",
-          "SCOPE_TAG", "SCOPE_VALUE",
-          "PARAMETERS_TAG", "PARAMETERS_VALUE",
-          "PARAMETER_TYPE_TAG", "PARAMETER_TYPE_VALUE",
-          "PARAMETER_VALUE_TAG", "PARAMETER_VALUE_VALUE" };
-
-    /** The instance */
+        { 
+        "START_STATE",
+        "STORED_PROCEDURE_CALL_STATE", 
+        "NAME_STATE",
+        "OPTIONS_STATE",
+        "LANGUAGE_SCHEME_STATE",
+        "SEARCH_CONTEXT_STATE",
+        "CONTEXT_STATE",
+        "SCOPE_STATE",
+        "PARAMETERS_STATE",
+        "PARAMETER_STATE",
+        "PARAMETER_TYPE_STATE",
+        "PARAMETER_VALUE_STATE" 
+        };
+    
+     /** The instance */
     private static StoredProcedureCallStatesEnum instance = new StoredProcedureCallStatesEnum();
 
 
@@ -171,14 +126,7 @@
 
     public String getGrammarName( int grammar )
     {
-        switch ( grammar )
-        {
-            case STORED_PROCEDURE_CALL_GRAMMAR:
-                return "STORED_PROCEDURE_CALL_GRAMMAR";
-
-            default:
-                return "UNKNOWN";
-        }
+        return "STORED_PROCEDURE_CALL_GRAMMAR";
     }
 
 
@@ -195,28 +143,10 @@
     }
 
 
-    public String getState( int grammar, int state )
+    public String getState( int state )
     {
-
-        if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
-        {
-            return ( state == END_STATE )
-                ? "END_STATE"
-                : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
-        }
-        else
-        {
-            switch ( grammar )
-            {
-
-                case STORED_PROCEDURE_CALL_GRAMMAR:
-                    return( ( state == GRAMMAR_END )
+        return( ( state == GRAMMAR_END )
                         ? "STORED_PROCEDURE_CALL_END_STATE"
                         : StoredProcedureCallString[state] );
-
-                default:
-                    return "UNKNOWN";
-            }
-        }
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureContainer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureContainer.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureContainer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureContainer.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,6 @@
 
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
 
 
 /**
@@ -46,16 +45,8 @@
     public StoredProcedureContainer()
     {
         super();
-        currentGrammar = 0;
-        grammars = new IGrammar[1];
-        grammarStack = new IGrammar[1];
         stateStack = new int[1];
-        nbGrammars = 0;
-
-        grammars[StoredProcedureStatesEnum.STORED_PROCEDURE_GRAMMAR] = StoredProcedureGrammar.getInstance();
-
-        grammarStack[currentGrammar] = grammars[StoredProcedureStatesEnum.STORED_PROCEDURE_GRAMMAR];
-
+        grammar = StoredProcedureGrammar.getInstance();
         states = StoredProcedureStatesEnum.getInstance();
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureGrammar.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureGrammar.java Tue Oct  3 06:49:43 2006
@@ -67,30 +67,24 @@
         //============================================================================================
         // StoredProcedure Message
         //============================================================================================
-        // StoredProcedure ::= SEQUENCE { (Tag)
+        // StoredProcedure ::= SEQUENCE {
         //   ...
         // Nothing to do.
-        super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.STORED_PROCEDURE_TAG, StoredProcedureStatesEnum.STORED_PROCEDURE_VALUE, null );
-
-        // StoredProcedure ::= SEQUENCE { (Value)
-        //   ...
-        // Nothing to do.
-        super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.STORED_PROCEDURE_VALUE, StoredProcedureStatesEnum.LANGUAGE_TAG, null );
+        super.transitions[StoredProcedureStatesEnum.START_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.START_STATE, 
+                                    StoredProcedureStatesEnum.STORED_PROCEDURE_STATE, 
+                                    UniversalTag.SEQUENCE_TAG, 
+                                    null );
 
         //    language OCTETSTRING, (Tag)
         //    ...
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.LANGUAGE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.LANGUAGE_TAG, StoredProcedureStatesEnum.LANGUAGE_VALUE, null );
-
-        //    language OCTETSTRING, (Value)
-        //    ...
-        // Store the language.
-        super.transitions[StoredProcedureStatesEnum.LANGUAGE_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.LANGUAGE_VALUE, StoredProcedureStatesEnum.PROCEDURE_TAG, new GrammarAction(
-                "Stores the language" )
+        //
+        // Creates the storeProcedure and stores the language
+        super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.STORED_PROCEDURE_STATE, 
+                                    StoredProcedureStatesEnum.LANGUAGE_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                new GrammarAction( "Stores the language" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
@@ -102,7 +96,7 @@
                     StoredProcedure storedProcedure = null;
 
                     // Store the value.
-                    if ( tlv.getLength().getLength() == 0 )
+                    if ( tlv.getLength() == 0 )
                     {
                         // We can't have a void language !
                         log.error( "The stored procedure language is null" );
@@ -125,17 +119,14 @@
                 }
             } );
 
-        //    procedure OCTETSTRING, (Tag)
-        //    ...
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.PROCEDURE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PROCEDURE_TAG, StoredProcedureStatesEnum.PROCEDURE_VALUE, null );
-
         //    procedure OCTETSTRING, (Value)
         //    ...
-        // Store the procedure.
-        super.transitions[StoredProcedureStatesEnum.PROCEDURE_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PROCEDURE_VALUE, StoredProcedureStatesEnum.PARAMETERS_TAG, new GrammarAction(
+        // Stores the procedure.
+        super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.LANGUAGE_STATE, 
+                                    StoredProcedureStatesEnum.PROCEDURE_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                new GrammarAction(
                 "Stores the procedure" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
@@ -148,7 +139,7 @@
                     StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
 
                     // Store the value.
-                    if ( tlv.getLength().getLength() == 0 )
+                    if ( tlv.getLength() == 0 )
                     {
                         // We can't have a void procedure !
                         log.error( "The procedure can't be null" );
@@ -168,17 +159,15 @@
                 }
             } );
 
-        // parameters SEQUENCE OF Parameter { (Tag)
-        //    ...
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.PARAMETERS_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETERS_TAG, StoredProcedureStatesEnum.PARAMETERS_VALUE, null );
-
         // parameters SEQUENCE OF Parameter { (Value)
         //    ...
-        // Nothing to do. The list of parameters will be created with the first parameter.
-        super.transitions[StoredProcedureStatesEnum.PARAMETERS_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETERS_VALUE, StoredProcedureStatesEnum.PARAMETER_TAG, new GrammarAction(
+        // The list of parameters will be created with the first parameter.
+        // We can have an empty list of parameters, so the PDU can be empty
+        super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.PROCEDURE_STATE, 
+                                    StoredProcedureStatesEnum.PARAMETERS_STATE, 
+                                    UniversalTag.SEQUENCE_TAG, 
+            new GrammarAction(
                 "Stores the parameters" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
@@ -188,34 +177,25 @@
                 }
             } );
         
-        
-
-        // parameter SEQUENCE OF  { (Tag)
-        //    ...
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_TAG, StoredProcedureStatesEnum.PARAMETER_VALUE, null );
-
         // parameter SEQUENCE OF { (Value)
         //    ...
         // Nothing to do. 
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_VALUE, StoredProcedureStatesEnum.PARAMETER_TYPE_TAG, null );
-
-        // Parameter ::= {
-        //    type OCTETSTRING, (Tag)
-        //    ...
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_TYPE_TAG, StoredProcedureStatesEnum.PARAMETER_TYPE_VALUE, null );
+        super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.PARAMETERS_STATE, 
+                                    StoredProcedureStatesEnum.PARAMETER_STATE, 
+                                    UniversalTag.SEQUENCE_TAG, 
+                                    null );
 
         // Parameter ::= {
         //    type OCTETSTRING, (Value)
         //    ...
+        //
         // We can create a parameter, and store its type
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_TYPE_VALUE, StoredProcedureStatesEnum.PARAMETER_VALUE_TAG, new GrammarAction(
-                "Store parameter type" )
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_STATE, 
+                                    StoredProcedureStatesEnum.PARAMETER_TYPE_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                new GrammarAction( "Store parameter type" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
@@ -225,7 +205,7 @@
                     StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
 
                     // Store the value.
-                    if ( tlv.getLength().getLength() == 0 )
+                    if ( tlv.getLength() == 0 )
                     {
                         // We can't have a void parameter type !
                         log.error( "The parameter type can't be null" );
@@ -255,18 +235,12 @@
         //    ...
         //    value OCTETSTRING (Tag)
         // }
-        // Nothing to do
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_VALUE_TAG, StoredProcedureStatesEnum.PARAMETER_VALUE_VALUE, null );
-
-        // Parameter ::= {
-        //    ...
-        //    value OCTETSTRING (Tag)
-        // }
         // Store the parameter value
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            StoredProcedureStatesEnum.PARAMETER_VALUE_VALUE, StoredProcedureStatesEnum.PARAMETER_TAG, new GrammarAction(
-                "Store parameter value" )
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE][UniversalTag.OCTET_STRING_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE, 
+                                    StoredProcedureStatesEnum.PARAMETER_VALUE_STATE, 
+                                    UniversalTag.OCTET_STRING_TAG,
+                new GrammarAction( "Store parameter value" )
             {
                 public void action( IAsn1Container container ) throws DecoderException
                 {
@@ -276,7 +250,7 @@
                     StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
 
                     // Store the value.
-                    if ( tlv.getLength().getLength() == 0 )
+                    if ( tlv.getLength() == 0 )
                     {
                         // We can't have a void parameter value !
                         log.error( "The parameter value can't be null" );
@@ -310,6 +284,15 @@
                     container.grammarEndAllowed( true );
                 }
             } );
+        
+        // Parameters ::= SEQUENCE OF Parameter
+        // 
+        // Loop on next parameter
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_STATE][UniversalTag.SEQUENCE_TAG] = 
+            new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_VALUE_STATE, 
+                                    StoredProcedureStatesEnum.PARAMETER_STATE, 
+                                    UniversalTag.SEQUENCE_TAG,
+                                    null );
     }
 
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureStatesEnum.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureStatesEnum.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureStatesEnum.java Tue Oct  3 06:49:43 2006
@@ -37,83 +37,52 @@
     //=========================================================================
     // StoredProcedure
     //=========================================================================
-    /** StoredProcedure Tag */
-    public static int STORED_PROCEDURE_TAG = 0;
+    /** starting state */
+    public static int START_STATE = 0;
 
-    /** StoredProcedure Value */
-    public static int STORED_PROCEDURE_VALUE = 1;
+    /** StoredProcedure */
+    public static int STORED_PROCEDURE_STATE = 1;
 
     // Language ---------------------------------------------------------------
-    /** Language Tag */
-    public static int LANGUAGE_TAG = 2;
-
-    /** Language Value */
-    public static int LANGUAGE_VALUE = 3;
+    /** Language */
+    public static int LANGUAGE_STATE = 2;
 
     // Procedure --------------------------------------------------------------
-    /** Procedure Tag */
-    public static int PROCEDURE_TAG = 4;
-
-    /** Procedure Value */
-    public static int PROCEDURE_VALUE = 5;
+    /** Procedure */
+    public static int PROCEDURE_STATE = 3;
 
     // Parameters -------------------------------------------------------------
-    /** Parameters Tag */
-    public static int PARAMETERS_TAG = 6;
-
-    /** Parameters Value */
-    public static int PARAMETERS_VALUE = 7;
+    /** Parameters */
+    public static int PARAMETERS_STATE = 4;
 
     // Parameter --------------------------------------------------------------
-    /** Parameter Tag */
-    public static int PARAMETER_TAG = 8;
-
-    /** Parameter Value */
-    public static int PARAMETER_VALUE = 9;
+    /** Parameter */
+    public static int PARAMETER_STATE = 5;
 
     // Parameter type ---------------------------------------------------------
-    /** Parameter type Tag */
-    public static int PARAMETER_TYPE_TAG = 10;
-
-    /** Parameter type Value */
-    public static int PARAMETER_TYPE_VALUE = 11;
+    /** Parameter type */
+    public static int PARAMETER_TYPE_STATE = 6;
 
     // Parameters value -------------------------------------------------------
-    /** Parameter value Tag */
-    public static int PARAMETER_VALUE_TAG = 12;
-
-    /** Parameter value Value */
-    public static int PARAMETER_VALUE_VALUE = 13;
-
-    public static int LAST_STORED_PROCEDURE_STATE = 14;
+    /** Parameter value */
+    public static int PARAMETER_VALUE_STATE = 7;
 
-    //=========================================================================
-    // Grammars declaration.
-    //=========================================================================
-    /** Ldap Message Grammar */
-    public static final int STORED_PROCEDURE_GRAMMAR_SWITCH = 0x0100;
-
-    /** LdapMessage grammar number */
-    public static final int STORED_PROCEDURE_GRAMMAR = 0;
-
-    /** The total number of grammars used */
-    public static final int NB_GRAMMARS = 1;
-
-    //=========================================================================
-    // Grammar switches debug strings 
-    //=========================================================================
-    /** A string representation of grammars */
-    private static String[] GrammarSwitchString = new String[]
-        { "STORED_PROCEDURE_GRAMMAR_SWITCH", };
+    public static int LAST_STORED_PROCEDURE_STATE = 8;
 
     //=========================================================================
     // States debug strings 
     //=========================================================================
     /** A string representation of all the states */
     private static String[] StoredProcedureString = new String[]
-        { "STORED_PROCEDURE_TAG", "STORED_PROCEDURE_VALUE", "LANGUAGE_TAG", "LANGUAGE_VALUE", "PROCEDURE_TAG",
-            "PROCEDURE_VALUE", "PARAMETERS_TAG", "PARAMETERS_VALUE", "PARAMETER_TYPE_TAG", "PARAMETER_TYPE_VALUE",
-            "PARAMETER_VALUE_TAG", "PARAMETER_VALUE_VALUE" };
+        { 
+        "START_STATE", 
+        "STORED_PROCEDURE_STATE", 
+        "LANGUAGE_STATE", 
+        "PROCEDURE_STATE", 
+        "PARAMETERS_STATE", 
+        "PARAMETER_TYPE_STATE",
+        "PARAMETER_VALUE_STATE" 
+        };
 
     /** The instance */
     private static StoredProcedureStatesEnum instance = new StoredProcedureStatesEnum();
@@ -149,14 +118,7 @@
      */
     public String getGrammarName( int grammar )
     {
-        switch ( grammar )
-        {
-            case STORED_PROCEDURE_GRAMMAR:
-                return "STORED_PROCEDURE_GRAMMAR";
-
-            default:
-                return "UNKNOWN";
-        }
+        return "STORED_PROCEDURE_GRAMMAR";
     }
 
 
@@ -185,26 +147,8 @@
      * @param state The state number
      * @return The String representing the state
      */
-    public String getState( int grammar, int state )
+    public String getState( int state )
     {
-
-        if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
-        {
-            return ( state == END_STATE ) ? "END_STATE"
-                : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
-        }
-        else
-        {
-
-            switch ( grammar )
-            {
-
-                case STORED_PROCEDURE_GRAMMAR:
-                    return ( ( state == GRAMMAR_END ) ? "STORED_PROCEDURE_END_STATE" : StoredProcedureString[state] );
-
-                default:
-                    return "UNKNOWN";
-            }
-        }
+        return ( ( state == GRAMMAR_END ) ? "STORED_PROCEDURE_END_STATE" : StoredProcedureString[state] );
     }
 }



Mime
View raw message