You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/01/03 21:47:28 UTC
svn commit: r365741 -
/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/asn1/pojo/psearch/PSearchControl.java
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;
}
}