directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1028591 [3/5] - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared: asn1/ber/ asn1/ber/grammar/ ldap/codec/ ldap/codec/controls/ppolicy/ ldap/codec/controls/replication/syncDoneValue/ ldap/codec/controls/replication/...
Date Fri, 29 Oct 2010 02:26:04 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -30,282 +30,163 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapStatesEnum implements States
+public enum LdapStatesEnum implements States
 {
     // ~ Static fields/initializers
     // -----------------------------------------------------------------
-    public static final int START_STATE =                       0;
-    public static final int LDAP_MESSAGE_STATE =                1;
-    public static final int MESSAGE_ID_STATE =                  2;
-    public static final int BIND_REQUEST_STATE =                3;
-    public static final int BIND_RESPONSE_STATE =               4;
-    public static final int UNBIND_REQUEST_STATE =              5;
-    public static final int SEARCH_REQUEST_STATE =              6;
-    public static final int SEARCH_RESULT_ENTRY_STATE =         7;
-    public static final int SEARCH_RESULT_DONE_STATE =          8;
-    public static final int SEARCH_RESULT_REFERENCE_STATE =     9;
-    public static final int MODIFY_REQUEST_STATE =              10;
-    public static final int MODIFY_RESPONSE_STATE =             11;
-    public static final int ADD_REQUEST_STATE =                 12;
-    public static final int ADD_RESPONSE_STATE =                13;
-    public static final int DEL_REQUEST_STATE =                 14;
-    public static final int DEL_RESPONSE_STATE =                15;
-    public static final int MODIFY_DN_REQUEST_STATE =           16;
-    public static final int MODIFY_DN_RESPONSE_STATE =          17;
-    public static final int COMPARE_REQUEST_STATE =             18;
-    public static final int COMPARE_RESPONSE_STATE =            19;
-    public static final int ABANDON_REQUEST_STATE =             20;
-    public static final int EXTENDED_REQUEST_STATE =            21;
-    public static final int EXTENDED_RESPONSE_STATE =           22;
-    public static final int VERSION_STATE =                     23;
-    public static final int NAME_STATE =                        24;
-    public static final int SIMPLE_STATE =                      25;
-    public static final int SASL_STATE =                        26;
-    public static final int MECHANISM_STATE =                   27;
-    public static final int CREDENTIALS_STATE =                 28;
-    public static final int RESULT_CODE_BR_STATE =              29;
-    public static final int MATCHED_DN_BR_STATE =               30;
-    public static final int ERROR_MESSAGE_BR_STATE =            31;
-    public static final int REFERRALS_BR_STATE =                32;
-    public static final int REFERRAL_BR_STATE =                 33;
-    public static final int SERVER_SASL_CREDENTIALS_STATE =     34;
-    public static final int RESULT_CODE_STATE =                 35;
-    public static final int MATCHED_DN_STATE =                  36;
-    public static final int ERROR_MESSAGE_STATE =               37;
-    public static final int REFERRALS_STATE =                   38;
-    public static final int REFERRAL_STATE =                    39;
-    public static final int REQUEST_NAME_STATE =                40;
-    public static final int REQUEST_VALUE_STATE =               41;
-    public static final int RESPONSE_NAME_STATE =               42;
-    public static final int RESPONSE_STATE =                    43;
-    public static final int RESULT_CODE_ER_STATE =              44;
-    public static final int MATCHED_DN_ER_STATE =               45;
-    public static final int ERROR_MESSAGE_ER_STATE =            46;
-    public static final int REFERRALS_ER_STATE =                47;
-    public static final int REFERRAL_ER_STATE =                 48;
-    public static final int ENTRY_STATE =                       49;
-    public static final int ATTRIBUTES_STATE =                  50;
-    public static final int ATTRIBUTE_STATE =                   51;
-    public static final int TYPE_STATE =                        52;
-    public static final int VALUES_STATE =                      53;
-    public static final int VALUE_STATE =                       54;
-    public static final int OBJECT_STATE =                      55;
-    public static final int MODIFICATIONS_STATE =               56;
-    public static final int MODIFICATIONS_SEQ_STATE =           57;
-    public static final int OPERATION_STATE =                   58;
-    public static final int MODIFICATION_STATE =                59;
-    public static final int TYPE_MOD_STATE =                    60;
-    public static final int VALS_STATE =                        61;
-    public static final int ATTRIBUTE_VALUE_STATE =             62;
-    public static final int ENTRY_MOD_DN_STATE =                63;
-    public static final int NEW_RDN_STATE =                     64;
-    public static final int DELETE_OLD_RDN_STATE =              65;
-    public static final int NEW_SUPERIOR_STATE =                66;
-    public static final int ENTRY_COMP_STATE =                  67;
-    public static final int AVA_STATE =                         68;
-    public static final int ATTRIBUTE_DESC_STATE =              69;
-    public static final int ASSERTION_VALUE_STATE =             70;
-    public static final int BASE_OBJECT_STATE =                 71;
-    public static final int SCOPE_STATE =                       72;
-    public static final int DEREF_ALIAS_STATE =                 73;
-    public static final int SIZE_LIMIT_STATE =                  74;
-    public static final int TIME_LIMIT_STATE =                  75;
-    public static final int TYPES_ONLY_STATE =                  76;
-    public static final int AND_STATE =                         77;
-    public static final int OR_STATE =                          78;
-    public static final int NOT_STATE =                         79;
-    public static final int EQUALITY_MATCH_STATE =              80;
-    public static final int SUBSTRING_FILTER_STATE =            81;
-    public static final int GREATER_OR_EQUAL_STATE =            82;
-    public static final int LESS_OR_EQUAL_STATE =               83;
-    public static final int PRESENT_STATE =                     84;
-    public static final int APPROX_MATCH_STATE =                85;
-    public static final int EXTENSIBLE_MATCH_STATE =            86;
-    public static final int ATTRIBUTE_DESC_FILTER_STATE =       87;
-    public static final int ASSERTION_VALUE_FILTER_STATE =      88;
-    public static final int ATTRIBUTE_DESCRIPTION_LIST_STATE =  89;
-    public static final int ATTRIBUTE_DESCRIPTION_STATE =       90;
-    public static final int TYPE_SUBSTRING_STATE =              91;
-    public static final int SUBSTRINGS_STATE =                  92;
-    public static final int INITIAL_STATE =                     93;
-    public static final int ANY_STATE =                         94;
-    public static final int FINAL_STATE =                       95;
-    public static final int MATCHING_RULE_STATE =               96;
-    public static final int TYPE_MATCHING_RULE_STATE =          97;
-    public static final int MATCH_VALUE_STATE =                 98;
-    public static final int DN_ATTRIBUTES_STATE =               99;
-    public static final int OBJECT_NAME_STATE =                 100;
-    public static final int ATTRIBUTES_SR_STATE =               101;
-    public static final int PARTIAL_ATTRIBUTES_LIST_STATE =     102;
-    public static final int TYPE_SR_STATE =                     103;
-    public static final int VALS_SR_STATE =                     104;
-    public static final int ATTRIBUTE_VALUE_SR_STATE =          105;
-    public static final int REFERENCE_STATE =                   106;
-    public static final int CONTROLS_STATE =                    107;
-    public static final int CONTROL_STATE =                     108;
-    public static final int CONTROL_TYPE_STATE =                109;
-    public static final int CRITICALITY_STATE =                 110;
-    public static final int CONTROL_VALUE_STATE =               111;
-    public static final int INTERMEDIATE_RESPONSE_STATE =       112;
-    public static final int INTERMEDIATE_RESPONSE_NAME_STATE =  113;
-    public static final int INTERMEDIATE_RESPONSE_VALUE_STATE = 114;
-    
-    
-    public static final int LAST_LDAP_STATE = 115;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] LDAP_MESSAGE_STRING = new String[]
-        { 
-        "START_STATE",
-        "LDAP_MESSAGE_STATE",
-        "MESSAGE_ID_STATE",
-        "BIND_REQUEST_STATE",
-        "BIND_RESPONSE_STATE",
-        "UNBIND_REQUEST_STATE",
-        "SEARCH_REQUEST_STATE",
-        "SEARCH_RESULT_ENTRY_STATE",
-        "SEARCH_RESULT_DONE_STATE",
-        "SEARCH_RESULT_REFERENCE_STATE",
-        "MODIFY_REQUEST_STATE",
-        "MODIFY_RESPONSE_STATE",
-        "ADD_REQUEST_STATE",
-        "ADD_RESPONSE_STATE",
-        "DEL_REQUEST_STATE",
-        "DEL_RESPONSE_STATE",
-        "MODIFY_DN_REQUEST_STATE",
-        "MODIFY_DN_RESPONSE_STATE",
-        "COMPARE_REQUEST_STATE",
-        "COMPARE_RESPONSE_STATE",
-        "ABANDON_REQUEST_STATE",
-        "EXTENDED_REQUEST_STATE",
-        "EXTENDED_RESPONSE_STATE",
-        "VERSION_STATE",
-        "NAME_STATE",
-        "SIMPLE_STATE",
-        "SASL_STATE",
-        "MECHANISM_STATE",
-        "CREDENTIALS_STATE",
-        "RESULT_CODE_BR_STATE",
-        "MATCHED_DN_BR_STATE",
-        "ERROR_MESSAGE_BR_STATE",
-        "REFERRALS_BR_STATE",
-        "REFERRAL_BR_STATE",
-        "SERVER_SASL_CREDENTIALS_STATE",
-        "RESULT_CODE_STATE",
-        "MATCHED_DN_STATE",
-        "ERROR_MESSAGE_STATE",
-        "REFERRALS_STATE",
-        "REFERRAL_STATE",
-        "REQUEST_NAME_STATE",
-        "REQUEST_VALUE_STATE",
-        "RESPONSE_NAME_STATE",
-        "RESPONSE_STATE",
-        "RESULT_CODE_ER_STATE",
-        "MATCHED_DN_ER_STATE",
-        "ERROR_MESSAGE_ER_STATE",
-        "REFERRALS_ER_STATE",
-        "REFERRAL_ER_STATE",
-        "ENTRY_STATE",
-        "ATTRIBUTES_STATE",
-        "ATTRIBUTE_STATE",
-        "TYPE_STATE",
-        "VALUES_STATE",
-        "VALUE_STATE",
-        "OBJECT_STATE",
-        "MODIFICATIONS_STATE",
-        "MODIFICATIONS_SEQ_STATE",
-        "OPERATION_STATE",
-        "MODIFICATION_STATE",
-        "TYPE_MOD_STATE",
-        "VALS_STATE",
-        "ATTRIBUTE_VALUE_STATE",
-        "ENTRY_MOD_DN_STATE",
-        "NEW_RDN_STATE",
-        "DELETE_OLD_RDN_STATE",
-        "NEW_SUPERIOR_STATE",
-        "ENTRY_COMP_STATE",
-        "AVA_STATE",
-        "ATTRIBUTE_DESC_STATE",
-        "ASSERTION_VALUE_STATE",
-        "BASE_OBJECT_STATE",
-        "SCOPE_STATE",
-        "DEREF_ALIAS_STATE",
-        "SIZE_LIMIT_STATE",
-        "TIME_LIMIT_STATE",
-        "TYPES_ONLY_STATE",
-        "AND_STATE",
-        "OR_STATE",
-        "NOT_STATE",
-        "EQUALITY_MATCH_STATE",
-        "SUBSTRINGS_FILTER_STATE",
-        "GREATER_OR_EQUAL_STATE",
-        "LESS_OR_EQUAL_STATE",
-        "PRESENT_STATE",
-        "APPROX_MATCH_STATE",
-        "EXTENSIBLE_MATCH_STATE",
-        "SUBSTRING_FILTER_STATE",
-        "ATTRIBUTE_DESC_FILTER_STATE",
-        "ASSERTION_VALUE_FILTER_STATE",
-        "ATTRIBUTE_DESCRIPTION_LIST_STATE",
-        "ATTRIBUTE_DESCRIPTION_STATE",
-        "TYPE_SUBSTRING_STATE",
-        "SUBSTRINGS_STATE",
-        "INITIAL_STATE",
-        "ANY_STATE",
-        "FINAL_STATE",
-        "MATCHING_RULE_STATE",
-        "TYPE_MATCHING_RULE_STATE",
-        "MATCH_VALUE_STATE",
-        "DN_ATTRIBUTES_STATE",
-        "OBJECT_NAME_STATE",
-        "ATTRIBUTES_SR_STATE",
-        "PARTIAL_ATTRIBUTES_LIST_STATE",
-        "TYPE_SR_STATE",
-        "VALS_SR_STATE",
-        "ATTRIBUTE_VALUE_SR_STATE",
-        "REFERENCE_STATE",
-        "CONTROLS_STATE",
-        "CONTROL_STATE",
-        "CONTROL_TYPE_STATE",
-        "CRITICALITY_STATE",
-        "CONTROL_VALUE_STATE",
-        "INTERMEDIATE_RESPONSE_STATE",
-        "INTERMEDIATE_RESPONSE_NAME_STATE",
-        "INTERMEDIATE_RESPONSE_VALUE_STATE",
-        "LAST_LDAP_STATE",
-        };
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
 
