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/04/15 07:22:02 UTC

svn commit: r161384 - directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java

Author: elecharny
Date: Thu Apr 14 22:22:02 2005
New Revision: 161384

URL: http://svn.apache.org/viewcvs?view=rev&rev=161384
Log:
As strongly suggested by Alan (thanks Alan!), replaced all those dangerous constant incrementation by numeric values.
Added some states. 

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java?view=diff&r1=161383&r2=161384
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/grammar/StatesEnum.java Thu Apr 14 22:22:02 2005
@@ -29,179 +29,208 @@
     /** The initial state of every grammar */
     public static int INIT_GRAMMAR_STATE = 0;
     
+    // LdapMessage ------------------------------------------------------------
     /** Initiate the counter to 0 */
-    private static int INIT_STATE = 0;
+    private static int LDAP_MESSAGE_STATE = 0;
 
-    // LdapMessage ------------------------------------------------------------
     /** LDAPMessage Tag */
-    public static int LDAP_MESSAGE_TAG = INIT_STATE++;
+
+    public static int LDAP_MESSAGE_TAG = 0;
 
     /** LDAPMessage Length */
-    public static int LDAP_MESSAGE_LENGTH = INIT_STATE++;
+    public static int LDAP_MESSAGE_LENGTH = 1;
 
     /** LDAPMessage Value */
-    public static int LDAP_MESSAGE_VALUE = INIT_STATE++;
+    public static int LDAP_MESSAGE_VALUE = 2;
 
     // Message ID -------------------------------------------------------------
     /** MessageID Tag */
-    public static int LDAP_MESSAGE_ID_TAG = INIT_STATE++;
+    public static int LDAP_MESSAGE_ID_TAG = 3;
 
     /** MessageID Length */
-    public static int LDAP_MESSAGE_ID_LENGTH = INIT_STATE++;
+    public static int LDAP_MESSAGE_ID_LENGTH = 4;
 
     /** MessageID Value */
-    public static int LDAP_MESSAGE_ID_VALUE = INIT_STATE++;
+    public static int LDAP_MESSAGE_ID_VALUE = 5;
 
     // ProtocolOp -------------------------------------------------------------
     /** protocolOp CHOICE Tag */
-    public static int PROTOCOL_OP_TAG = INIT_STATE++;
+    public static int PROTOCOL_OP_TAG = 6;
 
     /** protocolOp CHOICE Length */
-    public static int PROTOCOL_OP_LENGTH = INIT_STATE++;
+    public static int PROTOCOL_OP_LENGTH = 7;
 
     /** protocolOp CHOICE Value */
-    public static int PROTOCOL_OP_VALUE = INIT_STATE++;
+    public static int PROTOCOL_OP_VALUE = 8;
+    
+    public static int LAST_LDAP_MESSAGE_STATE = 9;
+    
+    
 
     // BindRequest ============================================================
     // Version ----------------------------------------------------------------
+    private static int BIND_REQUEST_STATE = 0;
+
+    /** The BindRequest Tag */
+    public static int BIND_REQUEST_TAG = 0;
+    
+    /** BIND_REQUEST Length */
+    public static int BIND_REQUEST_LENGTH = 1;
+    
+    /** The BindRequest Value */
+    public static int BIND_REQUEST_VALUE = 2;
+
     /**  Version Tag */
-    public static int BIND_REQUEST_VERSION_TAG = INIT_STATE++;
+    public static int BIND_REQUEST_VERSION_TAG = 3;
 
     /** Version Length */
-    public static int BIND_REQUEST_VERSION_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_VERSION_LENGTH = 4;
 
     /** Version Length */
-    public static int BIND_REQUEST_VERSION_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_VERSION_VALUE = 5;
 
     // Name -------------------------------------------------------------------
     /** Name Tag */
-    public static int BIND_REQUEST_NAME_TAG = INIT_STATE++;
+    public static int BIND_REQUEST_NAME_TAG = 6;
 
     /** Name Length */
-    public static int BIND_REQUEST_NAME_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_NAME_LENGTH = 7;
 
     /** Name Value */
-    public static int BIND_REQUEST_NAME_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_NAME_VALUE = 8;
 
     // Authentication choice --------------------------------------------------
     /** Authentication choice Tag */
-    public static int BIND_REQUEST_AUTHENTICATION_CHOICE_TAG = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_CHOICE_TAG = 9;
 
     // Authentication simple --------------------------------------------------
     /** Authentication Simple Tag */
