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/05/31 00:16:48 UTC
svn commit: r179160 -
/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java
Author: elecharny
Date: Mon May 30 15:16:45 2005
New Revision: 179160
URL: http://svn.apache.org/viewcvs?rev=179160&view=rev
Log:
Many fixes !
- added some separators in the comment (the code needed to be more readable)
- changed the name of the first state of each grammar
- added a END_STATE constant
- added the ADD_RESPONSE states
- fixed the debug method that return the grammar as the string
- added a method to return the current grammar name when passing the grammar class as a parameter
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java?rev=179160&r1=179159&r2=179160&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/LdapStatesEnum.java Mon May 30 15:16:45 2005
@@ -30,12 +30,13 @@
{
//~ Static fields/initializers -----------------------------------------------------------------
- // LdapMessage ------------------------------------------------------------
+ //=========================================================================
+ // LdapMessage
+ //=========================================================================
/** Initiate the counter to 0 */
- private static int LDAP_MESSAGE_STATE = 0;
+ //private static int FIRST_LDAP_MESSAGE_STATE = 0;
/** LDAPMessage Tag */
-
public static int LDAP_MESSAGE_TAG = 0;
/** LDAPMessage Length */
@@ -67,10 +68,11 @@
/** The Ldap Message last state */
public static int LAST_LDAP_MESSAGE_STATE = 9;
-
- // BindRequest ============================================================
+ //=========================================================================
+ // BindRequest
+ //=========================================================================
/** The bind request init state */
- private static int BIND_REQUEST_STATE = 0;
+ //private static int FIRST_BIND_REQUEST_STATE = 0;
/** The BindRequest Tag */
public static int BIND_REQUEST_TAG = 0;
@@ -147,9 +149,11 @@
/** The bind request last state */
public static int LAST_BIND_REQUEST_STATE = 20;
- // UnBindRequest ============================================================
+ //=========================================================================
+ // UnBindRequest
+ //=========================================================================
/** The unbind request init state */
- private static int UNBIND_REQUEST_STATE = 0;
+ //private static int FIRST_UNBIND_REQUEST_STATE = 0;
/** The UnBindRequest Tag */
public static int UNBIND_REQUEST_TAG = 0;
@@ -160,9 +164,11 @@
/** The unbind request last state */
public static int LAST_UNBIND_REQUEST_STATE = 2;
- // AbandonRequest ============================================================
+ //=========================================================================
+ // AbandonRequest
+ //=========================================================================
/** The abandon request init state */
- private static int ABANDON_REQUEST_STATE = 0;
+ //private static int FIRST_ABANDON_REQUEST_STATE = 0;
/** The abandon request Tag */
public static int ABANDON_REQUEST_MESSAGE_ID_TAG = 0;
@@ -176,9 +182,11 @@
/** The abandon request last state */
public static int LAST_ABANDON_REQUEST_STATE = 3;
- // Controls ===============================================================
+ //=========================================================================
+ // Controls
+ //=========================================================================
/** The ldap control init state */
- private static int LDAP_CONTROL_STATE = 0;
+ //private static int FIRST_LDAP_CONTROL_STATE = 0;
/** Controls Tag */
public static int CONTROLS_TAG = 1;
@@ -232,41 +240,62 @@
/** Control last state */
public static int CONTROL_LAST_STATE = 16;
- // BindResponse ===========================================================
+ //=========================================================================
+ // BindResponse
+ //=========================================================================
/** The bind response init state */
- private static int BIND_RESPONSE_STATE = 0;
+ //private static int FIRST_BIND_RESPONSE_STATE = 0;
- /** Response Tag */
+ /** Bind Response Tag */
public static int BIND_RESPONSE_TAG = 0;
- /** Response Length */
+ /** Bind Response Length */
public static int BIND_RESPONSE_LENGTH = 1;
- /** Response Value */
+ /** Bind Response Value */
public static int BIND_RESPONSE_VALUE = 2;
- /** Response Ldap Result */
+ /** Bind Response Ldap Result (we will switch the grammar here) */
public static int BIND_RESPONSE_LDAP_RESULT = 3;
- /** Response message ID Tag */
- public static int BIND_RESPONSE_MESSAGE_ID_TAG = 4;
-
/** serverSaslCreds Tag */
- public static int BIND_RESPONSE_SERVER_SASL_CREDS_TAG = 5;
+ public static int BIND_RESPONSE_SERVER_SASL_CREDS_TAG = 4;
/** serverSaslCreds Length */
- public static int BIND_RESPONSE_SERVER_SASL_CREDS_LENGTH = 6;
+ public static int BIND_RESPONSE_SERVER_SASL_CREDS_LENGTH = 5;
/** serverSaslCreds Length */
- public static int BIND_RESPONSE_SERVER_SASL_CREDS_VALUE = 7;
+ public static int BIND_RESPONSE_SERVER_SASL_CREDS_VALUE = 6;
/** Last state */
- public static int LAST_LDAP_STATE = 8;
+ public static int LAST_BIND_RESPONSE_STATE = 7;
+
+ //=========================================================================
+ // AddResponse
+ //=========================================================================
+ /** The add response init state */
+ //private static int FIRST_ADD_RESPONSE_STATE = 0;
+
+ /** Add Response Tag */
+ public static int ADD_RESPONSE_TAG = 0;
+
+ /** Add Response Length */
+ public static int ADD_RESPONSE_LENGTH = 1;
+ /** Add Response Value */
+ public static int ADD_RESPONSE_VALUE = 2;
- // LdapResult grammar states ==============================================
+ /** Add Response Ldap Result (we will switch the grammar here) */
+ public static int ADD_RESPONSE_LDAP_RESULT = 3;
+
+ /** Last state */
+ public static int LAST_ADD_RESPONSE_STATE = 4;
+
+ //=========================================================================
+ // LdapResult grammar states
+ //=========================================================================
/** The ldap result init state */
- private static int LDAP_RESULT_STATE = 0;
+ //private static int FIRST_LDAP_RESULT_STATE = 0;
// LdapResult Code --------------------------------------------------------
/** LdapResult Code Tag */
@@ -321,6 +350,9 @@
/** The last state */
public static int LDAP_RESULT_LAST_STATE = 15;
+ //=========================================================================
+ // Grammars declaration.
+ //=========================================================================
/** Ldap Message Grammar */
public static final int LDAP_MESSAGE_GRAMMAR_SWITCH = 0x0100;
@@ -363,6 +395,15 @@
/** AbandonRequest number */
public static final int ABANDON_REQUEST_GRAMMAR = 6;
+ /** AddRequest Grammar */
+ public static final int ADD_REQUEST_GRAMMAR_SWITCH = 0x0800;
+
+ /** AddRequest number */
+ public static final int ADD_REQUEST_GRAMMAR = 7;
+
+ //=========================================================================
+ // Grammar switches debug strings
+ //=========================================================================
/** A string representation of grammars */
private static String[] GrammarSwitchString =
new String[]
@@ -373,9 +414,13 @@
"BIND_REQUEST_GRAMMAR_SWITCH",
"BIND_RESPONSE_GRAMMAR_SWITCH",
"UNBIND_REQUEST_GRAMMAR_SWITCH",
- "ABANDON_REQUEST_GRAMMAR_SWITCH"
+ "ABANDON_REQUEST_GRAMMAR_SWITCH",
+ "ADD_REQUEST_GRAMMAR_SWITCH"
};
+ //=========================================================================
+ // States debug strings
+ //=========================================================================
/** A string representation of all the states */
private static String[] LdapMessageString =
new String[]
@@ -466,11 +511,11 @@
"BIND_RESPONSE_TAG",
"BIND_RESPONSE_LENGTH",
"BIND_RESPONSE_VALUE",
- "BIND_RESPONSE_MESSAGE_ID_TAG",
+ "BIND_RESPONSE_LDAP_RESULT",
"SERVER_SASL_CREDS_TAG",
"SERVER_SASL_CREDS_LENGTH",
"SERVER_SASL_CREDS_VALUE",
- "LAST_STATE"
+ "LAST_BIND_RESPONSE_STATE"
};
/** A string representation of all the Unbind Request states */
@@ -490,6 +535,16 @@
"ABANDON_REQUEST_MESSAGE_ID_VALUE"
};
+ /** A string representation of all the Add Request states */
+ private static String[] AddRequestString =
+ new String[]
+ {
+ "ADD_RESPONSE_TAG",
+ "ADD_RESPONSE_LENGTH",
+ "ADD_RESPONSE_VALUE",
+ "ADD_RESPONSE_LDAP_RESULT"
+ };
+
/** The instance */
private static LdapStatesEnum instance = new LdapStatesEnum();
@@ -513,6 +568,72 @@
{
return instance;
}
+
+ /**
+ * Get the grammar name
+ * @param The grammar code
+ * @return The grammar name
+ */
+ public static String getGrammarName(int grammar)
+ {
+ switch (grammar)
+ {
+ case LDAP_MESSAGE_GRAMMAR : return "LDAP_MESSAGE_GRAMMAR";
+ case LDAP_RESULT_GRAMMAR : return "LDAP_RESULT_GRAMMAR";
+ case LDAP_CONTROL_GRAMMAR : return "LDAP_CONTROL_GRAMMAR";
+ case BIND_REQUEST_GRAMMAR : return "BIND_REQUEST_GRAMMAR";
+ case BIND_RESPONSE_GRAMMAR : return "BIND_RESPONSE_GRAMMAR";
+ case UNBIND_REQUEST_GRAMMAR : return "UNBIND_REQUEST_GRAMMAR";
+ case ABANDON_REQUEST_GRAMMAR : return "ABANDON_REQUEST_GRAMMAR";
+ case ADD_REQUEST_GRAMMAR : return "ADD_REQUEST_GRAMMAR";
+ default : return "UNKNOWN";
+ }
+ }
+
+ /**
+ * Get the grammar name
+ * @param The grammar class
+ * @return The grammar name
+ */
+ public static String getGrammarName(Object grammar)
+ {
+ if (grammar instanceof LdapMessageGrammar)
+ {
+ return "LDAP_MESSAGE_GRAMMAR";
+ }
+ else if (grammar instanceof LdapResultGrammar)
+ {
+ return "LDAP_RESULT_GRAMMAR";
+ }
+ else if (grammar instanceof LdapControlGrammar)
+ {
+ return "LDAP_CONTROL_GRAMMAR";
+ }
+ else if (grammar instanceof BindRequestGrammar)
+ {
+ return "BIND_REQUEST_GRAMMAR";
+ }
+ else if (grammar instanceof BindResponseGrammar)
+ {
+ return "BIND_RESPONSE_GRAMMAR";
+ }
+ else if (grammar instanceof UnBindRequestGrammar)
+ {
+ return "UNBIND_REQUEST_GRAMMAR";
+ }
+ else if (grammar instanceof AbandonRequestGrammar)
+ {
+ return "ABANDON_REQUEST_GRAMMAR";
+ }
+ else if (grammar instanceof AddResponseGrammar)
+ {
+ return "ADD_RESPONSE_GRAMMAR";
+ }
+ else
+ {
+ return "UNKNOWN GRAMMAR";
+ }
+ }
/**
* Get the string representing the state
@@ -536,25 +657,28 @@
{
case LDAP_MESSAGE_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : LdapMessageString[state] );
+ return ( ( state == -1 ) ? "LDAP_MESSAGE_END_STATE" : LdapMessageString[state] );
case LDAP_RESULT_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : LdapResultString[state] );
+ return ( ( state == -1 ) ? "LDAP_RESULT_END_STATE" : LdapResultString[state] );
case LDAP_CONTROL_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : LdapControlString[state] );
+ return ( ( state == -1 ) ? "LDAP_CONTROL_END_STATE" : LdapControlString[state] );
case BIND_REQUEST_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : BindRequestString[state] );
+ return ( ( state == -1 ) ? "BIND_REQUEST_END_STATE" : BindRequestString[state] );
case BIND_RESPONSE_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : BindResponseString[state] );
+ return ( ( state == -1 ) ? "IND_RESPONSE_END_STATE" : BindResponseString[state] );
case UNBIND_REQUEST_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : UnBindRequestString[state] );
+ return ( ( state == -1 ) ? "UNBIND_REQUEST_END_STATE" : UnBindRequestString[state] );
case ABANDON_REQUEST_GRAMMAR :
- return ( ( state == -1 ) ? "END_STATE" : AbandonRequestString[state] );
+ return ( ( state == -1 ) ? "ABANDON_REQUEST_END_STATE" : AbandonRequestString[state] );
+
+ case ADD_REQUEST_GRAMMAR :
+ return ( ( state == -1 ) ? "ADD_REQUEST_END_STATE" : AddRequestString[state] );
default :
return "UNKNOWN";