Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 99647 invoked from network); 26 Jul 2005 23:39:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jul 2005 23:39:56 -0000 Received: (qmail 326 invoked by uid 500); 26 Jul 2005 23:39:56 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 285 invoked by uid 500); 26 Jul 2005 23:39:56 -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 272 invoked by uid 99); 26 Jul 2005 23:39:55 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jul 2005 16:39:55 -0700 X-ASF-Spam-Status: No, hits=-9.8 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, 26 Jul 2005 16:39:49 -0700 Received: (qmail 99621 invoked by uid 65534); 26 Jul 2005 23:39:54 -0000 Message-ID: <20050726233954.99614.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r225420 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java Date: Tue, 26 Jul 2005 23:39:54 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.2 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Tue Jul 26 16:39:51 2005 New Revision: 225420 URL: http://svn.apache.org/viewcvs?rev=225420&view=rev Log: - added some missing JavaDoc - added the computeLength() method Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java?rev=225420&r1=225419&r2=225420&view=diff ============================================================================== --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java (original) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchRequest.java Tue Jul 26 16:39:51 2005 @@ -17,13 +17,15 @@ package org.apache.asn1.ldap.pojo; import org.apache.asn1.Asn1Object; +import org.apache.asn1.ber.tlv.Length; +import org.apache.asn1.ber.tlv.Value; import org.apache.asn1.ldap.codec.LdapConstants; import org.apache.asn1.ldap.codec.primitives.LdapDN; import org.apache.asn1.ldap.codec.primitives.LdapString; import org.apache.asn1.ldap.pojo.filters.Filter; import java.util.ArrayList; - +import java.util.Iterator; /** * A SearchRequest ldapObject. It's a sub-class of Asn1Object, and it implements @@ -270,6 +272,82 @@ this.currentFilter = currentFilter; } + /** + * Compute the SearchRequest length + * + * SearchRequest : + * + * 0x63 L1 + * | + * +--> 0x04 L2 baseObject + * +--> 0x0A 0x01 scope + * +--> 0x0A 0x01 derefAliases + * +--> 0x02 0x0(1..4) sizeLimit + * +--> 0x02 0x0(1..4) timeLimit + * +--> 0x01 0x01 typesOnly + * +--> filter.computeLength() + * +--> 0x30 L3 (Attribute description list) + * | + * +--> 0x04 L4-1 Attribute description + * +--> 0x04 L4-2 Attribute description + * +--> ... + * +--> 0x04 L4-i Attribute description + * +--> ... + * +--> 0x04 L4-n Attribute description + * + */ + public int computeLength() + { + int searchRequestLength = 0; + + // The baseObject + searchRequestLength += 1 + Length.getNbBytes( baseObject.getLength() ) + baseObject.getLength(); + + // The scope + searchRequestLength += 1 + 1 + 1; + + // The derefAliases + searchRequestLength += 1 + 1 + 1; + + // The sizeLimit + searchRequestLength += 1 + 1 + Value.getNbBytes(sizeLimit); + + // The timeLimit + searchRequestLength += 1 + 1 + Value.getNbBytes(timeLimit); + + // The typesOnly + searchRequestLength += 1 + 1 + 1; + + // The filter + searchRequestLength += filter.computeLength(); + + // The attributes description list + int attributesLength = 0; + + if ( ( attributes != null ) && ( attributes.size() != 0 ) ) + { + Iterator attributeIterator = attributes.iterator(); + + // Compute the attributes length + while ( attributeIterator.hasNext() ) + { + LdapString attribute = (LdapString)attributeIterator.next(); + + // add the attribute length to the attributes length + attributesLength += 1 + Length.getNbBytes( attribute.getLength() ) + attribute.getLength(); + } + } + + searchRequestLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength; + + // Return the result. + return 1 + Length.getNbBytes( searchRequestLength ) + searchRequestLength; + } + + /** + * + * @return A string that represent the Filter + */ private String buildFilter() { if (filter == null) @@ -288,6 +366,9 @@ return sb.toString(); } + /** + * Return a string the represent a SearchRequest + */ public String toString() { StringBuffer sb = new StringBuffer();