-    //public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_TAG = INIT_STATE++;
+    //public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_TAG = BIND_REQUEST_STATE++;
 
     /** Authentication Simple Length */
-    public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_LENGTH = 10;
 
     /** Authentication Simple Value */
-    public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_SIMPLE_VALUE = 11;
 
     // Authentication sasl ----------------------------------------------------
     /** Authentication Sasl Tag */
     //public static int BIND_AUTHENTICATION_SASL_TAG = INIT_STATE++;
 
     /** Authentication Sasl Length */
-    public static int BIND_REQUEST_AUTHENTICATION_SASL_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_SASL_LENGTH = 12;
 
     /** Authentication Sasl Value */
-    public static int BIND_REQUEST_AUTHENTICATION_SASL_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_SASL_VALUE = 13;
 
     // Authentication sasl mechanism ------------------------------------------
     /** Authentication Sasl mechanism Tag */
-    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_TAG = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_TAG = 14;
 
     /** Authentication sasl mechanism Length */
-    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_LENGTH = 15;
 
     /** Authentication sasl mechanism Value */
-    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_MECHANISM_VALUE = 16;
 
     // Authentication sasl mechanism ------------------------------------------
     /** Authentication Sasl credentials Tag */
-    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG = 17;
 
     /** Authentication sasl credentials Length */
-    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_LENGTH = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_LENGTH = 18;
 
     /** Authentication sasl credentials Value */
-    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE = INIT_STATE++;
+    public static int BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE = 19;
+
+    public static int LAST_BIND_REQUEST_STATE = 20;
 
+    
     // Controls ===============================================================
+    private static int LDAP_CONTROL_STATE = 0;
+    
     /** Controls Tag */
-    public static int CONTROLS_TAG = INIT_STATE++;
+    public static int CONTROLS_TAG = 1;
 
     /** Controls Length */
-    public static int CONTROLS_LENGTH = INIT_STATE++;
+    public static int CONTROLS_LENGTH = 2;
 
     /** Controls Value */
-    public static int CONTROLS_VALUE = INIT_STATE++;
+    public static int CONTROLS_VALUE = 3;
 
     // Control ----------------------------------------------------------------
     /** Control Tag */
-    public static int CONTROL_TAG = INIT_STATE++;
+    public static int CONTROL_TAG = 4;
 
     /** Control Length */
-    public static int CONTROL_LENGTH = INIT_STATE++;
+    public static int CONTROL_LENGTH = 5;
 
     /** Control Value */
-    public static int CONTROL_VALUE = INIT_STATE++;
+    public static int CONTROL_VALUE = 6;
 
     // Control controltype ----------------------------------------------------
     /** Control type Tag */
-    public static int CONTROL_TYPE_TAG = INIT_STATE++;
+    public static int CONTROL_TYPE_TAG = 7;
 
     /** Control type Length */
-    public static int CONTROL_TYPE_LENGTH = INIT_STATE++;
+    public static int CONTROL_TYPE_LENGTH = 8;
 
     /** Control type Value */
-    public static int CONTROL_TYPE_VALUE = INIT_STATE++;
+    public static int CONTROL_TYPE_VALUE = 9;
 
     // Control criticality ----------------------------------------------------
     /** Control criticality Tag */
-    public static int CONTROL_CRITICALITY_TAG = INIT_STATE++;
+    public static int CONTROL_CRITICALITY_TAG = 10;
 
     /** Control criticality Length */
-    public static int CONTROL_CRITICALITY_LENGTH = INIT_STATE++;
+    public static int CONTROL_CRITICALITY_LENGTH = 11;
 
     /** Control criticality Value */
-    public static int CONTROL_CRITICALITY_VALUE = INIT_STATE++;
+    public static int CONTROL_CRITICALITY_VALUE = 12;
 
     // Control controlvalue ---------------------------------------------------
     /** Control value Tag */
-    public static int CONTROL_VALUE_TAG = INIT_STATE++;
+    public static int CONTROL_VALUE_TAG = 13;
 
     /** Control value Length */
-    public static int CONTROL_VALUE_LENGTH = INIT_STATE++;
+    public static int CONTROL_VALUE_LENGTH = 14;
 
     /** Control value Value */
-    public static int CONTROL_VALUE_VALUE = INIT_STATE++;
+    public static int CONTROL_VALUE_VALUE = 15;
+    
+    /** Control last state */
+    public static int CONTROL_LAST_STATE = 16;
 
     // BindResponse ===========================================================
     // Version ----------------------------------------------------------------
