Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 77286 invoked from network); 3 Jan 2006 20:47:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Jan 2006 20:47:51 -0000 Received: (qmail 44680 invoked by uid 500); 3 Jan 2006 20:47:50 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44648 invoked by uid 500); 3 Jan 2006 20:47:50 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 44637 invoked by uid 99); 3 Jan 2006 20:47:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jan 2006 12:47:50 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 03 Jan 2006 12:47:49 -0800 Received: (qmail 77133 invoked by uid 65534); 3 Jan 2006 20:47:29 -0000 Message-ID: <20060103204729.77131.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r365741 - /directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java Date: Tue, 03 Jan 2006 20:47:28 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Tue Jan 3 12:47:26 2006 New Revision: 365741 URL: http://svn.apache.org/viewcvs?rev=365741&view=rev Log: added encode method Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java?rev=365741&r1=365740&r2=365741&view=diff ============================================================================== --- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java (original) +++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java Tue Jan 3 12:47:26 2006 @@ -1,10 +1,19 @@ package org.apache.ldap.common.asn1.pojo.psearch; +import java.nio.BufferOverflowException; +import java.nio.ByteBuffer; +import java.util.Iterator; + +import org.apache.asn1.Asn1Object; import org.apache.asn1.ber.tlv.Length; +import org.apache.asn1.ber.tlv.UniversalTag; import org.apache.asn1.ber.tlv.Value; +import org.apache.asn1.codec.EncoderException; +import org.apache.ldap.common.asn1.codec.LdapConstants; +import org.apache.ldap.common.asn1.pojo.Control; -public class PSearchControl +public class PSearchControl extends Asn1Object { /** * If changesOnly is TRUE, the server MUST NOT return any existing @@ -31,6 +40,7 @@ */ private int changeTypes; + private transient int psearchSeqLength; /** * Compute the PSearchControl length @@ -46,7 +56,7 @@ int changesOnlyLength = 1 + 1 + 1; int returnRCsLength = 1 + 1 + 1; - int psearchSeqLength = changeTypesLength + changesOnlyLength + returnRCsLength; + psearchSeqLength = changeTypesLength + changesOnlyLength + returnRCsLength; return 1 + Length.getNbBytes( psearchSeqLength ) + psearchSeqLength; } @@ -85,5 +95,26 @@ public int getChangeTypes() { return changeTypes; + } + + + /** + * Encodes the persistent search control. + * + * @param buffer The encoded sink + * @return A ByteBuffer that contains the encoded PDU + * @throws EncoderException If anything goes wrong. + */ + public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException + { + // Allocate the bytes buffer. + ByteBuffer bb = ByteBuffer.allocate( computeLength() ); + bb.put( UniversalTag.SEQUENCE_TAG ); + bb.put( Length.getBytes( psearchSeqLength ) ); + + Value.encode( bb, changeTypes); + Value.encode( bb, changesOnly ); + Value.encode( bb, returnECs ); + return bb; } }