directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1028591 [4/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/controls/replication/syncmodifydn/SyncModifyDnControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlGrammar.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/SyncModifyDnControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlGrammar.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;
@@ -83,10 +82,9 @@ public final class SyncModifyDnControlGr
     private SyncModifyDnControlGrammar()
     {
         setName( SyncModifyDnControlGrammar.class.getName() );
-        setStatesEnum( SyncModifyDnControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[SyncModifyDnControlStatesEnum.LAST_SYNC_MODDN_VALUE_STATE][256];
+        super.transitions = new GrammarTransition[SyncModifyDnControlStatesEnum.LAST_SYNC_MODDN_VALUE_STATE.getState()][256];
 
         /** 
          * Transition from initial state to SyncModifyDnControl sequence
@@ -95,8 +93,8 @@ public final class SyncModifyDnControlGr
          *     
          * Initialize the SyncModifyDnControl object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            States.INIT_GRAMMAR_STATE, SyncModifyDnControlStatesEnum.SYNC_MODDN_VALUE_SEQUENCE_STATE,
+        super.transitions[SyncModifyDnControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            SyncModifyDnControlStatesEnum.INIT_GRAMMAR_STATE, SyncModifyDnControlStatesEnum.SYNC_MODDN_VALUE_SEQUENCE_STATE,
             UniversalTag.SEQUENCE.getValue(), null );
 
         /** 
@@ -107,7 +105,7 @@ public final class SyncModifyDnControlGr
          *     
          * Stores the entryDn value
          */
-        super.transitions[SyncModifyDnControlStatesEnum.SYNC_MODDN_VALUE_SEQUENCE_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.SYNC_MODDN_VALUE_SEQUENCE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.SYNC_MODDN_VALUE_SEQUENCE_STATE,
             SyncModifyDnControlStatesEnum.ENTRY_DN_STATE, UniversalTag.OCTET_STRING.getValue(), new GrammarAction(
                 "Set SyncModifyDnControl entryDn value" )
@@ -141,7 +139,7 @@ public final class SyncModifyDnControlGr
          * Stores the newSuperiorDn value
          */
 
-        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE][SyncModifyDnControlTags.MOVE_TAG.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE.getState()][SyncModifyDnControlTags.MOVE_TAG.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.ENTRY_DN_STATE, SyncModifyDnControlStatesEnum.MOVE_STATE,
             SyncModifyDnControlTags.MOVE_TAG.getValue(), new GrammarAction( "Set SyncModifyDnControl newSuperiorDn" )
             {
@@ -173,7 +171,7 @@ public final class SyncModifyDnControlGr
          * read the newSuperiorDn
          * move-name       [0] LDAPDN
          */
-        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE][SyncModifyDnControlTags.RENAME_TAG.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE.getState()][SyncModifyDnControlTags.RENAME_TAG.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.ENTRY_DN_STATE, SyncModifyDnControlStatesEnum.RENAME_STATE,
             SyncModifyDnControlTags.RENAME_TAG.getValue(), new GrammarAction( "enter SyncModifyDnControl rename choice" )
             {
@@ -195,7 +193,7 @@ public final class SyncModifyDnControlGr
          *            
          * Stores the newRdn value
          */
-        super.transitions[SyncModifyDnControlStatesEnum.RENAME_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.RENAME_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.RENAME_STATE, SyncModifyDnControlStatesEnum.RENAME_NEW_RDN_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncModifyDnControl newRdn value" )
             {
@@ -229,7 +227,7 @@ public final class SyncModifyDnControlGr
          *            
          * Stores the deleteOldRdn value
          */
-        super.transitions[SyncModifyDnControlStatesEnum.RENAME_NEW_RDN_STATE][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.RENAME_NEW_RDN_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.RENAME_NEW_RDN_STATE, SyncModifyDnControlStatesEnum.RENAME_DEL_OLD_RDN_STATE,
             UniversalTag.BOOLEAN.getValue(), new GrammarAction( "Set SyncModifyDnControl deleteOldRdn value" )
             {
@@ -262,7 +260,7 @@ public final class SyncModifyDnControlGr
          *     
          * Stores the deleteOldRdn flag
          */
-        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE][SyncModifyDnControlTags.MOVEANDRENAME_TAG.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.ENTRY_DN_STATE.getState()][SyncModifyDnControlTags.MOVEANDRENAME_TAG.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.ENTRY_DN_STATE, SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_STATE,
             SyncModifyDnControlTags.MOVEANDRENAME_TAG.getValue(), new GrammarAction( "enter SyncModifyDnControl moveAndRename choice" )
             {
@@ -284,7 +282,7 @@ public final class SyncModifyDnControlGr
          *            
          * Stores the newRdn value
          */
-        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_STATE, SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncModifyDnControl moveAndRename state's newSuperirorDN value" )
             {
@@ -316,7 +314,7 @@ public final class SyncModifyDnControlGr
          *            
          * Stores the newRdn value
          */
-        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE, SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_RDN_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set SyncModifyDnControl moveAndRename state's newRdn value" )
             {
@@ -348,7 +346,7 @@ public final class SyncModifyDnControlGr
          *     
          * Stores the deleteOldRdn flag
          */
-        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_RDN_STATE][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
+        super.transitions[SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_RDN_STATE.getState()][UniversalTag.BOOLEAN.getValue()] = new GrammarTransition(
             SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_NEW_RDN_STATE, SyncModifyDnControlStatesEnum.MOVE_AND_RENAME_DEL_OLD_RDN_STATE,
             UniversalTag.BOOLEAN.getValue(), new GrammarAction( "Set SyncModifyDnControl deleteOldRdn value" )
             {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlStatesEnum.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/SyncModifyDnControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,98 +32,83 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SyncModifyDnControlStatesEnum implements States
+public enum SyncModifyDnControlStatesEnum 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),
+
     // =========================================================================
     // SyncModifyDnControl's control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_SYNC_MODDN = 0;
+    START_SYNC_MODDN(0),
 
     /** Sequence Value */
-    public static final int SYNC_MODDN_VALUE_SEQUENCE_STATE = 1;
+    SYNC_MODDN_VALUE_SEQUENCE_STATE(1),
 
     /** modDn control's entryDN */
-    public static final int ENTRY_DN_STATE = 2;
+    ENTRY_DN_STATE(2),
     
     /** modDn control's move operation state */
-    public static final int MOVE_STATE = 3;
+    MOVE_STATE(3),
     
     /** modDn rename sequence */
-    public static final int RENAME_STATE = 4;
+    RENAME_STATE(4),
 
     /** modDn rename sequence */
-    public static final int MOVE_AND_RENAME_STATE = 5;
+    MOVE_AND_RENAME_STATE(5),
 
     /** modDn control's rename newRDN */
-    public static final int RENAME_NEW_RDN_STATE = 6;
+    RENAME_NEW_RDN_STATE(6),
 
     /** modDn control's rename deleteOldRdn flag */
-    public static final int RENAME_DEL_OLD_RDN_STATE = 7;
+    RENAME_DEL_OLD_RDN_STATE(7),
     
     /** modDn control's move and rename newSuperiorDN */
-    public static final int MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE = 8;
+    MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE(8),
 
     /** modDn control's move and rename newRDN */
-    public static final int MOVE_AND_RENAME_NEW_RDN_STATE = 9;
+    MOVE_AND_RENAME_NEW_RDN_STATE(9),
 
     /** modDn control's move and rename deleteOldRdn flag */
-    public static final int MOVE_AND_RENAME_DEL_OLD_RDN_STATE = 10;
+    MOVE_AND_RENAME_DEL_OLD_RDN_STATE(10),
 
     /** terminal state */
-    public static final int LAST_SYNC_MODDN_VALUE_STATE = 11;
+    LAST_SYNC_MODDN_VALUE_STATE(11);
+    
+    private int state;
     
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] SYNC_MODIFY_DN_STRING = new String[]
-        { 
-        "START_SYNC_MODDN", 
-        "SYNC_MODDN_VALUE_SEQUENCE_STATE", 
-        "ENTRY_DN_STATE",
-        "MOVE_STATE", 
-        "RENAME_STATE",
-        "MOVE_AND_RENAME_STATE",
-        "RENAME_NEW_RDN_STATE",
-        "RENAME_DEL_OLD_RDN_STATE",
-        "MOVE_AND_RENAME_NEW_SUPERIOR_DN_STATE",
-        "MOVE_AND_RENAME_NEW_RDN_STATE",
-        "MOVE_AND_RENAME_DEL_OLD_RDN_STATE",
-        };
-
-    /** The instance */
-    private static SyncModifyDnControlStatesEnum instance = new SyncModifyDnControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
-
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of SyncModifyDnControlStatesEnum.
+     *
+     * @param state
      */
-    private SyncModifyDnControlStatesEnum()
+    SyncModifyDnControlStatesEnum(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
      * 
@@ -161,6 +146,24 @@ public final class SyncModifyDnControlSt
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SYNC_MODDN_VALUE_END_STATE" : SYNC_MODIFY_DN_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "SYNC_MODDN_VALUE_END_STATE" : this.name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SyncModifyDnControlStatesEnum getStartState()
+    {
+        return START_SYNC_MODDN;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelContainer.java Fri Oct 29 02:26:02 2010
@@ -43,7 +43,7 @@ public class CancelContainer extends Abs
         super();
         stateStack = new int[1];
         grammar = CancelGrammar.getInstance();
-        states = CancelStatesEnum.getInstance();
+        setTransition( CancelStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelGrammar.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;
@@ -69,10 +68,9 @@ public final class CancelGrammar extends
     private CancelGrammar()
     {
         setName( CancelGrammar.class.getName() );
-        setStatesEnum( CancelStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[CancelStatesEnum.LAST_CANCEL_STATE][256];
+        super.transitions = new GrammarTransition[CancelStatesEnum.LAST_CANCEL_STATE.getState()][256];
 
         /**
          * Transition from init state to cancel sequence
@@ -81,8 +79,8 @@ public final class CancelGrammar extends
          * 
          * Creates the Cancel object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE,
+        super.transitions[CancelStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
+            new GrammarTransition( CancelStatesEnum.INIT_GRAMMAR_STATE,
                                     CancelStatesEnum.CANCEL_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(),
                 new GrammarAction(
@@ -105,7 +103,7 @@ public final class CancelGrammar extends
          *     
          * Set the cancelId value into the Cancel object.    
          */
-        super.transitions[CancelStatesEnum.CANCEL_SEQUENCE_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[CancelStatesEnum.CANCEL_SEQUENCE_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( CancelStatesEnum.CANCEL_SEQUENCE_STATE,
                                     CancelStatesEnum.CANCEL_ID_STATE, 
                                     UniversalTag.INTEGER.getValue(), 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,66 +32,59 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class CancelStatesEnum implements States
+public enum CancelStatesEnum 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),
+
     // =========================================================================
     // Cancel grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence */
-    public static final int CANCEL_SEQUENCE_STATE = 1;
+    CANCEL_SEQUENCE_STATE(1),
 
     /** cancelId */
-    public static final int CANCEL_ID_STATE = 2;
+    CANCEL_ID_STATE(2),
 
     /** terminal state */
-    public static final int LAST_CANCEL_STATE = 3;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] CANCEL_STRING = new String[]
-        { 
-        "START_STATE", 
-        "CANCEL_SEQUENCE_STATE",
-        "CANCEL_ID_STATE" 
-        };
-
-    /** The instance */
-    private static CancelStatesEnum instance = new CancelStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_CANCEL_STATE(3);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of CancelStatesEnum.
+     *
+     * @param state
      */
-    private CancelStatesEnum()
+    CancelStatesEnum(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
      * 
@@ -129,6 +122,24 @@ public final class CancelStatesEnum impl
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "CANCEL_END_STATE" : CANCEL_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "CANCEL_END_STATE" : this.name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public CancelStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationContainer.java Fri Oct 29 02:26:02 2010
@@ -42,7 +42,7 @@ public class CertGenerationContainer ext
         super();
         stateStack = new int[1];
         grammar = CertGenerationGrammar.getInstance();
-        states = CertGenerationStatesEnum.getInstance();
+        setTransition( CertGenerationStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationGrammar.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;
@@ -70,10 +69,9 @@ public class CertGenerationGrammar exten
     public CertGenerationGrammar()
     {
         setName( CertGenerationGrammar.class.getName() );
-        setStatesEnum( CertGenerationStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[CertGenerationStatesEnum.LAST_CERT_GENERATION_STATE][256];
+        super.transitions = new GrammarTransition[CertGenerationStatesEnum.LAST_CERT_GENERATION_STATE.getState()][256];
 
         /**
          * Transition from init state to certificate generation
@@ -83,8 +81,8 @@ public class CertGenerationGrammar exten
          *     
          * Creates the CertGenerationObject object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            States.INIT_GRAMMAR_STATE, CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,
+        super.transitions[CertGenerationStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            CertGenerationStatesEnum.INIT_GRAMMAR_STATE, CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,
             UniversalTag.SEQUENCE.getValue(), new GrammarAction( "Init CertGenerationObject" )
             {
                 public void action( Asn1Container container )
@@ -104,7 +102,7 @@ public class CertGenerationGrammar exten
          *     
          * Set the targetDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             CertGenerationStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE, CertGenerationStatesEnum.TARGETDN_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set Cert Generation target DN value" )
             {
@@ -150,7 +148,7 @@ public class CertGenerationGrammar exten
          *     
          * Set the issuerDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.TARGETDN_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[CertGenerationStatesEnum.TARGETDN_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             CertGenerationStatesEnum.TARGETDN_STATE, CertGenerationStatesEnum.ISSUER_STATE, UniversalTag.OCTET_STRING.getValue(),
             new GrammarAction( "Set Cert Generation issuer DN value" )
             {
@@ -190,7 +188,7 @@ public class CertGenerationGrammar exten
          *     
          * Set the subjectDN value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.ISSUER_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[CertGenerationStatesEnum.ISSUER_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             CertGenerationStatesEnum.ISSUER_STATE, CertGenerationStatesEnum.SUBJECT_STATE, UniversalTag.OCTET_STRING.getValue(),
             new GrammarAction( "Set Cert Generation subject DN value" )
             {
@@ -235,7 +233,7 @@ public class CertGenerationGrammar exten
          *     
          * Set the key algorithm value into the CertGenerationObject instance.
          */
-        super.transitions[CertGenerationStatesEnum.SUBJECT_STATE][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
+        super.transitions[CertGenerationStatesEnum.SUBJECT_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             CertGenerationStatesEnum.SUBJECT_STATE, CertGenerationStatesEnum.KEY_ALGORITHM_STATE,
             UniversalTag.OCTET_STRING.getValue(), new GrammarAction( "Set Cert Generation key algorithm value" )
             {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -29,42 +29,62 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CertGenerationStatesEnum implements States
+public enum CertGenerationStatesEnum 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),
+
     /** start state*/
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** sequence*/
-    public static final int CERT_GENERATION_REQUEST_SEQUENCE_STATE = 1;
+    CERT_GENERATION_REQUEST_SEQUENCE_STATE(1),
 
     /** the target DN*/
-    public static final int TARGETDN_STATE = 2;
+    TARGETDN_STATE(2),
 
     /** the issuer DN*/
-    public static final int ISSUER_STATE = 3;
+    ISSUER_STATE(3),
 
     /** the subject DN*/
-    public static final int SUBJECT_STATE = 4;
+    SUBJECT_STATE(4),
 
     /** the key algorithm*/
-    public static final int KEY_ALGORITHM_STATE = 5;
+    KEY_ALGORITHM_STATE(5),
 
     /** terminal state */
-    public static final int LAST_CERT_GENERATION_STATE = 6;
+    LAST_CERT_GENERATION_STATE(6);
 
-    private static String[] certGenerationString = new String[]
-        {
-          "START_STATE",
-          "CERT_GENERATION_REQUEST_SEQUENCE_STATE",
-          "TARGETDN_STATE", "ISSUER_STATE",
-          "SUBJECT_STATE",
-          "KEY_ALGORITHM_STATE"
-        };
-
-    /** a singleton instance*/
-    private static CertGenerationStatesEnum instance = new CertGenerationStatesEnum();
+    private int state;
+    
+    /**
+     * 
+     * Creates a new instance of CertGenerationStatesEnum.
+     *
+     * @param state
+     */
+    private CertGenerationStatesEnum( int state )
+    {
+        this.state = state;
+    }
 
+    /**
+     * 
+     * Get the state.
+     *
+     * @return State as integer value
+     */
+    public int getState()
+    {
+        return state;
+    }
     
     /**
      * Get the grammar name
@@ -103,16 +123,24 @@ public class CertGenerationStatesEnum im
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "CERT_GENERATION_END_STATE" : certGenerationString[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "CERT_GENERATION_END_STATE" : this.name() );
     }
 
+    
     /**
-     * Get an instance of this class
-     * 
-     * @return An instance on this class
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
      */
-    public static States getInstance()
+    public CertGenerationStatesEnum getStartState()
     {
-        return instance;
+        return START_STATE;
     }
 }

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectGrammar.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;
@@ -171,10 +170,9 @@ public final class GracefulDisconnectGra
     private GracefulDisconnectGrammar()
     {
         setName( GracefulDisconnectGrammar.class.getName() );
-        setStatesEnum( GracefulDisconnectStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[GracefulDisconnectStatesEnum.LAST_GRACEFUL_DISCONNECT_STATE][256];
+        super.transitions = new GrammarTransition[GracefulDisconnectStatesEnum.LAST_GRACEFUL_DISCONNECT_STATE.getState()][256];
 
         /**
          * Transition from init state to graceful disconnect
@@ -183,8 +181,8 @@ public final class GracefulDisconnectGra
          * 
          * Creates the GracefulDisconnect object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE,
+        super.transitions[GracefulDisconnectStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.INIT_GRAMMAR_STATE,
                                     GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(),
                 new GrammarAction(
@@ -208,7 +206,7 @@ public final class GracefulDisconnectGra
          *     
          * Set the time offline value into the GracefulDisconnect object.    
          */
-        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
                                     GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE, 
                                     UniversalTag.INTEGER.getValue(), 
@@ -224,7 +222,7 @@ public final class GracefulDisconnectGra
          *     
          * Set the delay value into the GracefulDisconnect object.    
          */
-        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE]
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE.getState()]
                          [GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
                                     GracefulDisconnectStatesEnum.DELAY_STATE, 
@@ -242,7 +240,7 @@ public final class GracefulDisconnectGra
          *     
          * Get some replicated contexts. Nothing to do    
          */
-        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_SEQUENCE_STATE,
                                     GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
                                     UniversalTag.SEQUENCE.getValue(), null );
@@ -257,7 +255,7 @@ public final class GracefulDisconnectGra
          *     
          * Set the delay value into the GracefulDisconnect object.    
          */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE.getState()][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE,
                                     GracefulDisconnectStatesEnum.DELAY_STATE, 
                                     GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG,
@@ -274,7 +272,7 @@ public final class GracefulDisconnectGra
          *     
          * Get some replicated contexts. Nothing to do    
          */
-        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.TIME_OFFLINE_STATE,
                                     GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
                                     UniversalTag.SEQUENCE.getValue(), null );
@@ -290,7 +288,7 @@ public final class GracefulDisconnectGra
          *     
          * Get some replicated contexts. Nothing to do    
          */
-        super.transitions[GracefulDisconnectStatesEnum.DELAY_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.DELAY_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.DELAY_STATE,
                                     GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), null );
@@ -306,7 +304,7 @@ public final class GracefulDisconnectGra
          *     
          * Stores the referral
          */
-        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.REPLICATED_CONTEXTS_STATE,
                                     GracefulDisconnectStatesEnum.REFERRAL_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -323,7 +321,7 @@ public final class GracefulDisconnectGra
          *     
          * Stores the referral
          */
-        super.transitions[GracefulDisconnectStatesEnum.REFERRAL_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[GracefulDisconnectStatesEnum.REFERRAL_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( GracefulDisconnectStatesEnum.REFERRAL_STATE,
                                     GracefulDisconnectStatesEnum.REFERRAL_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,78 +32,68 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class GracefulDisconnectStatesEnum implements States
+public enum GracefulDisconnectStatesEnum 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),
+
     // =========================================================================
     // GracefulDisconnect grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence */
-    public static final int GRACEFUL_DISCONNECT_SEQUENCE_STATE = 1;
+    GRACEFUL_DISCONNECT_SEQUENCE_STATE(1),
 
     /** Time offline */
-    public static final int TIME_OFFLINE_STATE = 2;
+    TIME_OFFLINE_STATE(2),
 
     /** Delay */
-    public static final int DELAY_STATE = 3;
+    DELAY_STATE(3),
 
     /** Replicated contexts */
-    public static final int REPLICATED_CONTEXTS_STATE = 4;
+    REPLICATED_CONTEXTS_STATE(4),
 
     /** Referral */
-    public static final int REFERRAL_STATE = 5;
+    REFERRAL_STATE(5),
 
     /** terminal state */
-    public static final int LAST_GRACEFUL_DISCONNECT_STATE = 6;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] GRACEFUL_DISCONNECT_STRING = new String[]
-        { 
-        "START_STATE", 
-        "GRACEFUL_DISCONNECT_SEQUENCE_STATE",
-        "TIME_OFFLINE_STATE", 
-        "DELAY_STATE", 
-        "REPLICATED_CONTEXTS_STATE",
-        "REFERRAL_STATE"
-        };
-
-    /** The instance */
-    private static GracefulDisconnectStatesEnum instance = new GracefulDisconnectStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_GRACEFUL_DISCONNECT_STATE(6);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of GracefulDisconnectStatesEnum.
+     *
+     * @param state
      */
-    private GracefulDisconnectStatesEnum()
+    private GracefulDisconnectStatesEnum(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
      * 
@@ -141,6 +131,24 @@ public final class GracefulDisconnectSta
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "GRACEFUL_DISCONNECT_END_STATE" : GRACEFUL_DISCONNECT_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "GRACEFUL_DISCONNECT_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public GracefulDisconnectStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownGrammar.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;
@@ -33,6 +32,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.util.IntegerDecoderException;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.extended.operations.GracefulActionConstants;
+import org.apache.directory.shared.ldap.codec.extended.operations.gracefulDisconnect.GracefulDisconnectStatesEnum;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -70,10 +70,9 @@ public final class GracefulShutdownGramm
     private GracefulShutdownGrammar()
     {
         setName( GracefulShutdownGrammar.class.getName() );
-        setStatesEnum( GracefulShutdownStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[GracefulShutdownStatesEnum.LAST_GRACEFUL_SHUTDOWN_STATE][256];
+        super.transitions = new GrammarTransition[GracefulShutdownStatesEnum.LAST_GRACEFUL_SHUTDOWN_STATE.getState()][256];
 
         /**
          * Transition from init state to graceful shutdown
@@ -83,8 +82,8 @@ public final class GracefulShutdownGramm
          *     
          * Creates the GracefulShutdown object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[GracefulShutdownStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
+            new GrammarTransition( GracefulDisconnectStatesEnum.INIT_GRAMMAR_STATE, 
                 GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, 
                 UniversalTag.SEQUENCE.getValue(),
                 new GrammarAction( "Init GracefulShutdown" )
@@ -108,7 +107,7 @@ public final class GracefulShutdownGramm
          * Set the time offline value into the GracefulShutdown
          * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, 
                                     GracefulShutdownStatesEnum.TIME_OFFLINE_STATE, 
                                     UniversalTag.INTEGER.getValue(), 
@@ -150,7 +149,7 @@ public final class GracefulShutdownGramm
          * Set the delay value into the GracefulShutdown
          * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_STATE][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
+        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_STATE.getState()][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
             new GrammarTransition( GracefulShutdownStatesEnum.TIME_OFFLINE_STATE, 
                                     GracefulShutdownStatesEnum.DELAY_STATE, 
                                     GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG, 
@@ -193,7 +192,7 @@ public final class GracefulShutdownGramm
          * Set the delay value into the GracefulShutdown
          * object.
          */
-        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE]
+        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE.getState()]
                          [GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] = 
             new GrammarTransition( GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE, 
                                     GracefulShutdownStatesEnum.DELAY_STATE, 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,71 +32,63 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class GracefulShutdownStatesEnum implements States
+public enum GracefulShutdownStatesEnum 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),
+
     // =========================================================================
     // GracefulShutdown grammar states
     // =========================================================================
 
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence */
-    public static final int GRACEFUL_SHUTDOWN_SEQUENCE_STATE = 1;
+    GRACEFUL_SHUTDOWN_SEQUENCE_STATE(1),
 
     /** Time offline */
-    public static final int TIME_OFFLINE_STATE = 2;
+    TIME_OFFLINE_STATE(2),
 
     /** Delay */
-    public static final int DELAY_STATE = 3;
+    DELAY_STATE(3),
 
     /** terminal state */
-    public static final int LAST_GRACEFUL_SHUTDOWN_STATE = 4;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] GRACEFUL_SHUTDOWN_STRING = new String[]
-        { 
-        "START_STATE",
-        "GRACEFUL_SHUTDOWN_SEQUENCE_STATE", 
-        "TIME_OFFLINE_STATE", 
-        "DELAY_STATE" 
-        };
-
-    /** The instance */
-    private static GracefulShutdownStatesEnum instance = new GracefulShutdownStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_GRACEFUL_SHUTDOWN_STATE(4);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of GracefulShutdownStatesEnum.
+     *
+     * @param state
      */
-    private GracefulShutdownStatesEnum()
+    GracefulShutdownStatesEnum(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
      * 
@@ -134,6 +126,24 @@ public final class GracefulShutdownState
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "GRACEFUL_SHUTDOWN_END_STATE" : GRACEFUL_SHUTDOWN_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "GRACEFUL_SHUTDOWN_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public GracefulShutdownStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureContainer.java Fri Oct 29 02:26:02 2010
@@ -46,7 +46,7 @@ public class StoredProcedureContainer ex
         super();
         stateStack = new int[1];
         grammar = StoredProcedureGrammar.getInstance();
-        states = StoredProcedureStatesEnum.getInstance();
+        setTransition( StoredProcedureStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureGrammar.java Fri Oct 29 02:26:02 2010
@@ -61,10 +61,9 @@ public final class StoredProcedureGramma
     private StoredProcedureGrammar()
     {
         setName( StoredProcedureGrammar.class.getName() );
-        setStatesEnum( StoredProcedureStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[StoredProcedureStatesEnum.LAST_STORED_PROCEDURE_STATE][256];
+        super.transitions = new GrammarTransition[StoredProcedureStatesEnum.LAST_STORED_PROCEDURE_STATE.getState()][256];
 
         //============================================================================================
         // StoredProcedure Message
@@ -72,7 +71,7 @@ public final class StoredProcedureGramma
         // StoredProcedure ::= SEQUENCE {
         //   ...
         // Nothing to do.
-        super.transitions[StoredProcedureStatesEnum.START_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.START_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.START_STATE, 
                                     StoredProcedureStatesEnum.STORED_PROCEDURE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), 
@@ -82,7 +81,7 @@ public final class StoredProcedureGramma
         //    ...
         //
         // Creates the storeProcedure and stores the language
-        super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.STORED_PROCEDURE_STATE, 
                                     StoredProcedureStatesEnum.LANGUAGE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -125,7 +124,7 @@ public final class StoredProcedureGramma
         //    procedure OCTETSTRING, (Value)
         //    ...
         // Stores the procedure.
-        super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.LANGUAGE_STATE, 
                                     StoredProcedureStatesEnum.PROCEDURE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -167,7 +166,7 @@ public final class StoredProcedureGramma
         //    ...
         // The list of parameters will be created with the first parameter.
         // We can have an empty list of parameters, so the PDU can be empty
-        super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.PROCEDURE_STATE, 
                                     StoredProcedureStatesEnum.PARAMETERS_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), 
@@ -184,7 +183,7 @@ public final class StoredProcedureGramma
         // parameter SEQUENCE OF { (Value)
         //    ...
         // Nothing to do. 
-        super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.PARAMETERS_STATE, 
                                     StoredProcedureStatesEnum.PARAMETER_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), 
@@ -195,7 +194,7 @@ public final class StoredProcedureGramma
         //    ...
         //
         // We can create a parameter, and store its type
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_STATE, 
                                     StoredProcedureStatesEnum.PARAMETER_TYPE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -241,7 +240,7 @@ public final class StoredProcedureGramma
         //    value OCTETSTRING (Tag)
         // }
         // Store the parameter value
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE, 
                                     StoredProcedureStatesEnum.PARAMETER_VALUE_STATE, 
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -295,7 +294,7 @@ public final class StoredProcedureGramma
         // Parameters ::= SEQUENCE OF Parameter
         // 
         // Loop on next parameter
-        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_VALUE_STATE, 
                                     StoredProcedureStatesEnum.PARAMETER_STATE, 
                                     UniversalTag.SEQUENCE.getValue(),

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,88 +32,79 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class StoredProcedureStatesEnum implements States
+public enum StoredProcedureStatesEnum 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),
+
     //=========================================================================
     // StoredProcedure
     //=========================================================================
     /** starting state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** StoredProcedure */
-    public static final int STORED_PROCEDURE_STATE = 1;
+    STORED_PROCEDURE_STATE(1),
 
     // Language ---------------------------------------------------------------
     /** Language */
-    public static final int LANGUAGE_STATE = 2;
+    LANGUAGE_STATE(2),
 
     // Procedure --------------------------------------------------------------
     /** Procedure */
-    public static final int PROCEDURE_STATE = 3;
+    PROCEDURE_STATE(3),
 
     // Parameters -------------------------------------------------------------
     /** Parameters */
-    public static final int PARAMETERS_STATE = 4;
+    PARAMETERS_STATE(4),
 
     // Parameter --------------------------------------------------------------
     /** Parameter */
-    public static final int PARAMETER_STATE = 5;
+    PARAMETER_STATE(5),
 
     // Parameter type ---------------------------------------------------------
     /** Parameter type */
-    public static final int PARAMETER_TYPE_STATE = 6;
+    PARAMETER_TYPE_STATE(6),
 
     // Parameters value -------------------------------------------------------
     /** Parameter value */
-    public static final int PARAMETER_VALUE_STATE = 7;
+    PARAMETER_VALUE_STATE(7),
 
     /** Last Stored Procedure */
-    public static final int LAST_STORED_PROCEDURE_STATE = 8;
-
-    //=========================================================================
-    // States debug strings 
-    //=========================================================================
-    /** A string representation of all the states */
-    private static final String[] STORED_PROCEDURE_STRING = new String[]
-        { 
-        "START_STATE", 
-        "STORED_PROCEDURE_STATE", 
-        "LANGUAGE_STATE", 
-        "PROCEDURE_STATE", 
-        "PARAMETERS_STATE", 
-        "PARAMETER_TYPE_STATE",
-        "PARAMETER_VALUE_STATE" 
-        };
-
-    /** The instance */
-    private static StoredProcedureStatesEnum instance = new StoredProcedureStatesEnum();
-
-
-    //~ Constructors -------------------------------------------------------------------------------
+    LAST_STORED_PROCEDURE_STATE(8);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of StoredProcedureStatesEnum.
      *
+     * @param state
      */
-    private StoredProcedureStatesEnum()
+    StoredProcedureStatesEnum(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
      * @param grammar The grammar code
@@ -151,6 +142,24 @@ public final class StoredProcedureStates
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "STORED_PROCEDURE_END_STATE" : STORED_PROCEDURE_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "STORED_PROCEDURE_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public StoredProcedureStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java Fri Oct 29 02:26:02 2010
@@ -65,10 +65,9 @@ public final class EntryChangeControlGra
     private EntryChangeControlGrammar()
     {
         setName( EntryChangeControlGrammar.class.getName() );
-        setStatesEnum( EntryChangeControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[EntryChangeControlStatesEnum.LAST_EC_STATE][256];
+        super.transitions = new GrammarTransition[EntryChangeControlStatesEnum.LAST_EC_STATE.getState()][256];
 
         // ============================================================================================
         // Transition from start state to Entry Change sequence
@@ -77,7 +76,7 @@ public final class EntryChangeControlGra
         //     ...
         //
         // Initialization of the structure
-        super.transitions[EntryChangeControlStatesEnum.START_STATE][UniversalTag.SEQUENCE.getValue()] = 
+        super.transitions[EntryChangeControlStatesEnum.START_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
             new GrammarTransition( EntryChangeControlStatesEnum.START_STATE, 
                                     EntryChangeControlStatesEnum.EC_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), null );
@@ -90,7 +89,7 @@ public final class EntryChangeControlGra
         //     ...
         //
         // Evaluates the changeType
-        super.transitions[EntryChangeControlStatesEnum.EC_SEQUENCE_STATE][UniversalTag.ENUMERATED.getValue()] = 
+        super.transitions[EntryChangeControlStatesEnum.EC_SEQUENCE_STATE.getState()][UniversalTag.ENUMERATED.getValue()] = 
             new GrammarTransition( EntryChangeControlStatesEnum.EC_SEQUENCE_STATE,
                                     EntryChangeControlStatesEnum.CHANGE_TYPE_STATE, 
                                     UniversalTag.ENUMERATED.getValue(),
@@ -149,7 +148,7 @@ public final class EntryChangeControlGra
         //
         // Set the previousDN into the structure. We first check that it's a
         // valid DN
-        super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( EntryChangeControlStatesEnum.CHANGE_TYPE_STATE, 
                                     EntryChangeControlStatesEnum.PREVIOUS_DN_STATE,
                                     UniversalTag.OCTET_STRING.getValue(),
@@ -234,7 +233,7 @@ public final class EntryChangeControlGra
         // }
         //
         // Set the changeNumber into the structure
-        super.transitions[EntryChangeControlStatesEnum.PREVIOUS_DN_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[EntryChangeControlStatesEnum.PREVIOUS_DN_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( EntryChangeControlStatesEnum.PREVIOUS_DN_STATE, 
                                     EntryChangeControlStatesEnum.CHANGE_NUMBER_STATE, 
                                     UniversalTag.INTEGER.getValue(),
@@ -249,7 +248,7 @@ public final class EntryChangeControlGra
         // }
         //
         // Set the changeNumber into the structure
-        super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[EntryChangeControlStatesEnum.CHANGE_TYPE_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( EntryChangeControlStatesEnum.CHANGE_TYPE_STATE, 
                                     EntryChangeControlStatesEnum.CHANGE_NUMBER_STATE, 
                                     UniversalTag.INTEGER.getValue(),

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,75 +32,66 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class EntryChangeControlStatesEnum implements States
+public enum EntryChangeControlStatesEnum 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),
+
     // =========================================================================
     // Entry change control grammar states
     // =========================================================================
 
     /** Sequence Tag */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence */
-    public static final int EC_SEQUENCE_STATE = 1;
+    EC_SEQUENCE_STATE(1),
 
     /** changeType */
-    public static final int CHANGE_TYPE_STATE = 2;
+    CHANGE_TYPE_STATE(2),
 
     /** previousDN */
-    public static final int PREVIOUS_DN_STATE = 3;
+    PREVIOUS_DN_STATE(3),
 
     /** changeNumber */
-    public static final int CHANGE_NUMBER_STATE = 4;
+    CHANGE_NUMBER_STATE(4),
 
     /** terminal state */
-    public static final int LAST_EC_STATE = 5;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] E_C_STRING = new String[]
-        { 
-        "START_STATE",
-        "EC_SEQUENCE_STATE", 
-        "CHANGE_TYPE_STATE",
-        "PREVIOUS_DN_STATE", 
-        "CHANGE_NUMBER_STATE" 
-        };
-
-    /** The instance */
-    private static EntryChangeControlStatesEnum instance = new EntryChangeControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_EC_STATE(5);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of EntryChangeControlStatesEnum.
+     *
+     * @param state
      */
-    private EntryChangeControlStatesEnum()
+    EntryChangeControlStatesEnum(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
      * 
@@ -138,6 +129,24 @@ public final class EntryChangeControlSta
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "EC_END_STATE" : E_C_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "EC_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public EntryChangeControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlGrammar.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;
@@ -68,10 +67,9 @@ public final class PagedResultsControlGr
     private PagedResultsControlGrammar()
     {
         setName( PagedResultsControlGrammar.class.getName() );
-        setStatesEnum( PagedResultsControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[PagedResultsControlStatesEnum.LAST_PAGED_SEARCH_STATE][256];
+        super.transitions = new GrammarTransition[PagedResultsControlStatesEnum.LAST_PAGED_SEARCH_STATE.getState()][256];
 
         /** 
          * Transition from initial state to PagedSearch sequence
@@ -80,8 +78,8 @@ public final class PagedResultsControlGr
          *     
          * Nothing to do
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[PagedResultsControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()] = 
+            new GrammarTransition( PagedResultsControlStatesEnum.INIT_GRAMMAR_STATE, 
                                     PagedResultsControlStatesEnum.PAGED_SEARCH_SEQUENCE_STATE, 
                                     UniversalTag.SEQUENCE.getValue(), null );
 
@@ -95,7 +93,7 @@ public final class PagedResultsControlGr
          *     
          * Stores the size value
          */
-        super.transitions[PagedResultsControlStatesEnum.PAGED_SEARCH_SEQUENCE_STATE][UniversalTag.INTEGER.getValue()] = 
+        super.transitions[PagedResultsControlStatesEnum.PAGED_SEARCH_SEQUENCE_STATE.getState()][UniversalTag.INTEGER.getValue()] = 
             new GrammarTransition( PagedResultsControlStatesEnum.PAGED_SEARCH_SEQUENCE_STATE, 
                 PagedResultsControlStatesEnum.SIZE_STATE, 
                 UniversalTag.INTEGER.getValue(),
@@ -143,7 +141,7 @@ public final class PagedResultsControlGr
          *     
          * Stores the cookie flag
          */
-        super.transitions[PagedResultsControlStatesEnum.SIZE_STATE][UniversalTag.OCTET_STRING.getValue()] = 
+        super.transitions[PagedResultsControlStatesEnum.SIZE_STATE.getState()][UniversalTag.OCTET_STRING.getValue()] = 
             new GrammarTransition( PagedResultsControlStatesEnum.SIZE_STATE,
                                     PagedResultsControlStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
                 new GrammarAction( "Set PagedSearchControl cookie" )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlStatesEnum.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlStatesEnum.java Fri Oct 29 02:26:02 2010
@@ -32,70 +32,62 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class PagedResultsControlStatesEnum implements States
+public enum PagedResultsControlStatesEnum 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),
+
     // =========================================================================
     // Paged search control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence Value */
-    public static final int PAGED_SEARCH_SEQUENCE_STATE = 1;
+    PAGED_SEARCH_SEQUENCE_STATE(1),
 
     /** Size Value */
-    public static final int SIZE_STATE = 2;
+    SIZE_STATE(2),
     
     /** Cookie Value */
-    public static final int COOKIE_STATE = 3;
+    COOKIE_STATE(3),
 
     /** terminal state */
-    public static final int LAST_PAGED_SEARCH_STATE = 4;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] PAGED_SEARCH_STRING = new String[]
-        {
-        "START_STATE", 
-        "PAGED_SEARCH_SEQUENCE_VALUE", 
-        "SIZE_STATE",
-        "COOKIE_STATE" 
-        };
-
-    /** The instance */
-    private static PagedResultsControlStatesEnum instance = new PagedResultsControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_PAGED_SEARCH_STATE(4);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of PagedResultsControlStatesEnum.
+     *
+     * @param state
      */
-    private PagedResultsControlStatesEnum()
+    PagedResultsControlStatesEnum(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
      * 
@@ -133,6 +125,24 @@ public final class PagedResultsControlSt
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "PAGED_SEARCH_END_STATE" : PAGED_SEARCH_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "PAGED_SEARCH_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public PagedResultsControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

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



Mime
View raw message