+    private static int BIND_RESPONSE_STATE = 0;
+
     /**  Response Tag */
-    public static int BIND_RESPONSE_TAG = INIT_STATE++;
+    public static int BIND_RESPONSE_TAG = 0;
 
     /**  Response Length */
-    public static int BIND_RESPONSE_LENGTH = INIT_STATE++;
+    public static int BIND_RESPONSE_LENGTH = 1;
 
     /**  Response Value */
-    public static int BIND_RESPONSE_VALUE = INIT_STATE++;
+    public static int BIND_RESPONSE_VALUE = 2;
+
+    /**  Response Ldap Result */
+    public static int BIND_RESPONSE_LDAP_RESULT = 3;
 
     /**  Response message ID Tag */
-    public static int BIND_RESPONSE_MESSAGE_ID_TAG = INIT_STATE++;
+    public static int BIND_RESPONSE_MESSAGE_ID_TAG = 4;
 
     /** serverSaslCreds Tag */
-    public static int SERVER_SASL_CREDS_TAG = INIT_STATE++;
+    public static int BIND_RESPONSE_SERVER_SASL_CREDS_TAG = 5;
 
     /** serverSaslCreds Length */
-    public static int SERVER_SASL_CREDS_LENGTH = INIT_STATE++;
+    public static int BIND_RESPONSE_SERVER_SASL_CREDS_LENGTH = 6;
 
     /** serverSaslCreds Length */
-    public static int SERVER_SASL_CREDS_VALUE = INIT_STATE++;
+    public static int BIND_RESPONSE_SERVER_SASL_CREDS_VALUE = 7;
 
     /** Last state */
-    public static int LAST_LDAP_STATE = INIT_STATE; 
+    public static int LAST_LDAP_STATE = 8; 
     
     
     // LdapResult grammar states ==============================================
@@ -209,69 +238,97 @@
     
     // LdapResult Code --------------------------------------------------------
     /** LdapResult Code Tag */
-    public static int LDAP_RESULT_CODE_TAG = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_CODE_TAG = 0;
 
     /** LdapResult Code Length */
-    public static int LDAP_RESULT_CODE_LENGTH = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_CODE_LENGTH = 1;
 
     /** LdapResult Code Value */
-    public static int LDAP_RESULT_CODE_VALUE = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_CODE_VALUE = 2;
 
     // LdapResult Matched DN --------------------------------------------------
     /** LdapResult Matched DN Tag */
-    public static int LDAP_RESULT_MATCHED_DN_TAG = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_MATCHED_DN_TAG = 3;
 
     /** LdapResult Matched DN Length */
-    public static int LDAP_RESULT_MATCHED_DN_LENGTH = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_MATCHED_DN_LENGTH = 4;
 
     /** LdapResult Matched DN Value */
-    public static int LDAP_RESULT_MATCHED_DN_VALUE = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_MATCHED_DN_VALUE = 5;
 
     // LdapResult error message -----------------------------------------------
     /** LdapResult error message Tag */
-    public static int LDAP_RESULT_ERROR_MESSAGE_TAG = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_ERROR_MESSAGE_TAG = 6;
 
     /** LdapResult error message Length */
-    public static int LDAP_RESULT_ERROR_MESSAGE_LENGTH = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_ERROR_MESSAGE_LENGTH = 7;
 
     /** LdapResult error message Value */
-    public static int LDAP_RESULT_ERROR_MESSAGE_VALUE = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_ERROR_MESSAGE_VALUE = 8;
 
     // LdapResult referral sequence -------------------------------------------
     /** LdapResult referral sequence Tag */
-    public static int LDAP_RESULT_REFERRAL_SEQUENCE_TAG = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_REFERRAL_SEQUENCE_TAG = 9;
 
     /** LdapResult referral sequence Length */
-    public static int LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH = 10;
 
     // LdapResult referrale ---------------------------------------------------
     /** LdapResult referral Tag */
-    public static int LDAP_RESULT_REFERRAL_TAG = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_REFERRAL_TAG = 11;
 
     /** LdapResult referral Length */
-    public static int LDAP_RESULT_REFERRAL_LENGTH = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_REFERRAL_LENGTH = 12;
 
     /** LdapResult referral Value */
-    public static int LDAP_RESULT_REFERRAL_VALUE = LDAP_RESULT_STATE++;
+    public static int LDAP_RESULT_REFERRAL_VALUE = 13;
+    
+    /** LdapResult referral Tag loop */
+    public static int LDAP_RESULT_REFERRAL_LOOP_TAG = 14;
 
     /** The last state */
