directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1028591 [5/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/search/controls/persistentSearch/PersistentSearchControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlGrammar.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/PersistentSearchControlGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlGrammar.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;
@@ -76,10 +75,9 @@ public final class PersistentSearchContr
     private PersistentSearchControlGrammar()
     {
         setName( PersistentSearchControlGrammar.class.getName() );
-        setStatesEnum( PersistentSearchControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[PersistentSearchControlStatesEnum.LAST_PSEARCH_STATE][256];
+        super.transitions = new GrammarTransition[PersistentSearchControlStatesEnum.LAST_PSEARCH_STATE.getState()][256];
 
         /** 
          * Transition from initial state to Psearch sequence
@@ -88,8 +86,8 @@ public final class PersistentSearchContr
          *     
          * Initialize the persistence search object
          */
-        super.transitions[States.INIT_GRAMMAR_STATE][UniversalTag.SEQUENCE.getValue()] =

-            new GrammarTransition( States.INIT_GRAMMAR_STATE, 
+        super.transitions[PersistentSearchControlStatesEnum.INIT_GRAMMAR_STATE.getState()][UniversalTag.SEQUENCE.getValue()]
= 
+            new GrammarTransition( PersistentSearchControlStatesEnum.INIT_GRAMMAR_STATE,

                                     PersistentSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE,

                                     UniversalTag.SEQUENCE.getValue(), null );
 
@@ -102,7 +100,7 @@ public final class PersistentSearchContr
          *     
          * Stores the change types value
          */
-        super.transitions[PersistentSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE][UniversalTag.INTEGER.getValue()]
= 
+        super.transitions[PersistentSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE.getState()][UniversalTag.INTEGER.getValue()]
= 
             new GrammarTransition( PersistentSearchControlStatesEnum.PSEARCH_SEQUENCE_STATE,

                 PersistentSearchControlStatesEnum.CHANGE_TYPES_STATE, 
                 UniversalTag.INTEGER.getValue(),
@@ -145,7 +143,7 @@ public final class PersistentSearchContr
          *     
          * Stores the change only flag
          */
-        super.transitions[PersistentSearchControlStatesEnum.CHANGE_TYPES_STATE][UniversalTag.BOOLEAN.getValue()]
= 
+        super.transitions[PersistentSearchControlStatesEnum.CHANGE_TYPES_STATE.getState()][UniversalTag.BOOLEAN.getValue()]
= 
             new GrammarTransition( PersistentSearchControlStatesEnum.CHANGE_TYPES_STATE,
                                     PersistentSearchControlStatesEnum.CHANGES_ONLY_STATE,
UniversalTag.BOOLEAN.getValue(),
                 new GrammarAction( "Set PSearchControl changesOnly" )
@@ -184,7 +182,7 @@ public final class PersistentSearchContr
          *     
          * Stores the return ECs flag 
          */
-        super.transitions[PersistentSearchControlStatesEnum.CHANGES_ONLY_STATE][UniversalTag.BOOLEAN.getValue()]
= 
+        super.transitions[PersistentSearchControlStatesEnum.CHANGES_ONLY_STATE.getState()][UniversalTag.BOOLEAN.getValue()]
= 
             new GrammarTransition( PersistentSearchControlStatesEnum.CHANGES_ONLY_STATE,

                                     PersistentSearchControlStatesEnum.RETURN_ECS_STATE, UniversalTag.BOOLEAN.getValue(),
                 new GrammarAction( "Set PSearchControl returnECs" )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlStatesEnum.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/PersistentSearchControlStatesEnum.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlStatesEnum.java
Fri Oct 29 02:26:02 2010
@@ -32,73 +32,65 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class PersistentSearchControlStatesEnum implements States
+public enum PersistentSearchControlStatesEnum 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),
+
     // =========================================================================
     // Persistent search control grammar states
     // =========================================================================
     /** Initial state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Sequence Value */
-    public static final int PSEARCH_SEQUENCE_STATE = 1;
+    PSEARCH_SEQUENCE_STATE(1),
 
     /** changeTypes Value */
-    public static final int CHANGE_TYPES_STATE = 2;
+    CHANGE_TYPES_STATE(2),
     
     /** changesOnly Value */
-    public static final int CHANGES_ONLY_STATE = 3;
+    CHANGES_ONLY_STATE(3),
 
     /** returnECs Value */
-    public static final int RETURN_ECS_STATE = 4;
+    RETURN_ECS_STATE(4),
 
     /** terminal state */
-    public static final int LAST_PSEARCH_STATE = 5;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] PSEARCH_STRING = new String[]
-        { 
-        "START_STATE", 
-        "PSEARCH_SEQUENCE_VALUE", 
-        "CHANGE_TYPES_STATE",
-        "CHANGES_ONLY_STATE", 
-        "RETURN_ECS_STATE" 
-        };
-
-    /** The instance */
-    private static PersistentSearchControlStatesEnum instance = new PersistentSearchControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_PSEARCH_STATE(5);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of PersistentSearchControlStatesEnum.
+     *
+     * @param state
      */
-    private PersistentSearchControlStatesEnum()
+    PersistentSearchControlStatesEnum(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 +129,24 @@ public final class PersistentSearchContr
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "PSEARCH_END_STATE" : PSEARCH_STRING[state] );
+        return ( ( state == GRAMMAR_END.getState() ) ? "PSEARCH_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public PersistentSearchControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlGrammar.java
Fri Oct 29 02:26:02 2010
@@ -58,12 +58,11 @@ public final class SubentriesControlGram
     private SubentriesControlGrammar()
     {
         setName( SubentriesControlGrammar.class.getName() );
-        setStatesEnum( SubentriesControlStatesEnum.getInstance() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[SubentriesControlStatesEnum.LAST_SUB_ENTRY_STATE][256];
+        super.transitions = new GrammarTransition[SubentriesControlStatesEnum.LAST_SUB_ENTRY_STATE.getState()][256];
 
-        super.transitions[SubentriesControlStatesEnum.START_STATE][UniversalTag.BOOLEAN.getValue()]
= 
+        super.transitions[SubentriesControlStatesEnum.START_STATE.getState()][UniversalTag.BOOLEAN.getValue()]
= 
             new GrammarTransition( SubentriesControlStatesEnum.START_STATE, 
                                     SubentriesControlStatesEnum.SUB_ENTRY_VISIBILITY_STATE,
UniversalTag.BOOLEAN.getValue(), 
                 new GrammarAction( "SubEntryControl visibility" )

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlStatesEnum.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlStatesEnum.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlStatesEnum.java
Fri Oct 29 02:26:02 2010
@@ -30,62 +30,57 @@ import org.apache.directory.shared.asn1.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SubentriesControlStatesEnum implements States
+public enum SubentriesControlStatesEnum 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),
+
     // =========================================================================
     // Sub entry control grammar states
     // =========================================================================
 
     /** Starting state */
-    public static final int START_STATE = 0;
+    START_STATE(0),
 
     /** Visibility Value */
-    public static final int SUB_ENTRY_VISIBILITY_STATE = 1;
+    SUB_ENTRY_VISIBILITY_STATE(1),
 
     /** terminal state */
-    public static final int LAST_SUB_ENTRY_STATE = 2;
-
-    // =========================================================================
-    // States debug strings
-    // =========================================================================
-    /** A string representation of all the states */
-    private static final String[] SUB_ENTRY_STRING = new String[]
-        {
-            "START_STATE",
-            "SUB_ENTRY_VISIBILITY_STATE"
-        };
-
-    /** The instance */
-    private static SubentriesControlStatesEnum instance = new SubentriesControlStatesEnum();
-
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
+    LAST_SUB_ENTRY_STATE(2);
 
+    private int state;
+    
     /**
-     * This is a private constructor. This class is a singleton
+     * 
+     * Creates a new instance of SubentriesControlStatesEnum.
+     *
+     * @param state
      */
-    private SubentriesControlStatesEnum()
+    SubentriesControlStatesEnum(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
@@ -124,6 +119,24 @@ public final class SubentriesControlStat
      */
     public String getState( int state )
     {
-        return ( ( state == GRAMMAR_END ) ? "SUB_ENTRY_END_STATE" : SUB_ENTRY_STRING[state]
);
+        return ( ( state == GRAMMAR_END.getState() ) ? "SUB_ENTRY_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == END_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public SubentriesControlStatesEnum getStartState()
+    {
+        return START_STATE;
     }
 }



Mime
View raw message