-    /** The instance */
-    private static LdapStatesEnum instance = new LdapStatesEnum();
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
 
+    /** The END_STATE */
+    END_STATE(-1),
 
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    START_STATE(                      0),
+    LDAP_MESSAGE_STATE(               1),
+    MESSAGE_ID_STATE(                 2),
+    BIND_REQUEST_STATE(               3),
+    BIND_RESPONSE_STATE(              4),
+    UNBIND_REQUEST_STATE(             5),
+    SEARCH_REQUEST_STATE(             6),
+    SEARCH_RESULT_ENTRY_STATE(        7),
+    SEARCH_RESULT_DONE_STATE(         8),
+    SEARCH_RESULT_REFERENCE_STATE(    9),
+    MODIFY_REQUEST_STATE(             10),
+    MODIFY_RESPONSE_STATE(            11),
+    ADD_REQUEST_STATE(                12),
+    ADD_RESPONSE_STATE(               13),
+    DEL_REQUEST_STATE(                14),
+    DEL_RESPONSE_STATE(               15),
+    MODIFY_DN_REQUEST_STATE(          16),
+    MODIFY_DN_RESPONSE_STATE(         17),
+    COMPARE_REQUEST_STATE(            18),
+    COMPARE_RESPONSE_STATE(           19),
+    ABANDON_REQUEST_STATE(            20),
+    EXTENDED_REQUEST_STATE(           21),
+    EXTENDED_RESPONSE_STATE(          22),
+    VERSION_STATE(                    23),
+    NAME_STATE(                       24),
+    SIMPLE_STATE(                     25),
+    SASL_STATE(                       26),
+    MECHANISM_STATE(                  27),
+    CREDENTIALS_STATE(                28),
+    RESULT_CODE_BR_STATE(             29),
+    MATCHED_DN_BR_STATE(              30),
+    ERROR_MESSAGE_BR_STATE(           31),
+    REFERRALS_BR_STATE(               32),
+    REFERRAL_BR_STATE(                33),
+    SERVER_SASL_CREDENTIALS_STATE(    34),
+    RESULT_CODE_STATE(                35),
+    MATCHED_DN_STATE(                 36),
+    ERROR_MESSAGE_STATE(              37),
+    REFERRALS_STATE(                  38),
+    REFERRAL_STATE(                   39),
+    REQUEST_NAME_STATE(               40),
+    REQUEST_VALUE_STATE(              41),
+    RESPONSE_NAME_STATE(              42),
+    RESPONSE_STATE(                   43),
+    RESULT_CODE_ER_STATE(             44),
+    MATCHED_DN_ER_STATE(              45),
+    ERROR_MESSAGE_ER_STATE(           46),
+    REFERRALS_ER_STATE(               47),
+    REFERRAL_ER_STATE(                48),
+    ENTRY_STATE(                      49),
+    ATTRIBUTES_STATE(                 50),
+    ATTRIBUTE_STATE(                  51),
+    TYPE_STATE(                       52),
+    VALUES_STATE(                     53),
+    VALUE_STATE(                      54),
+    OBJECT_STATE(                     55),
+    MODIFICATIONS_STATE(              56),
+    MODIFICATIONS_SEQ_STATE(          57),
+    OPERATION_STATE(                  58),
+    MODIFICATION_STATE(               59),
+    TYPE_MOD_STATE(                   60),
+    VALS_STATE(                       61),
+    ATTRIBUTE_VALUE_STATE(            62),
+    ENTRY_MOD_DN_STATE(               63),
+    NEW_RDN_STATE(                    64),
+    DELETE_OLD_RDN_STATE(             65),
+    NEW_SUPERIOR_STATE(               66),
+    ENTRY_COMP_STATE(                 67),
+    AVA_STATE(                        68),
+    ATTRIBUTE_DESC_STATE(             69),
+    ASSERTION_VALUE_STATE(            70),
+    BASE_OBJECT_STATE(                71),
+    SCOPE_STATE(                      72),
+    DEREF_ALIAS_STATE(                73),
+    SIZE_LIMIT_STATE(                 74),
+    TIME_LIMIT_STATE(                 75),
+    TYPES_ONLY_STATE(                 76),
+    AND_STATE(                        77),
+    OR_STATE(                         78),
+    NOT_STATE(                        79),
+    EQUALITY_MATCH_STATE(             80),
+    SUBSTRING_FILTER_STATE(           81),
+    GREATER_OR_EQUAL_STATE(           82),
+    LESS_OR_EQUAL_STATE(              83),
+    PRESENT_STATE(                    84),
+    APPROX_MATCH_STATE(               85),
+    EXTENSIBLE_MATCH_STATE(           86),
+    ATTRIBUTE_DESC_FILTER_STATE(      87),
+    ASSERTION_VALUE_FILTER_STATE(     88),
+    ATTRIBUTE_DESCRIPTION_LIST_STATE( 89),
+    ATTRIBUTE_DESCRIPTION_STATE(      90),
+    TYPE_SUBSTRING_STATE(             91),
+    SUBSTRINGS_STATE(                 92),
+    INITIAL_STATE(                    93),
+    ANY_STATE(                        94),
+    FINAL_STATE(                      95),
+    MATCHING_RULE_STATE(              96),
+    TYPE_MATCHING_RULE_STATE(         97),
+    MATCH_VALUE_STATE(                98),
+    DN_ATTRIBUTES_STATE(              99),
+    OBJECT_NAME_STATE(                100),
+    ATTRIBUTES_SR_STATE(              101),
+    PARTIAL_ATTRIBUTES_LIST_STATE(    102),
+    TYPE_SR_STATE(                    103),
+    VALS_SR_STATE(                    104),
+    ATTRIBUTE_VALUE_SR_STATE(         105),
+    REFERENCE_STATE(                  106),
+    CONTROLS_STATE(                   107),
+    CONTROL_STATE(                    108),
+    CONTROL_TYPE_STATE(               109),
+    CRITICALITY_STATE(                110),
+    CONTROL_VALUE_STATE(              111),
+    INTERMEDIATE_RESPONSE_STATE(      112),
+    INTERMEDIATE_RESPONSE_NAME_STATE( 113),
+    INTERMEDIATE_RESPONSE_VALUE_STATE(114),
+    
+    
+    LAST_LDAP_STATE(115);
 