-    public static int LDAP_RESULT_LAST_STATE = LDAP_RESULT_STATE;
+    public static int LDAP_RESULT_LAST_STATE = 15;
     
     
+    /** The ending state for every grammars */
+    public static int GRAMMAR_END = -1;
     
     /** The mask to filter between states transition and grammar switch */
     public final static int GRAMMAR_SWITCH_MASK = 0x0F00;
     
-    /** Ldap Grammar */
-    public final static int LDAP_GRAMMAR_SWITCH = 0x0100;
-    public final static int LDAP_GRAMMAR = 0;
+    /** Ldap Message Grammar */
+    public final static int LDAP_MESSAGE_GRAMMAR_SWITCH = 0x0100;
+    public final static int LDAP_MESSAGE_GRAMMAR = 0;
 
-    /** LdapResult Grammar */
+    /** Ldap Result Grammar */
     public final static int LDAP_RESULT_GRAMMAR_SWITCH = 0x0200;
     public final static int LDAP_RESULT_GRAMMAR = 1;
 
+    /** Ldap Control Grammar */
+    public final static int LDAP_CONTROL_GRAMMAR_SWITCH = 0x0300;
+    public final static int LDAP_CONTROL_GRAMMAR = 2;
+
+    /** Bind Request  Grammar */
+    public final static int BIND_REQUEST_GRAMMAR_SWITCH = 0x0400;
+    public final static int BIND_REQUEST_GRAMMAR = 3;
+
+    /** BindResponse Grammar */
+    public final static int BIND_RESPONSE_GRAMMAR_SWITCH = 0x0500;
+    public final static int BIND_RESPONSE_GRAMMAR = 4;
+    
+    /** A string representation of grammars */
+    private static String[] GrammarSwitchString = 
+        new String[]
+                   {
+            		"LDAP_MESSAGE_GRAMMAR_SWITCH",
+            		"LDAP_RESULT_GRAMMAR_SWITCH",
+            		"LDAP_CONTROL_GRAMMAR_SWITCH",
+            		"BIND_REQUEST_GRAMMAR_SWITCH",
+            		"BIND_RESPONSE_GRAMMAR_SWITCH"
+                   };
+
     /** A string representation of all the states */
-    private static String[] LdapString =
+    private static String[] LdapMessageString =
         new String[]
         {
     		"LDAP_MESSAGE_TAG",
@@ -282,7 +339,13 @@
 			"LDAP_MESSAGE_ID_VALUE",
 			"PROTOCOL_OP_TAG",
 			"PROTOCOL_OP_LENGTH",
-			"PROTOCOL_OP_VALUE",
+			"PROTOCOL_OP_VALUE"
+        };
+    
+    /** A string representation of all the LdapResult states */
+    private static String[] LdapResultString =
+        new String[]
+        {
 			"LDAP_RESULT_CODE_TAG",
 			"LDAP_RESULT_CODE_LENGTH",
 			"LDAP_RESULT_CODE_VALUE",
@@ -297,6 +360,37 @@
 			"LDAP_RESULT_REFERRAL_TAG",
 			"LDAP_RESULT_REFERRAL_LENGTH",
 			"LDAP_RESULT_REFERRAL_VALUE",
+			"LAST_STATE"
+        };
+
+    /** A string representation of all the controls states */
+    private static String[] LdapControlString =
+        new String[]
+        {
+			"CONTROLS_TAG",
+			"CONTROLS_LENGTH",
+			"CONTROLS_VALUE",
+			"CONTROL_TAG",
+			"CONTROL_LENGTH",
+			"CONTROL_VALUE",
+			"CONTROL_TYPE_TAG",
+			"CONTROL_TYPE_LENGTH",
+			"CONTROL_TYPE_VALUE",
+			"CONTROL_CRITICALITY_TAG",
+			"CONTROL_CRITICALITY_LENGTH",
+			"CONTROL_CRITICALITY_VALUE",
+			"CONTROL_VALUE_TAG",
+			"CONTROL_VALUE_LENGTH",
+			"CONTROL_VALUE_VALUE"
+        };
+    
+    /** A string representation of all the Bind Request states */
+    private static String[] BindRequestString =
+        new String[]
+        {
+			"BIND_REQUEST_TAG",
+			"BIND_REQUEST_LENGTH",
+			"BIND_REQUEST_VALUE",
 			"BIND_REQUEST_VERSION_TAG",
 			"BIND_REQUEST_VERSION_LENGTH",
 			"BIND_REQUEST_VERSION_VALUE",
@@ -316,48 +410,22 @@
 			"BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG",
 			"BIND_REQUEST_AUTHENTICATION_CREDENTIALS_LENGTH",
 			"BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE",
-			"CONTROLS_TAG",
-			"CONTROLS_LENGTH",
-			"CONTROLS_VALUE",
-			"CONTROL_TAG",
-			"CONTROL_LENGTH",
-			"CONTROL_VALUE",
-			"CONTROL_TYPE_TAG",
-			"CONTROL_TYPE_LENGTH",
-			"CONTROL_TYPE_VALUE",
-			"CONTROL_CRITICALITY_TAG",
-			"CONTROL_CRITICALITY_LENGTH",
-			"CONTROL_CRITICALITY_VALUE",
-			"CONTROL_VALUE_TAG",
-			"CONTROL_VALUE_LENGTH",
-			"CONTROL_VALUE_VALUE",
+        };
+    
+    /** A string representation of all the BindResponse states */
+    private static String[] BindResponseString =
+        new String[]
+        {
 			"BIND_RESPONSE_TAG",
+			"BIND_RESPONSE_LENGTH",
+			"BIND_RESPONSE_VALUE",
+			"BIND_RESPONSE_MESSAGE_ID_TAG",
 			"SERVER_SASL_CREDS_TAG",
 			"SERVER_SASL_CREDS_LENGTH",
 			"SERVER_SASL_CREDS_VALUE",
 			"LAST_STATE"
         };
 
