directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r226642 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/DelRequest.java
Date Sun, 31 Jul 2005 13:55:45 GMT
Author: elecharny
Date: Sun Jul 31 06:55:41 2005
New Revision: 226642

URL: http://svn.apache.org/viewcvs?rev=226642&view=rev
Log:
- added the encode method
- fixed the header

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/DelRequest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/DelRequest.java?rev=226642&r1=226641&r2=226642&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/DelRequest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/DelRequest.java
Sun Jul 31 06:55:41 2005
@@ -16,13 +16,18 @@
  */
 package org.apache.asn1.ldap.pojo;
 
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.EncoderException;
 import org.apache.asn1.ber.tlv.Length;
+import org.apache.asn1.ldap.codec.LdapConstants;
 import org.apache.asn1.ldap.codec.primitives.LdapDN;
 
 
 /**
  * A DelRequest Message. Its syntax is :
- *   AbandonRequest ::= [APPLICATION 10] LDAPDN
+ *   DelRequest ::= [APPLICATION 10] LDAPDN
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -82,6 +87,40 @@
         return 1 + Length.getNbBytes( entry.getLength() ) + entry.getLength();
     }
     
+    /**
+     * Compute the DelRequest length
+     * 
+     * DelRequest :
+     * 
+     * 0x4A LL entry
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The DelRequest Tag
+            buffer.put( LdapConstants.DEL_REQUEST_TAG );
+
+            // The entry
+            buffer.put( Length.getBytes( entry.getLength() ) );
+            buffer.put( entry.getData() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        return buffer;
+    }
+
     /**
      * Return a String representing a DelRequest
      * 



Mime
View raw message