directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r161401 - directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java
Date Fri, 15 Apr 2005 05:43:51 GMT
Author: elecharny
Date: Thu Apr 14 22:43:50 2005
New Revision: 161401

URL: http://svn.apache.org/viewcvs?view=rev&rev=161401
Log:
Changed the inheritance of this class, leading to a lot of mermber suppression in this class.

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java?view=diff&r1=161400&r2=161401
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java
Thu Apr 14 22:43:50 2005
@@ -16,12 +16,16 @@
  */
 package org.apache.asn1.ldap.codec;
 
+import org.apache.asn1.ber.AbstractContainer;
 import org.apache.asn1.ber.containers.IAsn1Container;
 import org.apache.asn1.ber.grammar.IGrammar;
-import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ber.grammar.StatesEnum;
+import org.apache.asn1.ldap.codec.grammars.BindRequestGrammar;
+import org.apache.asn1.ldap.codec.grammars.BindResponseGrammar;
+import org.apache.asn1.ldap.codec.grammars.LdapControlGrammar;
+import org.apache.asn1.ldap.codec.grammars.LdapMessageGrammar;
+import org.apache.asn1.ldap.codec.grammars.LdapResultGrammar;
 import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
-import org.apache.asn1.util.pools.LocalPoolManager;
-import org.apache.asn1.util.pools.PoolObject;
 
 
 /**
@@ -31,38 +35,13 @@
  *  
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapMessageContainer extends PoolObject implements IAsn1Container //extends
AbstractLdapContainer
+public class LdapMessageContainer extends AbstractContainer implements IAsn1Container //extends
AbstractLdapContainer
 {
     //~ Instance fields ----------------------------------------------------------------------------
 
-    /** The current state of the decoding */
-    protected int state;
-
-    /** The current transition */
-    protected int transition;
-
-    /** The current TLV */
-    protected TLV tlv;
-
-    /** The pool that is associated with this container */
-    protected LocalPoolManager poolManager;
-
-    /** The grammars that are used.
-     * It's a stack as we can switch grammars */
-    protected IGrammar[] grammarStack;
-    
-    /** All the possible grammars */
-    private IGrammar[] grammars;
-    
-    /** The number of stored grammars */ 
-    private int nbGrammars;
-    
-    /** The current grammar */
-    private int currentGrammar;
-
     /** The ldap message */
     private LdapMessagePOJO ldapMessage;
-
+    
     //~ Constructors -------------------------------------------------------------------------------
 
     /**
@@ -72,10 +51,18 @@
     public LdapMessageContainer()
     {
         super( );
-        currentGrammar = -1;
+        currentGrammar = 0;
         grammars = new IGrammar[10];
         grammarStack = new IGrammar[10];
         nbGrammars = 0;
+
+        grammars[StatesEnum.LDAP_MESSAGE_GRAMMAR] = LdapMessageGrammar.getInstance(); 
+        grammars[StatesEnum.LDAP_CONTROL_GRAMMAR] = LdapControlGrammar.getInstance(); 
+        grammars[StatesEnum.BIND_REQUEST_GRAMMAR] = BindRequestGrammar.getInstance(); 
+        grammars[StatesEnum.LDAP_RESULT_GRAMMAR]  = LdapResultGrammar.getInstance(); 
+        grammars[StatesEnum.BIND_RESPONSE_GRAMMAR] = BindResponseGrammar.getInstance(); 
+
+        grammarStack[currentGrammar] = grammars[StatesEnum.LDAP_MESSAGE_GRAMMAR];
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -89,18 +76,15 @@
         transition = 0;
         ldapMessage.free();
         
-        for (int i = 0; i < nbGrammars; i++ )
-        {
-            grammars[i] = null;
-        }
-        
-        for (int i = 0; i < grammarStack.length; i++ )
+        for (int i = 0; i <= currentGrammar; i++ )
         {
             grammarStack[i] = null;
         }
         
         currentGrammar = 0;
         nbGrammars = 0;
+
+        grammarStack[currentGrammar] = grammars[StatesEnum.LDAP_MESSAGE_GRAMMAR];
         
         super.free();
     }
@@ -123,134 +107,5 @@
     public void setLdapMessage( LdapMessagePOJO ldapMessage )
     {
         this.ldapMessage = ldapMessage;
-    }
-
-    /**
-     * Associate a pool Manager to the container
-     *
-     * @param poolManager The pool manager
-     */
-    public void setPoolManager( LocalPoolManager poolManager )
-    {
-        this.poolManager = poolManager;
-    }
-
-    /**
-     * @return The poolManager associated with this container
-     */
-    public LocalPoolManager getPoolManager()
-    {
-        return poolManager;
-    }
-
-    /**
-     * @return Returns the grammar used to decode a LdapMessage.
-     */
-    public IGrammar getGrammar()
-    {
-        return grammarStack[currentGrammar];
-    }
-
-    /**
-     * Add a IGrammar to use
-     *
-     * @param grammar The grammar to add.
-     */
-    public void addGrammar( IGrammar grammar )
-    {
-        grammars[nbGrammars++] = grammar;
-    }
-
-    /**
-     * Switch to another grammar
-     *
-     * @param grammar The grammar to add.
-     */
-    public void switchGrammar( int grammar )
-    {
-        currentGrammar ++;
-        grammarStack[currentGrammar] = grammars[grammar];
-    }
-
-    /**
-     * restore the previous grammar (the one before a switch has occured)
-     *
-     * @param grammar The grammar to add.
-     */
-    public void restoreGrammar()
-    {
-        grammarStack[currentGrammar] = null;
-        currentGrammar --;
-    }
-
-    /**
-     * Set the current TLV
-     *
-     * @param tlv The current TLV
-     */
-    public void setCurrentTLV( TLV tlv )
-    {
-        this.tlv = tlv;
-    }
-
-    /**
-     * @return Returns the current TLV being decoded
-     */
-    public TLV getCurrentTLV()
-    {
-
-        return this.tlv;
-    }
-
-    /**
-     * @return Returns the current grammar state
-     */
-    public int getState()
-    {
-        return state;
-    }
-
-    /**
-     * Set the new current state
-     *
-     * @param state The new state
-     */
-    public void setState( int state )
-    {
-        this.state = state;
-    }
-
-    /**
-     * @return Returns the transition from the previous state to the new 
-     * state
-     */
-    public int getTransition()
-    {
-        return transition;
-    }
-
-    /**
-     * Update the transition from a state to another
-     *
-     * @param transition The transition to set
-     */
-    public void setTransition( int transition )
-    {
-        this.transition = transition;
-    }
-    
-    /**
-     * @return Returns the currentGrammar.
-     */
-    public int getCurrentGrammar() {
-        return currentGrammar;
-    }
-
-    /**
-     * @return Set the grammar that will be used to start a decoding.
-     */
-    public void setInitGrammar(int grammar) {
-        currentGrammar ++;
-        grammarStack[currentGrammar] = grammars[grammar];
     }
 }



Mime
View raw message