-    /** A string representation of all the LdapResult states */
-    private static String[] LdapResultString =
-        new String[]
-        {
-			"LDAP_RESULT_CODE_TAG",
-			"LDAP_RESULT_CODE_LENGTH",
-			"LDAP_RESULT_CODE_VALUE",
-			"LDAP_RESULT_MATCHED_DN_TAG",
-			"LDAP_RESULT_MATCHED_DN_LENGTH",
-			"LDAP_RESULT_MATCHED_DN_VALUE",
-			"LDAP_RESULT_ERROR_MESSAGE_TAG",
-			"LDAP_RESULT_ERROR_MESSAGE_LENGTH",
-			"LDAP_RESULT_ERROR_MESSAGE_VALUE",
-			"LDAP_RESULT_REFERRAL_SEQUENCE_TAG",
-			"LDAP_RESULT_REFERRAL_SEQUENCE_LENGTH",
-			"LDAP_RESULT_REFERRAL_TAG",
-			"LDAP_RESULT_REFERRAL_LENGTH",
-			"LDAP_RESULT_REFERRAL_VALUE",
-			"LAST_STATE"
-        };
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
@@ -368,16 +436,32 @@
      */
     public static String getState( int grammar, int state )
     {
-        switch (grammar)
+        if ((state & GRAMMAR_SWITCH_MASK) != 0)
+        {
+            return (state == -1) ? "END_STATE" : GrammarSwitchString[((state & GRAMMAR_SWITCH_MASK) >> 8) - 1];
+        }
+        else 
         {
-            case LDAP_GRAMMAR :
-                return ( ( state == -1 ) ? "END_STATE" : LdapString[state] );
-                
-            case LDAP_RESULT_GRAMMAR :
-                return ( ( state == -1 ) ? "END_STATE" : LdapResultString[state] );
-                
-            default :
-                return "";
+	        switch (grammar)
+	        {
+	            case LDAP_MESSAGE_GRAMMAR :
+	                return ( ( state == -1 ) ? "END_STATE" : LdapMessageString[state] );
+	                
+	            case LDAP_RESULT_GRAMMAR :
+	                return ( ( state == -1 ) ? "END_STATE" : LdapResultString[state] );
+	                
+	            case LDAP_CONTROL_GRAMMAR :
+	                return ( ( state == -1 ) ? "END_STATE" : LdapControlString[state] );
+	                
+	            case BIND_REQUEST_GRAMMAR :
+	                return ( ( state == -1 ) ? "END_STATE" : BindRequestString[state] );
+	                
+	            case BIND_RESPONSE_GRAMMAR :
+	                return ( ( state == -1 ) ? "END_STATE" : BindResponseString[state] );
+	                
+	            default :
+	                return "UNKNOWN";
+	        }
         }
     }
 }