+    
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of LdapStatesEnum.
+     *
+     * @param state
      */
-    private LdapStatesEnum()
+    LdapStatesEnum(int state)
     {
+        this.state = state;
     }
 
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
+    
 
     /**
      * Get the grammar name
@@ -348,6 +229,24 @@ public class LdapStatesEnum implements S
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "LDAP_MESSAGE_END_STATE" : LDAP_MESSAGE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "LDAP_MESSAGE_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public LdapStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlContainer.java Fri Oct 29 02:26:02 2010
@@ -39,7 +39,7 @@ public class PasswordPolicyResponseContr
         super();
         stateStack = new int[1];
         grammar = PasswordPolicyResponseControlGrammar.getInstance();
-        states = PasswordPolicyResponseControlStates.getInstance();
+        setTransition( PasswordPolicyResponseControlStates.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -26,7 +26,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 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.DecoderException;
@@ -57,12 +56,11 @@ public class PasswordPolicyResponseContr
     private PasswordPolicyResponseControlGrammar()
     {
         setName( PasswordPolicyResponseControlGrammar.class.getName() );
-        setStatesEnum( PasswordPolicyResponseControlStates.getInstance() );
 
-        super.transitions = new GrammarTransition[PasswordPolicyResponseControlStates.END_STATE][256];
-
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            States.INIT_GRAMMAR_STATE, PasswordPolicyResponseControlStates.START_STATE, UniversalTag.SEQUENCE.getValue(),
+        super.transitions = new GrammarTransition[PasswordPolicyResponseControlStates.END_STATE.getState()][256];
+        
+        super.transitions[PasswordPolicyResponseControlStates.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            PasswordPolicyResponseControlStates.INIT_GRAMMAR_STATE, PasswordPolicyResponseControlStates.START_STATE, UniversalTag.SEQUENCE.getValue(),
             new GrammarAction( "Initialization" )
             {
                 public void action( Asn1Container container ) throws DecoderException
@@ -74,7 +72,7 @@ public class PasswordPolicyResponseContr
                 }
             } );
 
-        super.transitions[PasswordPolicyResponseControlStates.START_STATE][PasswordPolicyResponseControlTags.TIME_BEFORE_EXPIRATION_TAG
+        super.transitions[PasswordPolicyResponseControlStates.START_STATE.getState()][PasswordPolicyResponseControlTags.TIME_BEFORE_EXPIRATION_TAG
             .getValue()] = new GrammarTransition( PasswordPolicyResponseControlStates.START_STATE,
             PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE,
             PasswordPolicyResponseControlTags.TIME_BEFORE_EXPIRATION_TAG.getValue(), new GrammarAction(
@@ -106,7 +104,7 @@ public class PasswordPolicyResponseContr
                 }
             } );
 
-        super.transitions[PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
+        super.transitions[PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE.getState()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
             PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE, PasswordPolicyResponseControlStates.END_STATE,
             UniversalTag.ENUMERATED.getValue(), new GrammarAction( "set ppolicy error value" )
             {
@@ -120,7 +118,7 @@ public class PasswordPolicyResponseContr
                 }
             } );
 
-        super.transitions[PasswordPolicyResponseControlStates.START_STATE][PasswordPolicyResponseControlTags.GRACE_AUTHNS_REMAINING_TAG
+        super.transitions[PasswordPolicyResponseControlStates.START_STATE.getState()][PasswordPolicyResponseControlTags.GRACE_AUTHNS_REMAINING_TAG
             .getValue()] = new GrammarTransition( PasswordPolicyResponseControlStates.START_STATE,
             PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE,
             PasswordPolicyResponseControlTags.GRACE_AUTHNS_REMAINING_TAG.getValue(), new GrammarAction(
@@ -152,7 +150,7 @@ public class PasswordPolicyResponseContr
                 }
             } );
 
-        super.transitions[PasswordPolicyResponseControlStates.START_STATE][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
+        super.transitions[PasswordPolicyResponseControlStates.START_STATE.getState()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
             PasswordPolicyResponseControlStates.START_STATE, PasswordPolicyResponseControlStates.PPOLICY_ERROR_STATE,
             UniversalTag.ENUMERATED.getValue(), new GrammarAction( "set ppolicy error value" )
             {
@@ -165,7 +163,6 @@ public class PasswordPolicyResponseContr
                     ppolicyRespContainer.setGrammarEndAllowed( true );
                 }
             } );
-
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlStates.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlStates.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlStates.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlStates.java Fri Oct 29 02:26:02 2010
@@ -30,46 +30,49 @@ import org.apache.directory.shared.asn1.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PasswordPolicyResponseControlStates implements States
+public enum PasswordPolicyResponseControlStates implements States
 {
 
-    public static final int START_STATE = 0;
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
 
-    public static final int PPOLICY_TIME_BEFORE_EXPIRATION_STATE = 1;
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
 
-    public static final int PPOLICY_GRACE_AUTHNS_REMAINING_STATE = 2;
+    START_STATE(0),
 
-    public static final int PPOLICY_ERROR_STATE = 3;
+    PPOLICY_TIME_BEFORE_EXPIRATION_STATE(1),
 
-    public static final int END_STATE = 4;
+    PPOLICY_GRACE_AUTHNS_REMAINING_STATE(2),
 
-    private static PasswordPolicyResponseControlStates instance = new PasswordPolicyResponseControlStates();
+    PPOLICY_ERROR_STATE(3),
 
-    private static final String[] PPOLICY_STATE_STRING = new String[]
-        { 
-          "START_STATE",
-          "PPOLICY_TIME_BEFORE_EXPIRATION_STATE",
-          "PPOLICY_GRACE_AUTHNS_REMAINING_STATE",
-          "PPOLICY_ERROR_STATE"
-        };
+    END_STATE(4);
 
-
-    private PasswordPolicyResponseControlStates()
+    private int state;
+    
+    /**
+     * 
+     * Creates a new instance of PasswordPolicyResponseControlStates.
+     *
+     * @param state
+     */
+    private PasswordPolicyResponseControlStates(int state)
     {
+        this.state = state;
     }
 
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
-
+    
     /**
      * {@inheritDoc}
      */
