You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/08/03 00:27:06 UTC

svn commit: r227096 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapMessage.java

Author: elecharny
Date: Tue Aug  2 15:27:04 2005
New Revision: 227096

URL: http://svn.apache.org/viewcvs?rev=227096&view=rev
Log:
- added the local length used to compute the length
- fixed the length calcaulation
- fixed the encoding of the controls

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapMessage.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapMessage.java?rev=227096&r1=227095&r2=227096&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapMessage.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapMessage.java Tue Aug  2 15:27:04 2005
@@ -48,10 +48,16 @@
     /** The controls */
     private ArrayList controls;
     
+    /** The current control */
+    private transient Control currentControl;
+    
     /** The LdapMessage length */
     private transient int ldapMessageLength;
     
     /** The controls length */
+    private transient int controlsLength;
+    
+    /** The controls sequence length */
     private transient int controlsSequenceLength;
 
     //~ Constructors -------------------------------------------------------------------------------
@@ -79,16 +85,35 @@
     }
 
     /**
+     * Get the current Control Object 
+     *
+     * @return The current Control Object
+     */
+    public Control getCurrentControl()
+    {
+        return currentControl;
+    }
+
+    /**
      * Add a control to the Controls array
      *
      * @param control The Control to add
      */
     public void addControl( Control control )
     {
+        currentControl = control;
         this.controls.add( control );
     }
 
     /**
+     * Init the controls array
+     */
+    public void initControl(  )
+    {
+        controls = new ArrayList();
+    }
+
+    /**
      * Get the message ID
      *
      * @return The message ID
@@ -413,8 +438,6 @@
             }
             
             // Computes the controls length
-            int controlsLength = 0;
-            
             controlsLength = 1 + Length.getNbBytes( controlsSequenceLength ) + controlsSequenceLength; 
                 
             // Now, add the tag and the length of the controls length
@@ -478,10 +501,13 @@
         // Do the same thing for Controls, if any.
         if (controls != null)
         {
+            // Encode the controls
+            bb.put( (byte)LdapConstants.CONTROLS_TAG );
+            bb.put( Length.getBytes( controlsLength ) );
+
             // Encode the control's sequence
-            bb.put( (byte)LdapConstants.CONTROLS_SEQUENCE_TAG );
+            bb.put( UniversalTag.SEQUENCE_TAG );
             bb.put( Length.getBytes( controlsSequenceLength ) );
-            
 
             // Encode each control
             Iterator controlIterator = controls.iterator();
@@ -506,13 +532,13 @@
 
         sb.append( "LdapMessage\n" );
         sb.append( "    message Id : " ).append( messageId ).append( '\n' );
-        sb.append( protocolOp.toString() ).append( '\n' );
+        sb.append( protocolOp.toString() );
 
         if ( controls != null )
         {
 	        for ( int i = 0; i < controls.size(); i++ )
 	        {
-	            sb.append( ( ( Control ) controls.get( i ) ).toString() ).append( '\n' );
+	            sb.append( ( ( Control ) controls.get( i ) ).toString() );
 	        }
         }