directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1028591 [1/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
Author: felixk
Date: Fri Oct 29 02:26:02 2010
New Revision: 1028591

URL: http://svn.apache.org/viewvc?rev=1028591&view=rev
Log:
Fix DIRSHARED-64
Transform States and inherited interfaces/implementing classes to enums

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/AbstractContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Container.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/AbstractGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/Grammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/States.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlStates.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncStateValue/SyncStateValueControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/CancelStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/certGeneration/CertGenerationStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulDisconnect/GracefulDisconnectStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/gracefulShutdown/GracefulShutdownStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/storedProcedure/StoredProcedureStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/pagedSearch/PagedResultsControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchControlStatesEnum.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/subentries/SubentriesControlStatesEnum.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/AbstractContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/AbstractContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/AbstractContainer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/AbstractContainer.java
Fri Oct 29 02:26:02 2010
@@ -45,14 +45,11 @@ public abstract class AbstractContainer 
     private TLVStateEnum state;
 
     /** The current transition */
-    private int transition;
+    private Enum<?> transition;
 
     /** The current TLV */
     private TLV tlv;
 
-    /** Store the different states for debug purpose */
-    protected States states;
-
     /** The parent TLV */
     private TLV parentTLV;
 
@@ -140,7 +137,7 @@ public abstract class AbstractContainer 
      * 
      * @return Returns the transition from the previous state to the new state
      */
-    public int getTransition()
+    public Enum<?> getTransition()
     {
         return transition;
     }
@@ -151,7 +148,7 @@ public abstract class AbstractContainer 
      * 
      * @param transition The transition to set
      */
-    public void setTransition( int transition )
+    public void setTransition( Enum<?> transition )
     {
         this.transition = transition;
     }
@@ -180,17 +177,6 @@ public abstract class AbstractContainer 
 
 
     /**
-     * Get the states for this container's grammars
-     * 
-     * @return Returns the states.
-     */
-    public States getStates()
-    {
-        return states;
-    }
-
-
-    /**
      * Get the parent TLV;
      * 
      * @return Returns the parent TLV, if any.
@@ -219,7 +205,7 @@ public abstract class AbstractContainer 
     {
         tlv = null;
         parentTLV = null;
-        transition = 0;
+        transition = ((States)transition).getStartState();
         state = TLVStateEnum.TAG_STATE_START;
     }
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Container.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Container.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Container.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Container.java
Fri Oct 29 02:26:02 2010
@@ -21,7 +21,6 @@ package org.apache.directory.shared.asn1
 
 
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
-import org.apache.directory.shared.asn1.ber.grammar.States;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
 
@@ -78,7 +77,7 @@ public interface Asn1Container
      * 
      * @return Returns the transition from the previous state to the new state
      */
-    int getTransition();
+    Enum<?> getTransition();
 
 
     /**
@@ -86,13 +85,7 @@ public interface Asn1Container
      * 
      * @param transition The transition to set
      */
-    void setTransition( int transition );
-
-
-    /**
-     * @return Returns the states.
-     */
-    States getStates();
+    void setTransition( Enum<?> transition );
 
 
     /**

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/AbstractGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/AbstractGrammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/AbstractGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/AbstractGrammar.java
Fri Oct 29 02:26:02 2010
@@ -52,10 +52,6 @@ public abstract class AbstractGrammar im
     /** The grammar name */
     private String name;
 
-    /** The grammar's states */
-    private States statesEnum;
-
-
     /** Default constructor */
     public AbstractGrammar()
     {
@@ -91,9 +87,9 @@ public abstract class AbstractGrammar im
      * @param tag The current tag
      * @return A valid transition if any, or null.
      */
-    public GrammarTransition getTransition( int state, int tag )
+    public GrammarTransition getTransition( Enum<?> state, int tag )
     {
-        return transitions[state][tag & 0x00FF];
+        return transitions[((States)state).getState()][tag & 0x00FF];
     }
 
 
@@ -107,11 +103,10 @@ public abstract class AbstractGrammar im
     public void executeAction( Asn1Container container ) throws DecoderException
     {
 
-        int currentState = container.getTransition();
+        Enum<?> currentState = container.getTransition();
         Grammar currentGrammar = container.getGrammar();
-
         // We have to deal with the special case of a GRAMMAR_END state
-        if ( currentState == States.END_STATE )
+        if ( ((States)currentState).isEndState() )
         {
             return;
         }
@@ -124,8 +119,7 @@ public abstract class AbstractGrammar im
 
         if ( transition == null )
         {
-            String errorMessage = I18n.err( I18n.ERR_00001_BAD_TRANSITION_FROM_STATE, currentGrammar.getStatesEnum()
-                .getState( currentState ), Asn1StringUtils.dumpByte( tagByte ) );
+            String errorMessage = I18n.err( I18n.ERR_00001_BAD_TRANSITION_FROM_STATE, currentState,
Asn1StringUtils.dumpByte( tagByte ) );
 
             LOG.error( errorMessage );
 
@@ -136,7 +130,7 @@ public abstract class AbstractGrammar im
 
         if ( IS_DEBUG )
         {
-            LOG.debug( transition.toString( currentGrammar.getStatesEnum() ) );
+            LOG.debug( transition.toString() );
         }
 
         if ( transition.hasAction() )
@@ -147,26 +141,4 @@ public abstract class AbstractGrammar im
 
         container.setTransition( transition.getCurrentState() );
     }
-
-
-    /**
-     * Get the states of the current grammar
-     * 
-     * @return Returns the statesEnum.
-     */
-    public States getStatesEnum()
-    {
-        return statesEnum;
-    }
-
-
-    /**
-     * Set the states for this grammar
-     * 
-     * @param statesEnum The statesEnum to set.
-     */
-    public void setStatesEnum( States statesEnum )
-    {
-        this.statesEnum = statesEnum;
-    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/Grammar.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/Grammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/Grammar.java
Fri Oct 29 02:26:02 2010
@@ -25,7 +25,7 @@ import org.apache.directory.shared.asn1.
 
 
 /**
- * The interface which expose common behavior of a Gramar implementer.
+ * The interface which expose common behavior of a Grammar implementer.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -50,14 +50,6 @@ public interface Grammar
 
 
     /**
-     * Get the statesEnum for the current grammar
-     * 
-     * @return The specific States Enum for the current grammar
-     */
-    States getStatesEnum();
-
-
-    /**
      * Set the grammar's name
      * 
      * @param name The grammar name

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
Fri Oct 29 02:26:02 2010
@@ -35,10 +35,10 @@ public class GrammarTransition
     private Action action;
 
     /** The previous state */
-    private int previousState;
+    private Enum<?> previousState;
 
     /** The current state */
-    private int currentState;
+    private Enum<?> currentState;
 
     /** The current tag */
     private int currentTag;
@@ -52,7 +52,7 @@ public class GrammarTransition
      * @param currentTag the current TLV's tag
      * @param action The action to execute. It could be null.
      */
-    public GrammarTransition( int previousState, int currentState, int currentTag, Action
action )
+    public GrammarTransition( Enum<?> previousState, Enum<?> currentState, int
currentTag, Action action )
     {
         this.previousState = previousState;
         this.currentState = currentState;
@@ -84,7 +84,7 @@ public class GrammarTransition
     /**
      * @return The current state
      */
-    public int getCurrentState()
+    public Enum<?> getCurrentState()
     {
         return currentState;
     }
@@ -93,7 +93,7 @@ public class GrammarTransition
     /**
      * @return The previous state
      */
-    public int getPreviousState()
+    public Enum<?> getPreviousState()
     {
         return previousState;
     }
@@ -103,12 +103,12 @@ public class GrammarTransition
      * @param statesEnum Starting state.
      * @return A representation of the transition as a string.
      */
-    public String toString( States statesEnum )
+    public String toString( )
     {
         StringBuilder sb = new StringBuilder();
 
-        sb.append( "Transition from state <" ).append( statesEnum.getState( previousState
) ).append( "> " );
-        sb.append( "to state <" ).append( statesEnum.getState( currentState ) ).append(
">, " );
+        sb.append( "Transition from state <" ).append( previousState ).append( "> "
);
+        sb.append( "to state <" ).append( currentState ).append( ">, " );
         sb.append( "tag <" ).append( Asn1StringUtils.dumpByte( ( byte ) currentTag ) ).append(
">, " );
         sb.append( "action : " );
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/States.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/States.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/States.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/grammar/States.java
Fri Oct 29 02:26:02 2010
@@ -21,47 +21,28 @@ package org.apache.directory.shared.asn1
 
 
 /**
- * This interface is used to store the different states of a grammar. While
- * tracing debugging information, the methods to dump the current state as a
- * string are called.
+ * Interface to get custom function from enum when casting.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public interface States
 {
-    /** The initial state of every grammar */
-    int INIT_GRAMMAR_STATE = 0;
-
-    /** The ending state for every grammars */
-    int GRAMMAR_END = -1;
-
-    /** The END_STATE */
-    int END_STATE = -1;
-
-
-    /** 
-     * Get the current state's name 
+    /**
+     * Get the string representing the state
      * 
-     * @param state the current state
-     * @return the associated name for this state
+     * @param state The state number
+     * @return The String representing the state
      */
-    String getState( int state );
+    public int getState();
 
 
-    /** 
-     * Return the grammar name of a grammar
-     * 
-     * @param grammar the grammar from which we want the name
-     * @return the grammar's name
+    /**
+     * @return True if this is the END_STATE
      */
-    String getGrammarName( Grammar grammar );
-
-
-    /** 
-     * Return the grammar name from a grammar number 
-     * 
-     * @param grammar the grammar number from which we want the name
-     * @return the grammar's name
+    public boolean isEndState();
+    
+    /**
+     * @return The START_STATE of the enum
      */
-    String getGrammarName( int grammar );
+    public Enum<?> getStartState();
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java?rev=1028591&r1=1028590&r2=1028591&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
Fri Oct 29 02:26:02 2010
@@ -102,8 +102,8 @@ public class LdapMessageContainer extend
         super();
         this.stateStack = new int[10];
         this.grammar = LdapMessageGrammar.getInstance();
-        this.states = LdapStatesEnum.getInstance();
         this.binaryAttributeDetector = binaryAttributeDetector;
+        setTransition( LdapStatesEnum.INIT_GRAMMAR_STATE );
     }
 
 



Mime
View raw message