@@ -83,7 +86,6 @@ public class PasswordPolicyResponseContr
         return "UNKNOWN_GRAMMAR";
     }
 
-
     /**
      * {@inheritDoc}
      */
@@ -98,6 +100,24 @@ public class PasswordPolicyResponseContr
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : PPOLICY_STATE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR" : name() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public PasswordPolicyResponseControlStates getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlContainer.java Fri Oct 29 02:26:02 2010
@@ -45,7 +45,7 @@ public class SyncDoneValueControlContain
         super();
         stateStack = new int[1];
         grammar = SyncDoneValueControlGrammar.getInstance();
-        states = SyncDoneValueControlStatesEnum.getInstance();
+        setTransition( SyncDoneValueControlStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -25,7 +25,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 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.DecoderException;
@@ -73,9 +72,8 @@ public final class SyncDoneValueControlG
     private SyncDoneValueControlGrammar()
     {
         setName( SyncDoneValueControlGrammar.class.getName() );
-        setStatesEnum( SyncDoneValueControlStatesEnum.getInstance() );
 
-        super.transitions = new GrammarTransition[SyncDoneValueControlStatesEnum.LAST_SYNC_DONE_VALUE_STATE][256];
+        super.transitions = new GrammarTransition[SyncDoneValueControlStatesEnum.LAST_SYNC_DONE_VALUE_STATE.getState()][256];
 
         /** 
          * Transition from initial state to SyncDoneValue sequence
@@ -84,9 +82,9 @@ public final class SyncDoneValueControlG
          *     
          * Initialize the syncDoneValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            States.INIT_GRAMMAR_STATE, SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE, UniversalTag.SEQUENCE.getValue(),
-            new GrammarAction( "Initiaization" )
+        super.transitions[SyncDoneValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            SyncDoneValueControlStatesEnum.INIT_GRAMMAR_STATE, SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE, UniversalTag.SEQUENCE.getValue(),
+            new GrammarAction( "Initialization" )
             {
                 public void action( Asn1Container container ) throws DecoderException
                 {
@@ -104,7 +102,7 @@ public final class SyncDoneValueControlG
          *    ....
          * }
          */
-        super.transitions[SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE, SyncDoneValueControlStatesEnum.COOKIE_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncDoneValueControl cookie" )
             {
@@ -163,7 +161,7 @@ public final class SyncDoneValueControlG
          *    refreshDeletes BOOLEAN DEFAULT FALSE
          * }
          */
-        super.transitions[SyncDoneValueControlStatesEnum.COOKIE_STATE][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
+        super.transitions[SyncDoneValueControlStatesEnum.COOKIE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
             SyncDoneValueControlStatesEnum.COOKIE_STATE, SyncDoneValueControlStatesEnum.REFRESH_DELETES_STATE,
             UniversalTag.BOOLEAN.getValue(), refreshDeletesTagAction );
         
@@ -174,7 +172,7 @@ public final class SyncDoneValueControlG
          *    refreshDeletes BOOLEAN DEFAULT FALSE
          * }
          */
-        super.transitions[SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
+        super.transitions[SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
             SyncDoneValueControlStatesEnum.SYNC_DONE_VALUE_SEQUENCE_STATE, SyncDoneValueControlStatesEnum.REFRESH_DELETES_STATE,
             UniversalTag.BOOLEAN.getValue(), refreshDeletesTagAction );
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -31,52 +31,57 @@ import org.apache.directory.shared.asn1.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SyncDoneValueControlStatesEnum implements States
+public enum SyncDoneValueControlStatesEnum implements States
 {
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
+
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
+
+    /** The END_STATE */
+    END_STATE(-1),
+
+    
     /***/
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** sequence start state */
-    public static final int SYNC_DONE_VALUE_SEQUENCE_STATE = 1;
+    SYNC_DONE_VALUE_SEQUENCE_STATE(1),
 
     /** cookie value state */
-    public static final int COOKIE_STATE = 2;
+    COOKIE_STATE(2),
 
     /** refreshDeletes value state */
-    public static final int REFRESH_DELETES_STATE = 3;
+    REFRESH_DELETES_STATE(3),
 
     /** terminal state */
-    public static final int LAST_SYNC_DONE_VALUE_STATE = 4;
-
-    /** A string representation of all the states */
-    private static final String[] SYNC_DONE_VALUE_STRING = new String[]
-       {
-           "START_STATE",
-           "SYNC_DONE_VALUE_SEQUENCE_STATE",
-           "COOKIE_STATE",
-           "REFRESH_DELETES_STATE",
-       };
-
-    /** The instance */
-    private static SyncDoneValueControlStatesEnum instance = new SyncDoneValueControlStatesEnum();
-
+    LAST_SYNC_DONE_VALUE_STATE(4);
 
-    private SyncDoneValueControlStatesEnum()
+    private int state;
+    
+    /**
+     * 
+     * Creates a new instance of SyncDoneValueControlStatesEnum.
+     *
+     * @param state
+     */
+    private SyncDoneValueControlStatesEnum(int state)
     {
+        this.state = state;
     }
 
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
-
+    
     /**
      * Get the grammar name
      * 
@@ -114,7 +119,24 @@ public final class SyncDoneValueControlS
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SYNC_DONE_VALUE_GRAMMAR" : SYNC_DONE_VALUE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "SYNC_DONE_VALUE_GRAMMAR" : this.name() );
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SyncDoneValueControlStatesEnum getStartState()
+    {
+        return START_STATE;
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java Fri Oct 29 02:26:02 2010
@@ -43,7 +43,7 @@ public class SyncInfoValueControlContain
         super();
         stateStack = new int[1];
         grammar = SyncInfoValueControlGrammar.getInstance();
-        states = SyncInfoValueControlStatesEnum.getInstance();
+        setTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -25,7 +25,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 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.DecoderException;
@@ -81,10 +80,9 @@ public final class SyncInfoValueControlG
     private SyncInfoValueControlGrammar()
     {
         setName( SyncInfoValueControlGrammar.class.getName() );
-        setStatesEnum( SyncInfoValueControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE][256];
+        super.transitions = new GrammarTransition[SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE.getState()][256];
 
         /** 
          * Transition from initial state to SyncInfoValue newCookie choice
@@ -94,8 +92,8 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the syncInfoValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][SyncInfoValueTags.NEW_COOKIE_TAG.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][SyncInfoValueTags.NEW_COOKIE_TAG.getValue()] = 
+            new GrammarTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     SyncInfoValueControlStatesEnum.NEW_COOKIE_STATE, 
                                     SyncInfoValueTags.NEW_COOKIE_TAG.getValue(), 
                 new GrammarAction( "NewCookie choice for SyncInfoValueControl" )
@@ -135,8 +133,8 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the syncInfoValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][SyncInfoValueTags.REFRESH_DELETE_TAG.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][SyncInfoValueTags.REFRESH_DELETE_TAG.getValue()] = 
+            new GrammarTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE, 
                                     SyncInfoValueTags.REFRESH_DELETE_TAG.getValue(), 
                 new GrammarAction( "RefreshDelete choice for SyncInfoValueControl" )
@@ -164,7 +162,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the cookie object
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE, 
                                     SyncInfoValueControlStatesEnum.REFRESH_DELETE_COOKIE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(), 
@@ -203,7 +201,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDone flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_COOKIE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_COOKIE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_DELETE_COOKIE_STATE, 
                                     SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -256,7 +254,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDone flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_DELETE_STATE, 
                                     SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -309,8 +307,8 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the syncInfoValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][SyncInfoValueTags.REFRESH_PRESENT_TAG.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][SyncInfoValueTags.REFRESH_PRESENT_TAG.getValue()] = 
+            new GrammarTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE, 
                                     SyncInfoValueTags.REFRESH_PRESENT_TAG.getValue(), 
                 new GrammarAction( "RefreshDelete choice for SyncInfoValueControl" )
@@ -338,7 +336,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the cookie object
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE, 
                                     SyncInfoValueControlStatesEnum.REFRESH_PRESENT_COOKIE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(), 
@@ -379,7 +377,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDone flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_COOKIE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_COOKIE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_PRESENT_COOKIE_STATE, 
                                     SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -432,7 +430,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDone flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.REFRESH_PRESENT_STATE, 
                                     SyncInfoValueControlStatesEnum.LAST_SYNC_INFO_VALUE_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -484,8 +482,8 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the syncInfoValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][SyncInfoValueTags.SYNC_ID_SET_TAG.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][SyncInfoValueTags.SYNC_ID_SET_TAG.getValue()] = 
+            new GrammarTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE, 
                                     SyncInfoValueTags.SYNC_ID_SET_TAG.getValue(), 
                 new GrammarAction( "SyncIdSet choice for SyncInfoValueControl" )
@@ -510,7 +508,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the cookie object
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(), 
@@ -546,7 +544,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDeletes flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_REFRESH_DELETES_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -592,7 +590,7 @@ public final class SyncInfoValueControlG
          *     
          * Load the refreshDeletes flag
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_REFRESH_DELETES_STATE, 
                                     UniversalTag.BOOLEAN.getValue(), 
@@ -638,7 +636,7 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the UUID set : no action associated, except allowing a grammar end
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE][UniversalTag.SET.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE.getState()][UniversalTag.SET.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE, 
                                     UniversalTag.SET.getValue(), 
@@ -664,7 +662,7 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the UUID set : no action associated
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE][UniversalTag.SET.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE.getState()][UniversalTag.SET.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_COOKIE_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE, 
                                     UniversalTag.SET.getValue(),
@@ -690,7 +688,7 @@ public final class SyncInfoValueControlG
          *     
          * Initialize the UUID set : no action associated
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_REFRESH_DELETES_STATE][UniversalTag.SET.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_REFRESH_DELETES_STATE.getState()][UniversalTag.SET.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_REFRESH_DELETES_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE, 
                                     UniversalTag.SET.getValue(), 
@@ -716,7 +714,7 @@ public final class SyncInfoValueControlG
          *     
          * Add the first UUID in the UUIDs list
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_SET_OF_UUIDS_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_UUID_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(), 
@@ -763,7 +761,7 @@ public final class SyncInfoValueControlG
          *     
          * Add a new UUID in the UUIDs list
          */
-        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_UUID_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncInfoValueControlStatesEnum.SYNC_ID_SET_UUID_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncInfoValueControlStatesEnum.SYNC_ID_SET_UUID_STATE, 
                                     SyncInfoValueControlStatesEnum.SYNC_ID_SET_UUID_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(), 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -22,6 +22,7 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.States;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControlStatesEnum;
 
 
 /**
@@ -32,106 +33,89 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SyncInfoValueControlStatesEnum implements States
+public enum SyncInfoValueControlStatesEnum implements States
 {
     // ~ Static fields/initializers
     // -----------------------------------------------------------------
 
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
+
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
+
+    /** The END_STATE */
+    END_STATE(-1),
+
     // =========================================================================
     // SyncRequestValue control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** NewCookie state */
-    public static final int NEW_COOKIE_STATE = 1;
+    NEW_COOKIE_STATE(1),
 
     /** RefreshDelete state */
-    public static final int REFRESH_DELETE_STATE = 2;
+    REFRESH_DELETE_STATE(2),
     
     /** RefreshDelete cookie state */
-    public static final int REFRESH_DELETE_COOKIE_STATE = 3;
+    REFRESH_DELETE_COOKIE_STATE(3),
     
     /** RefreshDelete refreshDone state */
-    public static final int REFRESH_DELETE_REFRESH_DONE_STATE = 4;
+    REFRESH_DELETE_REFRESH_DONE_STATE(4),
     
     /** RefreshPresent state */
-    public static final int REFRESH_PRESENT_STATE = 5;
+    REFRESH_PRESENT_STATE(5),
     
     /** RefreshPresent cookie state */
-    public static final int REFRESH_PRESENT_COOKIE_STATE = 6;
+    REFRESH_PRESENT_COOKIE_STATE(6),
     
     /** RefreshPresent refreshDone state */
-    public static final int REFRESH_PRESENT_REFRESH_DONE_STATE = 7;
+    REFRESH_PRESENT_REFRESH_DONE_STATE(7),
     
     /** SyncIdSet state */
-    public static final int SYNC_ID_SET_STATE = 8;
+    SYNC_ID_SET_STATE(8),
     
     /** SyncIdSet cookie state */
-    public static final int SYNC_ID_SET_COOKIE_STATE = 9;
+    SYNC_ID_SET_COOKIE_STATE(9),
     
     /** SyncIdSet refreshDone state */
-    public static final int SYNC_ID_SET_REFRESH_DELETES_STATE = 10;
+    SYNC_ID_SET_REFRESH_DELETES_STATE(10),
     
     /** SyncIdSet SET OF UUIDs state */
-    public static final int SYNC_ID_SET_SET_OF_UUIDS_STATE = 11;
+    SYNC_ID_SET_SET_OF_UUIDS_STATE(11),
     
     /** SyncIdSet UUID state */
-    public static final int SYNC_ID_SET_UUID_STATE = 12;
+    SYNC_ID_SET_UUID_STATE(12),
 
     /** terminal state */
-    public static final int LAST_SYNC_INFO_VALUE_STATE = 13;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] SYNC_INFO_VALUE_STRING = new String[]
-        { 
-            "START_STATE",
-            "NEW_COOKIE_STATE",
-            "REFRESH_DELETE_STATE",
-            "REFRESH_DELETE_COOKIE_STATE",
-            "REFRESH_DELETE_REFRESH_DONE_STATE",
-            "REFRESH_PRESENT_STATE",
-            "REFRESH_PRESENT_COOKIE_STATE",
-            "REFRESH_PRESENT_REFRESH_DONE_STATE",
-            "SYNC_ID_SET_STATE",
-            "SYNC_ID_SET_COOKIE_STATE",
-            "SYNC_ID_SET_REFRESH_DELETES_STATE",
-            "SYNC_ID_SET_SET_OF_UUIDS_STATE",
-            "int SYNC_ID_SET_UUID_STATE"
-        };
-
-    /** The instance */
-    private static SyncInfoValueControlStatesEnum instance = new SyncInfoValueControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_SYNC_INFO_VALUE_STATE(13);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of SyncInfoValueControlStatesEnum.
+     *
+     * @param state
      */
-    private SyncInfoValueControlStatesEnum()
+    SyncInfoValueControlStatesEnum(int state)
     {
+        this.state = state;
     }
 
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
-
+    
     /**
      * Get the grammar name
      * 
@@ -169,6 +153,24 @@ public final class SyncInfoValueControlS
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SYNC_INFO_VALUE_END_STATE" : SYNC_INFO_VALUE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "SYNC_INFO_VALUE_END_STATE" : this.name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SyncInfoValueControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlContainer.java Fri Oct 29 02:26:02 2010
@@ -43,7 +43,7 @@ public class SyncRequestValueControlCont
         super();
         stateStack = new int[1];
         grammar = SyncRequestValueControlGrammar.getInstance();
-        states = SyncRequestValueControlStatesEnum.getInstance();
+        setTransition( SyncRequestValueControlStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -25,7 +25,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 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.DecoderException;
@@ -34,6 +33,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.util.IntegerDecoder;
 import org.apache.directory.shared.asn1.util.IntegerDecoderException;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlStatesEnum;
 import org.apache.directory.shared.ldap.message.control.replication.SynchronizationModeEnum;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -77,10 +77,9 @@ public final class SyncRequestValueContr
     private SyncRequestValueControlGrammar()
     {
         setName( SyncRequestValueControlGrammar.class.getName() );
-        setStatesEnum( SyncRequestValueControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[SyncRequestValueControlStatesEnum.LAST_SYNC_REQUEST_VALUE_STATE][256];
+        super.transitions = new GrammarTransition[SyncRequestValueControlStatesEnum.LAST_SYNC_REQUEST_VALUE_STATE.getState()][256];
 
         /** 
          * Transition from initial state to SyncRequestValue sequence
@@ -89,8 +88,8 @@ public final class SyncRequestValueContr
          *     
          * Initialize the syncRequestValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[SyncRequestValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
+            new GrammarTransition( SyncInfoValueControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     SyncRequestValueControlStatesEnum.SYNC_REQUEST_VALUE_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), 
                 null );
@@ -109,7 +108,7 @@ public final class SyncRequestValueContr
          *     
          * Stores the mode value
          */
-        super.transitions[SyncRequestValueControlStatesEnum.SYNC_REQUEST_VALUE_SEQUENCE_STATE][UniversalTag.ENUMERATED.getValue()] = 
+        super.transitions[SyncRequestValueControlStatesEnum.SYNC_REQUEST_VALUE_SEQUENCE_STATE.getState()][UniversalTag.ENUMERATED.getValue()] = 
             new GrammarTransition( SyncRequestValueControlStatesEnum.SYNC_REQUEST_VALUE_SEQUENCE_STATE, 
                 SyncRequestValueControlStatesEnum.MODE_STATE, 
                 UniversalTag.ENUMERATED.getValue(),
@@ -158,7 +157,7 @@ public final class SyncRequestValueContr
          *     
          * Stores the cookie
          */
-        super.transitions[SyncRequestValueControlStatesEnum.MODE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[SyncRequestValueControlStatesEnum.MODE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( SyncRequestValueControlStatesEnum.MODE_STATE,
                                     SyncRequestValueControlStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
                 new GrammarAction( "Set SyncRequestValueControl cookie" )
@@ -192,7 +191,7 @@ public final class SyncRequestValueContr
          *     
          * Stores the reloadHint flag
          */
-        super.transitions[SyncRequestValueControlStatesEnum.MODE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncRequestValueControlStatesEnum.MODE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncRequestValueControlStatesEnum.MODE_STATE,
                                     SyncRequestValueControlStatesEnum.RELOAD_HINT_STATE, UniversalTag.BOOLEAN.getValue(),
                 new GrammarAction( "Set SyncRequestValueControl reloadHint flag" )
@@ -235,7 +234,7 @@ public final class SyncRequestValueContr
          *     
          * Stores the reloadHint flag
          */
-        super.transitions[SyncRequestValueControlStatesEnum.COOKIE_STATE][UniversalTag.BOOLEAN.getValue()] = 
+        super.transitions[SyncRequestValueControlStatesEnum.COOKIE_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = 
             new GrammarTransition( SyncRequestValueControlStatesEnum.COOKIE_STATE,
                                     SyncRequestValueControlStatesEnum.RELOAD_HINT_STATE, UniversalTag.BOOLEAN.getValue(),
                 new GrammarAction( "Set SyncRequestValueControl reloadHint flag" )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,74 +32,65 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SyncRequestValueControlStatesEnum implements States
+public enum SyncRequestValueControlStatesEnum implements States
 {
     // ~ Static fields/initializers
     // -----------------------------------------------------------------
 
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
+
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
+
+    /** The END_STATE */
+    END_STATE(-1),
+
     // =========================================================================
     // SyncRequestValue control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence Value */
-    public static final int SYNC_REQUEST_VALUE_SEQUENCE_STATE = 1;
+    SYNC_REQUEST_VALUE_SEQUENCE_STATE(1),
 
     /** mode Value */
-    public static final int MODE_STATE = 2;
+    MODE_STATE(2),
     
     /** cookie Value */
-    public static final int COOKIE_STATE = 3;
+    COOKIE_STATE(3),
 
     /** reloadHint Value */
-    public static final int RELOAD_HINT_STATE = 4;
+    RELOAD_HINT_STATE(4),
 
     /** terminal state */
-    public static final int LAST_SYNC_REQUEST_VALUE_STATE = 5;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] SYNC_REQUEST_VALUE_STRING = new String[]
-        { 
-        "START_STATE", 
-        "SYNC_REQUEST_VALUE_SEQUENCE_STATE", 
-        "MODE_STATE",
-        "COOKIE_STATE", 
-        "RELOAD_HINT_STATE" 
-        };
-
-    /** The instance */
-    private static SyncRequestValueControlStatesEnum instance = new SyncRequestValueControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_SYNC_REQUEST_VALUE_STATE(5);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of SyncRequestValueControlStatesEnum.
+     *
+     * @param state
      */
-    private SyncRequestValueControlStatesEnum()
+    SyncRequestValueControlStatesEnum(int state)
     {
+        this.state = state;
     }
 
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
-
+    
     /**
      * Get the grammar name
      * 
@@ -137,6 +128,24 @@ public final class SyncRequestValueContr
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SYNC_REQUEST_VALUE_END_STATE" : SYNC_REQUEST_VALUE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "SYNC_REQUEST_VALUE_END_STATE" : this.name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SyncRequestValueControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java Fri Oct 29 02:26:02 2010
@@ -43,7 +43,7 @@ public class SyncStateValueControlContai
         super();
         stateStack = new int[1];
         grammar = SyncStateValueControlGrammar.getInstance();
-        states = SyncStateValueControlStatesEnum.getInstance();
+        setTransition( SyncStateValueControlStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -25,7 +25,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 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.DecoderException;
@@ -75,10 +74,9 @@ public final class SyncStateValueControl
     private SyncStateValueControlGrammar()
     {
         setName( SyncStateValueControlGrammar.class.getName() );
-        setStatesEnum( SyncStateValueControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[SyncStateValueControlStatesEnum.LAST_SYNC_STATE_VALUE_STATE][256];
+        super.transitions = new GrammarTransition[SyncStateValueControlStatesEnum.LAST_SYNC_STATE_VALUE_STATE.getState()][256];
 
         /** 
          * Transition from initial state to SyncStateValue sequence
@@ -87,8 +85,8 @@ public final class SyncStateValueControl
          *     
          * Initialize the syncStateValue object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            States.INIT_GRAMMAR_STATE, SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE,
+        super.transitions[SyncStateValueControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            SyncStateValueControlStatesEnum.INIT_GRAMMAR_STATE, SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE,
             UniversalTag.SEQUENCE.getValue(), null );
 
         /** 
@@ -104,7 +102,7 @@ public final class SyncStateValueControl
          *     
          * Stores the sync state type value
          */
-        super.transitions[SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE.getState()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
             SyncStateValueControlStatesEnum.SYNC_STATE_VALUE_SEQUENCE_STATE,
             SyncStateValueControlStatesEnum.SYNC_TYPE_STATE, UniversalTag.ENUMERATED.getValue(), new GrammarAction(
                 "Set SyncStateValueControl state type" )
@@ -150,7 +148,7 @@ public final class SyncStateValueControl
          *     
          * Stores the entryUUID
          */
-        super.transitions[SyncStateValueControlStatesEnum.SYNC_TYPE_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_TYPE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncStateValueControlStatesEnum.SYNC_TYPE_STATE, SyncStateValueControlStatesEnum.SYNC_UUID_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncStateValueControl entryUUID" )
             {
@@ -182,7 +180,7 @@ public final class SyncStateValueControl
          *     
          * Stores the reloadHint flag
          */
-        super.transitions[SyncStateValueControlStatesEnum.SYNC_UUID_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncStateValueControlStatesEnum.SYNC_UUID_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncStateValueControlStatesEnum.SYNC_UUID_STATE, SyncStateValueControlStatesEnum.COOKIE_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncStateValueControl cookie value" )
             {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,74 +32,65 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SyncStateValueControlStatesEnum implements States
+public enum SyncStateValueControlStatesEnum implements States
 {
     // ~ Static fields/initializers
     // -----------------------------------------------------------------
 
+    /** The initial state of every grammar */
+    INIT_GRAMMAR_STATE(0),
+
+    /** The ending state for every grammars */
+    GRAMMAR_END(-1),
+
+    /** The END_STATE */
+    END_STATE(-1),
+
     // =========================================================================
     // SyncStateValue control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence Value */
-    public static final int SYNC_STATE_VALUE_SEQUENCE_STATE = 1;
+    SYNC_STATE_VALUE_SEQUENCE_STATE(1),
 
     /** sync state type Value */
-    public static final int SYNC_TYPE_STATE = 2;
+    SYNC_TYPE_STATE(2),
     
     /** syncUUID Value */
-    public static final int SYNC_UUID_STATE = 3;
+    SYNC_UUID_STATE(3),
 
     /** cookie Value */
-    public static final int COOKIE_STATE = 4;
+    COOKIE_STATE(4),
 
     /** terminal state */
-    public static final int LAST_SYNC_STATE_VALUE_STATE = 5;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] SYNC_STATE_VALUE_STRING = new String[]
-        { 
-        "START_STATE", 
-        "SYNC_STATE_VALUE_SEQUENCE_STATE", 
-        "SYNC_TYPE_STATE",
-        "SYNC_UUID_STATE", 
-        "COOKIE_STATE" 
-        };
-
-    /** The instance */
-    private static SyncStateValueControlStatesEnum instance = new SyncStateValueControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_SYNC_STATE_VALUE_STATE(5);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of SyncStateValueControlStatesEnum.
+     *
+     * @param state
      */
-    private SyncStateValueControlStatesEnum()
+    private SyncStateValueControlStatesEnum(int state)
     {
+        this.state = state;
     }
 
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
-     * Get an instance of this class
      * 
-     * @return An instance on this class
+     * Get the state.
+     *
+     * @return State as integer value
      */
-    public static States getInstance()
+    public int getState()
     {
-        return instance;
+        return state;
     }
-
-
+    
     /**
      * Get the grammar name
      * 
@@ -137,6 +128,24 @@ public final class SyncStateValueControl
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SYNC_STATE_VALUE_END_STATE" : SYNC_STATE_VALUE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "SYNC_STATE_VALUE_END_STATE" : this.name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SyncStateValueControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlContainer.java Fri Oct 29 02:26:02 2010
@@ -43,7 +43,7 @@ public class SyncModifyDnControlContaine
         super();
         stateStack = new int[1];
         grammar = SyncModifyDnControlGrammar.getInstance();
-        states = SyncModifyDnControlStatesEnum.getInstance();
+        setTransition( SyncModifyDnControlStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 



Mime
View raw message