directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r452497 [7/9] - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/abandon/ main/java/org/apache/directory/shared/ldap/codec/add/ main/java/org/apache/dir...
Date Tue, 03 Oct 2006 13:49:46 GMT
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java Tue Oct  3 06:49:43 2006
@@ -20,13 +20,12 @@
 package org.apache.directory.shared.ldap.codec.modify;
 
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -48,12 +47,28 @@
 
 
 /**
- * A ModifyRequest Message. Its syntax is : ModifyRequest ::= [APPLICATION 6]
- * SEQUENCE { object LDAPDN, modification SEQUENCE OF SEQUENCE { operation
- * ENUMERATED { add (0), delete (1), replace (2) }, modification
- * AttributeTypeAndValues } } AttributeTypeAndValues ::= SEQUENCE { type
- * AttributeDescription, vals SET OF AttributeValue } AttributeValue ::= OCTET
- * STRING
+ * A ModifyRequest Message. 
+ * 
+ * Its syntax is : 
+ * 
+ * ModifyRequest ::= [APPLICATION 6] SEQUENCE { 
+ *     object LDAPDN, 
+ *     modification SEQUENCE OF SEQUENCE { 
+ *         operation ENUMERATED { 
+ *             add (0), 
+ *             delete (1), 
+ *             replace (2) 
+ *         }, 
+ *         modification AttributeTypeAndValues 
+ *     } 
+ * } 
+ * 
+ * AttributeTypeAndValues ::= SEQUENCE {
+ *     type AttributeDescription, 
+ *     vals SET OF AttributeValue 
+ * } 
+ * 
+ * AttributeValue ::= OCTET STRING
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -145,8 +160,7 @@
     /**
      * Add a new modification to the list
      * 
-     * @param operation
-     *            The type of operation (add, delete or replace)
+     * @param operation The type of operation (add, delete or replace)
      */
     public void addModification( int operation )
     {
@@ -162,19 +176,7 @@
     /**
      * Add a new attributeTypeAndValue
      * 
-     * @param type
-     *            The attribute's name
-     */
-    public void addAttributeTypeAndValues( LdapString type )
-    {
-        addAttributeTypeAndValues( type.getString() );
-    }
-
-    /**
-     * Add a new attributeTypeAndValue
-     * 
-     * @param type
-     *            The attribute's name
+     * @param type The attribute's name
      */
     public void addAttributeTypeAndValues( String type )
     {
@@ -206,8 +208,7 @@
     /**
      * Add a new value to the current attribute
      * 
-     * @param value
-     *            The value to add
+     * @param value The value to add
      */
     public void addAttributeValue( Object value )
     {
@@ -238,8 +239,7 @@
     /**
      * Set the modification DN.
      * 
-     * @param object
-     *            The DN to set.
+     * @param object The DN to set.
      */
     public void setObject( LdapDN object )
     {
@@ -261,8 +261,7 @@
     /**
      * Store the current operation
      * 
-     * @param currentOperation
-     *            The currentOperation to set.
+     * @param currentOperation The currentOperation to set.
      */
     public void setCurrentOperation( int currentOperation )
     {
@@ -271,21 +270,49 @@
 
 
     /**
-     * Compute the ModifyRequest length ModifyRequest : 0x66 L1 | +--> 0x04 L2
-     * object +--> 0x30 L3 modifications | +--> 0x30 L4-1 modification sequence | | |
-     * +--> 0x0A 0x01 (0..2) operation | +--> 0x30 L5-1 modification | | | +-->
-     * 0x04 L6-1 type | +--> 0x31 L7-1 vals | | | +--> 0x04 L8-1-1
-     * attributeValue | +--> 0x04 L8-1-2 attributeValue | +--> ... | +--> 0x04
-     * L8-1-i attributeValue | +--> ... | +--> 0x04 L8-1-n attributeValue | +-->
-     * 0x30 L4-2 modification sequence . | . +--> 0x0A 0x01 (0..2) operation .
-     * +--> 0x30 L5-2 modification | +--> 0x04 L6-2 type +--> 0x31 L7-2 vals |
-     * +--> 0x04 L8-2-1 attributeValue +--> 0x04 L8-2-2 attributeValue +--> ...
-     * +--> 0x04 L8-2-i attributeValue +--> ... +--> 0x04 L8-2-n attributeValue
+     * Compute the ModifyRequest length 
+     * 
+     * ModifyRequest :
+     * 
+     * 0x66 L1
+     *  |
+     *  +--> 0x04 L2 object
+     *  +--> 0x30 L3 modifications
+     *        |
+     *        +--> 0x30 L4-1 modification sequence
+     *        |     |
+     *        |     +--> 0x0A 0x01 (0..2) operation
+     *        |     +--> 0x30 L5-1 modification
+     *        |           |
+     *        |           +--> 0x04 L6-1 type
+     *        |           +--> 0x31 L7-1 vals
+     *        |                 |
+     *        |                 +--> 0x04 L8-1-1 attributeValue
+     *        |                 +--> 0x04 L8-1-2 attributeValue
+     *        |                 +--> ...
+     *        |                 +--> 0x04 L8-1-i attributeValue
+     *        |                 +--> ...
+     *        |                 +--> 0x04 L8-1-n attributeValue
+     *        |
+     *        +--> 0x30 L4-2 modification sequence
+     *        .     |
+     *        .     +--> 0x0A 0x01 (0..2) operation
+     *        .     +--> 0x30 L5-2 modification
+     *                    |
+     *                    +--> 0x04 L6-2 type
+     *                    +--> 0x31 L7-2 vals
+     *                          |
+     *                          +--> 0x04 L8-2-1 attributeValue
+     *                          +--> 0x04 L8-2-2 attributeValue
+     *                          +--> ...
+     *                          +--> 0x04 L8-2-i attributeValue
+     *                          +--> ...
+     *                          +--> 0x04 L8-2-n attributeValue
      */
     public int computeLength()
     {
         // Initialized with object
-        modifyRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( object ) ) + LdapDN.getNbBytes( object );
+        modifyRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( object ) ) + LdapDN.getNbBytes( object );
 
         // Modifications
         modificationsLength = 0;
@@ -307,7 +334,7 @@
 
                 // Modification length initialized with the type
                 int typeLength = modification.getAttribute().getID().length();
-                int localModificationLength = 1 + Length.getNbBytes( typeLength ) + typeLength;
+                int localModificationLength = 1 + TLV.getNbBytes( typeLength ) + typeLength;
 
                 try
                 {
@@ -324,17 +351,17 @@
                             if ( value instanceof String )
                             {
                                 int valueLength = StringTools.getBytesUtf8( ( String ) value ).length;
-                                localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+                                localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
                             }
                             else
                             {
-                                localValuesLength += 1 + Length.getNbBytes( ( ( byte[] ) value ).length )
+                                localValuesLength += 1 + TLV.getNbBytes( ( ( byte[] ) value ).length )
                                     + ( ( byte[] ) value ).length;
                             }
                         }
                     }
 
-                    localModificationLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength;
+                    localModificationLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                 }
                 catch ( NamingException ne )
                 {
@@ -342,11 +369,11 @@
                 }
 
                 // Compute the modificationSequenceLength
-                localModificationSequenceLength += 1 + Length.getNbBytes( localModificationLength )
+                localModificationSequenceLength += 1 + TLV.getNbBytes( localModificationLength )
                     + localModificationLength;
 
                 // Add the tag and the length
-                modificationsLength += 1 + Length.getNbBytes( localModificationSequenceLength )
+                modificationsLength += 1 + TLV.getNbBytes( localModificationSequenceLength )
                     + localModificationSequenceLength;
 
                 // Store the arrays of values
@@ -356,23 +383,40 @@
             }
 
             // Add the modifications length to the modificationRequestLength
-            modifyRequestLength += 1 + Length.getNbBytes( modificationsLength ) + modificationsLength;
+            modifyRequestLength += 1 + TLV.getNbBytes( modificationsLength ) + modificationsLength;
         }
 
-        return 1 + Length.getNbBytes( modifyRequestLength ) + modifyRequestLength;
+        return 1 + TLV.getNbBytes( modifyRequestLength ) + modifyRequestLength;
     }
 
 
     /**
-     * Encode the ModifyRequest message to a PDU. AddRequest : 0x66 LL 0x04 LL
-     * object 0x30 LL modifiations 0x30 LL modification sequence 0x0A 0x01
-     * operation 0x30 LL modification 0x04 LL type 0x31 LL vals 0x04 LL
-     * attributeValue ... 0x04 LL attributeValue ... 0x30 LL modification
-     * sequence 0x0A 0x01 operation 0x30 LL modification 0x04 LL type 0x31 LL
-     * vals 0x04 LL attributeValue ... 0x04 LL attributeValue
+     * Encode the ModifyRequest message to a PDU. 
+     * 
+     * ModifyRequest : 
+     * 0x66 LL
+     *   0x04 LL object
+     *   0x30 LL modifiations
+     *     0x30 LL modification sequence
+     *       0x0A 0x01 operation
+     *       0x30 LL modification
+     *         0x04 LL type
+     *         0x31 LL vals
+     *           0x04 LL attributeValue
+     *           ... 
+     *           0x04 LL attributeValue
+     *     ... 
+     *     0x30 LL modification sequence
+     *       0x0A 0x01 operation
+     *       0x30 LL modification
+     *         0x04 LL type
+     *         0x31 LL vals
+     *           0x04 LL attributeValue
+     *           ... 
+     *           0x04 LL attributeValue
+     * 
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -386,14 +430,14 @@
         {
             // The AddRequest Tag
             buffer.put( LdapConstants.MODIFY_REQUEST_TAG );
-            buffer.put( Length.getBytes( modifyRequestLength ) );
+            buffer.put( TLV.getBytes( modifyRequestLength ) );
 
             // The entry
             Value.encode( buffer, LdapDN.getBytes( object ) );
 
             // The modifications sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );
-            buffer.put( Length.getBytes( modificationsLength ) );
+            buffer.put( TLV.getBytes( modificationsLength ) );
 
             // The modifications list
             if ( ( modifications != null ) && ( modifications.size() != 0 ) )
@@ -410,7 +454,7 @@
                     buffer.put( UniversalTag.SEQUENCE_TAG );
                     int localModificationSequenceLength = ( ( Integer ) modificationSequenceLength
                         .get( modificationNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localModificationSequenceLength ) );
+                    buffer.put( TLV.getBytes( localModificationSequenceLength ) );
 
                     // The operation. The value has to be changed, it's not
                     // the same value in DirContext and in RFC 2251.
@@ -437,7 +481,7 @@
                     buffer.put( UniversalTag.SEQUENCE_TAG );
                     int localModificationLength = ( ( Integer ) modificationLength.get( modificationNumber ) )
                         .intValue();
-                    buffer.put( Length.getBytes( localModificationLength ) );
+                    buffer.put( TLV.getBytes( localModificationLength ) );
 
                     // The modification type
                     Value.encode( buffer, modification.getAttribute().getID() );
@@ -445,7 +489,7 @@
                     // The values
                     buffer.put( UniversalTag.SET_TAG );
                     int localValuesLength = ( ( Integer ) valuesLength.get( modificationNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localValuesLength ) );
+                    buffer.put( TLV.getBytes( localValuesLength ) );
 
                     try
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java Tue Oct  3 06:49:43 2006
@@ -23,15 +23,16 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 
 
 /**
- * An ModifyResponse Message. Its syntax is : ModifyResponse ::= [APPLICATION 7]
- * LDAPResult
+ * An ModifyResponse Message. Its syntax is : 
+ * 
+ * ModifyResponse ::= [APPLICATION 7] LDAPResult
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -61,23 +62,28 @@
 
 
     /**
-     * Compute the ModifyResponse length ModifyResponse : 0x67 L1 | +-->
-     * LdapResult L1 = Length(LdapResult) Length(ModifyResponse) = Length(0x67) +
-     * Length(L1) + L1
+     * Compute the ModifyResponse length 
+     * 
+     * ModifyResponse : 
+     * 0x67 L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(ModifyResponse) = Length(0x67) + Length(L1) + L1
      */
     public int computeLength()
     {
         int ldapResponseLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+        return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength;
     }
 
 
     /**
      * Encode the ModifyResponse message to a PDU.
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -91,7 +97,7 @@
         {
             // The tag
             buffer.put( LdapConstants.MODIFY_RESPONSE_TAG );
-            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+            buffer.put( TLV.getBytes( getLdapResponseLength() ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,7 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
@@ -34,9 +34,12 @@
 
 
 /**
- * A ModifyDNRequest Message. Its syntax is : ModifyDNRequest ::= [APPLICATION
- * 12] SEQUENCE { entry LDAPDN, newrdn RelativeLDAPDN, deleteoldrdn BOOLEAN,
- * newSuperior [0] LDAPDN OPTIONAL }
+ * A ModifyDNRequest Message. Its syntax is :
+ * ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+ *                 entry           LDAPDN,
+ *                 newrdn          RelativeLDAPDN,
+ *                 deleteoldrdn    BOOLEAN,
+ *                 newSuperior     [0] LDAPDN OPTIONAL }
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -101,8 +104,7 @@
     /**
      * Set the modification DN.
      * 
-     * @param entry
-     *            The entry to set.
+     * @param entry The entry to set.
      */
     public void setEntry( LdapDN entry )
     {
@@ -124,8 +126,7 @@
     /**
      * Set the flag to delete the old RDN
      * 
-     * @param deleteOldRDN
-     *            The deleteOldRDN to set.
+     * @param deleteOldRDN The deleteOldRDN to set.
      */
     public void setDeleteOldRDN( boolean deleteOldRDN )
     {
@@ -147,8 +148,7 @@
     /**
      * Set the new RDN
      * 
-     * @param newRDN
-     *            The newRDN to set.
+     * @param newRDN The newRDN to set.
      */
     public void setNewRDN( Rdn newRDN )
     {
@@ -170,8 +170,7 @@
     /**
      * Set the new superior
      * 
-     * @param newSuperior
-     *            The newSuperior to set.
+     * @param newSuperior The newSuperior to set.
      */
     public void setNewSuperior( LdapDN newSuperior )
     {
@@ -180,38 +179,54 @@
 
 
     /**
-     * Compute the ModifyDNRequest length ModifyDNRequest : 0x6C L1 | +--> 0x04
-     * L2 entry +--> 0x04 L3 newRDN +--> 0x01 0x01 (true/false) deleteOldRDN (3
-     * bytes) [+--> 0x80 L4 newSuperior ] L2 = Length(0x04) +
-     * Length(Length(entry)) + Length(entry) L3 = Length(0x04) +
-     * Length(Length(newRDN)) + Length(newRDN) L4 = Length(0x80) +
-     * Length(Length(newSuperior)) + Length(newSuperior) L1 = L2 + L3 + 3 [+ L4]
+     * Compute the ModifyDNRequest length
+     * 
+     * ModifyDNRequest :
+     * 
+     * 0x6C L1
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x04 L3 newRDN
+     *  +--> 0x01 0x01 (true/false) deleteOldRDN (3 bytes)
+     * [+--> 0x80 L4 newSuperior ] 
+     * 
+     * L2 = Length(0x04) + Length(Length(entry)) + Length(entry) 
+     * L3 = Length(0x04) + Length(Length(newRDN)) + Length(newRDN) 
+     * L4 = Length(0x80) + Length(Length(newSuperior)) + Length(newSuperior)
+     * L1 = L2 + L3 + 3 [+ L4] 
+     * 
      * Length(ModifyDNRequest) = Length(0x6C) + Length(L1) + L1
      * 
-     * @return DOCUMENT ME!
+     * @return The PDU's length of a ModifyDN Request
      */
     public int computeLength()
     {
         int newRdnlength = StringTools.getBytesUtf8( newRDN.toString() ).length;
-        modifyDNRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ) + 1
-            + Length.getNbBytes( newRdnlength ) + newRdnlength + 1 + 1 + 1; // deleteOldRDN
+        modifyDNRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ) + 1
+            + TLV.getNbBytes( newRdnlength ) + newRdnlength + 1 + 1 + 1; // deleteOldRDN
 
         if ( newSuperior != null )
         {
-            modifyDNRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( newSuperior ) )
+            modifyDNRequestLength += 1 + TLV.getNbBytes( LdapDN.getNbBytes( newSuperior ) )
                 + LdapDN.getNbBytes( newSuperior );
         }
 
-        return 1 + Length.getNbBytes( modifyDNRequestLength ) + modifyDNRequestLength;
+        return 1 + TLV.getNbBytes( modifyDNRequestLength ) + modifyDNRequestLength;
     }
 
 
     /**
-     * Encode the ModifyDNRequest message to a PDU. ModifyDNRequest : 0x6C LL
-     * 0x04 LL entry 0x04 LL newRDN 0x01 0x01 deleteOldRDN [0x80 LL newSuperior]
+     * Encode the ModifyDNRequest message to a PDU. 
+     * 
+     * ModifyDNRequest :
+     * 
+     * 0x6C LL
+     *   0x04 LL entry
+     *   0x04 LL newRDN
+     *   0x01 0x01 deleteOldRDN
+     *   [0x80 LL newSuperior]
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -225,7 +240,7 @@
         {
             // The ModifyDNRequest Tag
             buffer.put( LdapConstants.MODIFY_DN_REQUEST_TAG );
-            buffer.put( Length.getBytes( modifyDNRequestLength ) );
+            buffer.put( TLV.getBytes( modifyDNRequestLength ) );
 
             // The entry
 
@@ -245,7 +260,7 @@
 
                 int newSuperiorLength = LdapDN.getNbBytes( newSuperior );
 
-                buffer.put( Length.getBytes( newSuperiorLength ) );
+                buffer.put( TLV.getBytes( newSuperiorLength ) );
 
                 if ( newSuperiorLength != 0 )
                 {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java Tue Oct  3 06:49:43 2006
@@ -23,15 +23,16 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 
 
 /**
- * An ModifyDNResponse Message. Its syntax is : ModifyDNResponse ::=
- * [APPLICATION 13] LDAPResult
+ * An ModifyDNResponse Message. Its syntax is : 
+ * 
+ * ModifyDNResponse ::= [APPLICATION 13] LDAPResult
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -61,23 +62,28 @@
 
 
     /**
-     * Compute the ModifyDNResponse length ModifyDNResponse : 0x6D L1 | +-->
-     * LdapResult L1 = Length(LdapResult) Length(ModifyDNResponse) =
-     * Length(0x6D) + Length(L1) + L1
+     * Compute the ModifyDNResponse length 
+     * 
+     * ModifyDNResponse : 
+     * 0x6D L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(ModifyDNResponse) = Length(0x6D) + Length(L1) + L1
      */
     public int computeLength()
     {
         int ldapResponseLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+        return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength;
     }
 
 
     /**
      * Encode the ModifyDNResponse message to a PDU.
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -91,7 +97,7 @@
         {
             // The tag
             buffer.put( LdapConstants.MODIFY_DN_RESPONSE_TAG );
-            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+            buffer.put( TLV.getBytes( getLdapResponseLength() ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java Tue Oct  3 06:49:43 2006
@@ -24,7 +24,7 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 
@@ -61,24 +61,30 @@
 
 
     /**
-     * Compute the AndFilter length AndFilter : 0xA0 L1 super.computeLength()
+     * Compute the AndFilter length 
+     * 
+     * AndFilter : 
+     * 0xA0 L1 super.computeLength()
+     * 
      * Length(AndFilter) = Length(0xA0) + Length(super.computeLength()) +
-     * super.computeLength()
+     *          super.computeLength()
      */
     public int computeLength()
     {
         filtersLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+        return 1 + TLV.getNbBytes( filtersLength ) + filtersLength;
     }
 
 
     /**
-     * Encode the AndFilter message to a PDU. AndFilter : 0xA0 LL
-     * filter.encode() ... filter.encode()
+     * Encode the AndFilter message to a PDU. 
+     * 
+     * AndFilter : 
+     * 0xA0 LL
+     *  filter.encode() ... filter.encode()
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -92,7 +98,7 @@
         {
             // The AndFilter Tag
             buffer.put( ( byte ) LdapConstants.AND_FILTER_TAG );
-            buffer.put( Length.getBytes( filtersLength ) );
+            buffer.put( TLV.getBytes( filtersLength ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,7 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
@@ -57,10 +57,9 @@
     /**
      * The constructor.
      * 
-     * @param filterType
-     *            DOCUMENT ME!
+     * @param filterType The filter type
      */
-    public AttributeValueAssertionFilter(int filterType)
+    public AttributeValueAssertionFilter( int filterType )
     {
         this.filterType = filterType;
     }
@@ -83,8 +82,7 @@
     /**
      * Set the assertion
      * 
-     * @param assertion
-     *            The assertion to set.
+     * @param assertion The assertion to set.
      */
     public void setAssertion( AttributeValueAssertion assertion )
     {
@@ -106,8 +104,7 @@
     /**
      * Set the filter type
      * 
-     * @param filterType
-     *            The filterType to set.
+     * @param filterType The filterType to set.
      */
     public void setFilterType( int filterType )
     {
@@ -116,18 +113,31 @@
 
 
     /**
-     * Compute the AttributeValueFilter length AttributeValueFilter : 0xA(3, 5,
-     * 6, 8) L1 | +--> 0x04 L2 attributeDesc +--> 0x04 L3 assertionValue L2 =
-     * Length(attributeDesc) L3 = Length(assertionValue) L1 = 1 + Length(L2) +
-     * L2 + 1 + Length(L3) + L3 Length(AttributeValueFilter) = Length(0xA?) +
-     * Length(L1) + 1 + Length(L2) + L2 + 1 + Length(L3) + L3
+     * Compute the AttributeValueFilter length
+     * 
+     * AttributeValueFilter :
+     * 
+     * 0xA(3, 5, 6, 8) L1
+     *  |
+     *  +--> 0x04 L2 attributeDesc
+     *  +--> 0x04 L3 assertionValue
+     *  
+     * 
+     * L2 = Length(attributeDesc)
+     * L3 = Length(assertionValue)
+     * L1 = 1 + Length(L2) + L2 
+     *      + 1 + Length(L3) + L3
+     * 
+     * Length(AttributeValueFilter) = Length(0xA?) + Length(L1)
+     *                                + 1 + Length(L2) + L2 
+     *                                + 1 + Length(L3) + L3 
      */
     public int computeLength()
     {
         avaLength = 0;
         int attributeDescLength = assertion.getAttributeDesc().length();
 
-        avaLength = 1 + Length.getNbBytes( attributeDescLength ) + attributeDescLength;
+        avaLength = 1 + TLV.getNbBytes( attributeDescLength ) + attributeDescLength;
 
         Object assertionValue = assertion.getAssertionValue();
 
@@ -142,20 +152,27 @@
             assertionValueLength = ( ( byte[] ) assertionValue ).length;
         }
 
-        avaLength += 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength;
+        avaLength += 1 + TLV.getNbBytes( assertionValueLength ) + assertionValueLength;
 
-        return 1 + Length.getNbBytes( avaLength ) + avaLength;
+        return 1 + TLV.getNbBytes( avaLength ) + avaLength;
     }
 
 
     /**
-     * Encode the AttributeValueAssertion Filters to a PDU. The following
-     * filters are to be encoded : - equality match - greater or equal - less or
-     * equal - approx match AttributeValueAssertion filters : 0xA[3, 5, 6, 8] LL
-     * 0x04 LL attributeDesc 0x04 LL assertionValue
+     * Encode the AttributeValueAssertion Filters to a PDU. The 
+     * following filters are to be encoded :
+     *  - equality match 
+     *  - greater or equal
+     *  - less or equal
+     *  - approx match 
+     * 
+     * AttributeValueAssertion filters :
+     * 
+     * 0xA[3, 5, 6, 8] LL 
+     * 0x04 LL attributeDesc
+     * 0x04 LL assertionValue
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -187,7 +204,7 @@
                     break;
             }
 
-            buffer.put( Length.getBytes( avaLength ) );
+            buffer.put( TLV.getBytes( avaLength ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java Tue Oct  3 06:49:43 2006
@@ -63,8 +63,7 @@
     /**
      * Add a new Filter to the list.
      * 
-     * @param filter
-     *            The filter to add
+     * @param filter The filter to add
      */
     public void addFilter( Filter filter ) throws DecoderException
     {
@@ -114,11 +113,12 @@
 
 
     /**
-     * Encode the ConnectorFilter message to a PDU. ConnectorFilter :
+     * Encode the ConnectorFilter message to a PDU. 
+     * 
+     * ConnectorFilter :
      * filter.encode() ... filter.encode()
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java Tue Oct  3 06:49:43 2006
@@ -23,11 +23,10 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
@@ -45,10 +44,15 @@
     private transient int expectedMatchingRuleLength;
 
     /** Matching rule */
-    private LdapString matchingRule;
+    private String matchingRule;
+    
+    /** Matching rule bytes */
+    private transient byte[] matchingRuleBytes;
 
     /** Matching rule type */
-    private LdapString type;
+    private String type;
+    
+    private transient byte[] typeBytes;
 
     /** Matching rule value */
     private Object matchValue;
@@ -59,9 +63,6 @@
     /** The extensible match length */
     private transient int extensibleMatchLength;
 
-
-    /** The matching Rule Assertion Length */
-    // private transient int matchingRuleAssertionLength;
     // ~ Constructors
     // -------------------------------------------------------------------------------
     /**
@@ -91,8 +92,7 @@
     /**
      * Set the dnAttributes flag
      * 
-     * @param dnAttributes
-     *            The dnAttributes to set.
+     * @param dnAttributes The dnAttributes to set.
      */
     public void setDnAttributes( boolean dnAttributes )
     {
@@ -105,7 +105,7 @@
      * 
      * @return Returns the matchingRule.
      */
-    public LdapString getMatchingRule()
+    public String getMatchingRule()
     {
         return matchingRule;
     }
@@ -114,10 +114,9 @@
     /**
      * Set the matchingRule
      * 
-     * @param matchingRule
-     *            The matchingRule to set.
+     * @param matchingRule The matchingRule to set.
      */
-    public void setMatchingRule( LdapString matchingRule )
+    public void setMatchingRule( String matchingRule )
     {
         this.matchingRule = matchingRule;
     }
@@ -137,8 +136,7 @@
     /**
      * Set the matchValue
      * 
-     * @param matchValue
-     *            The matchValue to set.
+     * @param matchValue The matchValue to set.
      */
     public void setMatchValue( Object matchValue )
     {
@@ -151,7 +149,7 @@
      * 
      * @return Returns the type.
      */
-    public LdapString getType()
+    public String getType()
     {
         return type;
     }
@@ -160,10 +158,9 @@
     /**
      * Set the type
      * 
-     * @param type
-     *            The type to set.
+     * @param type The type to set.
      */
-    public void setType( LdapString type )
+    public void setType( String type )
     {
         this.type = type;
     }
@@ -183,8 +180,7 @@
     /**
      * Set the expectedMatchingRuleLength
      * 
-     * @param expectedMatchingRuleLength
-     *            The expectedMatchingRuleLength to set.
+     * @param expectedMatchingRuleLength The expectedMatchingRuleLength to set.
      */
     public void setExpectedMatchingRuleLength( int expectedMatchingRuleLength )
     {
@@ -193,20 +189,27 @@
 
 
     /**
-     * Compute the ExtensibleMatchFilter length ExtensibleMatchFilter : 0xA9 L1 |
-     * [+--> 0x81 L3 matchingRule] [+--> 0x82 L4 type] [+--> 0x83 L5 matchValue]
-     * [+--> 0x01 0x01 dnAttributes]
+     * Compute the ExtensibleMatchFilter length 
+     * ExtensibleMatchFilter : 
+     * 0xA9 L1 
+     *   |
+     *  [+--> 0x81 L3 matchingRule] 
+     *  [+--> 0x82 L4 type] 
+     *  [+--> 0x83 L5 matchValue]
+     *  [+--> 0x01 0x01 dnAttributes]
      */
     public int computeLength()
     {
         if ( matchingRule != null )
         {
-            extensibleMatchLength = 1 + Length.getNbBytes( matchingRule.getNbBytes() ) + matchingRule.getNbBytes();
+            matchingRuleBytes = StringTools.getBytesUtf8(  matchingRule );
+            extensibleMatchLength = 1 + TLV.getNbBytes( matchingRuleBytes.length ) + matchingRuleBytes.length;
         }
 
         if ( type != null )
         {
-            extensibleMatchLength += 1 + Length.getNbBytes( type.getNbBytes() ) + type.getNbBytes();
+            typeBytes = StringTools.getBytesUtf8( type );
+            extensibleMatchLength += 1 + TLV.getNbBytes( typeBytes.length ) + typeBytes.length;
         }
 
         if ( matchValue != null )
@@ -214,11 +217,11 @@
             if ( matchValue instanceof String )
             {
                 int matchValueLength = StringTools.getBytesUtf8( ( String ) matchValue ).length;
-                extensibleMatchLength += 1 + Length.getNbBytes( matchValueLength ) + matchValueLength;
+                extensibleMatchLength += 1 + TLV.getNbBytes( matchValueLength ) + matchValueLength;
             }
             else
             {
-                extensibleMatchLength += 1 + Length.getNbBytes( ( ( byte[] ) matchValue ).length )
+                extensibleMatchLength += 1 + TLV.getNbBytes( ( ( byte[] ) matchValue ).length )
                     + ( ( byte[] ) matchValue ).length;
             }
         }
@@ -228,18 +231,27 @@
             extensibleMatchLength += 1 + 1 + 1;
         }
 
-        return 1 + Length.getNbBytes( extensibleMatchLength ) + extensibleMatchLength;
+        return 1 + TLV.getNbBytes( extensibleMatchLength ) + extensibleMatchLength;
     }
 
 
     /**
-     * Encode the ExtensibleMatch Filters to a PDU. ExtensibleMatch filter :
-     * 0xA9 LL | 0x81 LL matchingRule | / | 0x82 LL Type | / | /0x83 LL
-     * matchValue +--+ +-+ | \ \ | \ 0x83 LL MatchValue | 0x82 LL type | 0x83 LL
-     * matchValue +--[0x84 0x01 dnAttributes]
+     * Encode the ExtensibleMatch Filters to a PDU. 
+     * 
+     * ExtensibleMatch filter :
+     * 
+     * 0xA9 LL 
+     *  |     0x81 LL matchingRule
+     *  |    / |   0x82 LL Type  
+     *  |   /  |  /0x83 LL matchValue
+     *  +--+   +-+
+     *  |   \     \
+     *  |    \     0x83 LL MatchValue
+     *  |     0x82 LL type
+     *  |     0x83 LL matchValue
+     *  +--[0x84 0x01 dnAttributes]
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -253,7 +265,7 @@
         {
             // The ExtensibleMatch Tag
             buffer.put( ( byte ) LdapConstants.EXTENSIBLE_MATCH_FILTER_TAG );
-            buffer.put( Length.getBytes( extensibleMatchLength ) );
+            buffer.put( TLV.getBytes( extensibleMatchLength ) );
 
             if ( ( matchingRule == null ) && ( type == null ) )
             {
@@ -263,28 +275,28 @@
             // The matching rule
             if ( matchingRule != null )
             {
-                buffer.put( ( byte ) LdapConstants.SEARCH_MATCHING_RULE_TAG );
-                buffer.put( Length.getBytes( matchingRule.getNbBytes() ) );
-                buffer.put( matchingRule.getBytes() );
+                buffer.put( ( byte ) LdapConstants.MATCHING_RULE_ID_TAG );
+                buffer.put( TLV.getBytes( matchingRuleBytes.length ) );
+                buffer.put( matchingRuleBytes );
             }
 
             // The type
             if ( type != null )
             {
-                buffer.put( ( byte ) LdapConstants.MATCHING_RULE_ASSERTION_TYPE_TAG );
-                buffer.put( Length.getBytes( type.getNbBytes() ) );
-                buffer.put( type.getBytes() );
+                buffer.put( ( byte ) LdapConstants.MATCHING_RULE_TYPE_TAG );
+                buffer.put( TLV.getBytes( typeBytes.length ) );
+                buffer.put( typeBytes );
             }
 
             // The match value
             if ( matchValue != null )
             {
-                buffer.put( ( byte ) LdapConstants.SEARCH_MATCH_VALUE_TAG );
+                buffer.put( ( byte ) LdapConstants.MATCH_VALUE_TAG );
 
                 if ( matchValue instanceof String )
                 {
                     byte[] matchValueBytes = StringTools.getBytesUtf8( ( String ) matchValue );
-                    buffer.put( Length.getBytes( matchValueBytes.length ) );
+                    buffer.put( TLV.getBytes( matchValueBytes.length ) );
 
                     if ( matchValueBytes.length != 0 )
                     {
@@ -293,7 +305,7 @@
                 }
                 else
                 {
-                    buffer.put( Length.getBytes( ( ( byte[] ) matchValue ).length ) );
+                    buffer.put( TLV.getBytes( ( ( byte[] ) matchValue ).length ) );
 
                     if ( ( ( byte[] ) matchValue ).length != 0 )
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java Tue Oct  3 06:49:43 2006
@@ -32,16 +32,10 @@
  */
 public abstract class Filter extends Asn1Object
 {
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
-
     /**
      * The constructor.
      */
     public Filter()
     {
     }
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java Tue Oct  3 06:49:43 2006
@@ -23,7 +23,7 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
@@ -51,8 +51,7 @@
      * Subclass the addFilterMethod, as this is specific for a NotFilter (we
      * cannot have more than one elements).
      * 
-     * @param filter
-     *            The Filter to add
+     * @param filter The Filter to add
      */
     public void addFilter( Filter filter ) throws DecoderException
     {
@@ -79,8 +78,7 @@
     /**
      * Set the NotFilter
      * 
-     * @param notFilter
-     *            The notFilter to set.
+     * @param notFilter The notFilter to set.
      */
     public void setNotFilter( Filter notFilter ) throws DecoderException
     {
@@ -94,24 +92,27 @@
 
 
     /**
-     * Compute the NotFilter length NotFilter : 0xA2 L1 super.computeLength()
+     * Compute the NotFilter length 
+     * NotFilter : 
+     * 0xA2 L1 super.computeLength()
+     * 
      * Length(NotFilter) = Length(0xA2) + Length(super.computeLength()) +
-     * super.computeLength()
+     *      super.computeLength()
      */
     public int computeLength()
     {
         filtersLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+        return 1 + TLV.getNbBytes( filtersLength ) + filtersLength;
     }
 
 
     /**
-     * Encode the NotFilter message to a PDU. NotFilter : 0xA2 LL
-     * filter.encode()
+     * Encode the NotFilter message to a PDU. 
+     * NotFilter : 
+     * 0xA2 LL filter.encode()
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -125,7 +126,7 @@
         {
             // The NotFilter Tag
             buffer.put( ( byte ) LdapConstants.NOT_FILTER_TAG );
-            buffer.put( Length.getBytes( filtersLength ) );
+            buffer.put( TLV.getBytes( filtersLength ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java Tue Oct  3 06:49:43 2006
@@ -24,7 +24,7 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 
@@ -63,23 +63,28 @@
 
 
     /**
-     * Compute the OrFilter length OrFilter : 0xA1 L1 super.computeLength()
+     * Compute the OrFilter length 
+     * 
+     * OrFilter : 
+     * 0xA1 L1 super.computeLength()
+     * 
      * Length(OrFilter) = Length(0xA1) + Length(super.computeLength()) +
-     * super.computeLength()
+     *      super.computeLength()
      */
     public int computeLength()
     {
         filtersLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+        return 1 + TLV.getNbBytes( filtersLength ) + filtersLength;
     }
 
 
     /**
-     * Encode the OrFilter message to a PDU. OrFilter : 0xA1 LL filter.encode()
+     * Encode the OrFilter message to a PDU. 
+     * OrFilter : 
+     *   0xA1 LL filter.encode()
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -93,7 +98,7 @@
         {
             // The OrFilter Tag
             buffer.put( ( byte ) LdapConstants.OR_FILTER_TAG );
-            buffer.put( Length.getBytes( filtersLength ) );
+            buffer.put( TLV.getBytes( filtersLength ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java Tue Oct  3 06:49:43 2006
@@ -23,10 +23,10 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -40,7 +40,10 @@
     // ----------------------------------------------------------------------------
 
     /** The attribute description. */
-    private LdapString attributeDescription;
+    private String attributeDescription;
+    
+    /** Temporary storage for attribute description bytes */
+    private transient byte[] attributeDescriptionBytes; 
 
 
     // ~ Constructors
@@ -62,7 +65,7 @@
      * 
      * @return Returns the attributeDescription.
      */
-    public LdapString getAttributeDescription()
+    public String getAttributeDescription()
     {
         return attributeDescription;
     }
@@ -71,23 +74,26 @@
     /**
      * Set the attributeDescription
      * 
-     * @param attributeDescription
-     *            The attributeDescription to set.
+     * @param attributeDescription The attributeDescription to set.
      */
-    public void setAttributeDescription( LdapString attributeDescription )
+    public void setAttributeDescription( String attributeDescription )
     {
         this.attributeDescription = attributeDescription;
     }
 
 
     /**
-     * Compute the PresentFilter length PresentFilter : 0x87 L1 present
+     * Compute the PresentFilter length 
+     * PresentFilter : 
+     * 0x87 L1 present
+     * 
      * Length(PresentFilter) = Length(0x87) + Length(super.computeLength()) +
-     * super.computeLength()
+     *      super.computeLength()
      */
     public int computeLength()
     {
-        return 1 + Length.getNbBytes( attributeDescription.getNbBytes() ) + attributeDescription.getNbBytes();
+        attributeDescriptionBytes = StringTools.getBytesUtf8( attributeDescription );
+        return 1 + TLV.getNbBytes( attributeDescriptionBytes.length ) + attributeDescriptionBytes.length;
     }
 
 
@@ -95,8 +101,7 @@
      * Encode the PresentFilter message to a PDU. PresentFilter : 0x87 LL
      * attributeDescription
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -110,8 +115,8 @@
         {
             // The PresentFilter Tag
             buffer.put( ( byte ) LdapConstants.PRESENT_FILTER_TAG );
-            buffer.put( Length.getBytes( attributeDescription.getNbBytes() ) );
-            buffer.put( attributeDescription.getBytes() );
+            buffer.put( TLV.getBytes( attributeDescriptionBytes.length ) );
+            buffer.put( attributeDescriptionBytes );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java Tue Oct  3 06:49:43 2006
@@ -22,7 +22,6 @@
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.tlv.Length;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -31,7 +30,6 @@
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 
@@ -148,12 +146,11 @@
     /**
      * Add an attribute to the attributes list.
      * 
-     * @param attribute
-     *            The attribute to add to the list
+     * @param attribute The attribute to add to the list
      */
-    public void addAttribute( LdapString attribute )
+    public void addAttribute( String attribute )
     {
-        attributes.put( new BasicAttribute( StringTools.lowerCase( attribute.getString() ) ) );
+        attributes.put( new BasicAttribute( StringTools.lowerCase( attribute ) ) );
     }
 
 
@@ -171,8 +168,7 @@
     /**
      * Set the base object
      * 
-     * @param baseObject
-     *            The baseObject to set.
+     * @param baseObject The baseObject to set.
      */
     public void setBaseObject( LdapDN baseObject )
     {
@@ -194,8 +190,7 @@
     /**
      * Set the derefAliases flag
      * 
-     * @param derefAliases
-     *            The derefAliases to set.
+     * @param derefAliases The derefAliases to set.
      */
     public void setDerefAliases( int derefAliases )
     {
@@ -217,8 +212,7 @@
     /**
      * Set the filter
      * 
-     * @param filter
-     *            The filter to set.
+     * @param filter The filter to set.
      */
     public void setFilter( Filter filter )
     {
@@ -240,8 +234,7 @@
     /**
      * Set the search scope
      * 
-     * @param scope
-     *            The scope to set.
+     * @param scope The scope to set.
      */
     public void setScope( int scope )
     {
@@ -263,8 +256,7 @@
     /**
      * Set the size limit
      * 
-     * @param sizeLimit
-     *            The sizeLimit to set.
+     * @param sizeLimit The sizeLimit to set.
      */
     public void setSizeLimit( int sizeLimit )
     {
@@ -286,8 +278,7 @@
     /**
      * Set the time limit
      * 
-     * @param timeLimit
-     *            The timeLimit to set.
+     * @param timeLimit The timeLimit to set.
      */
     public void setTimeLimit( int timeLimit )
     {
@@ -309,8 +300,7 @@
     /**
      * Set the typesOnly flag
      * 
-     * @param typesOnly
-     *            The typesOnly to set.
+     * @param typesOnly The typesOnly to set.
      */
     public void setTypesOnly( boolean typesOnly )
     {
@@ -388,8 +378,7 @@
     /**
      * Set the current dilter
      * 
-     * @param currentFilter
-     *            The currentFilter to set.
+     * @param currentFilter The currentFilter to set.
      */
     public void setCurrentFilter( Filter filter ) throws DecoderException
     {
@@ -408,8 +397,6 @@
     public void unstackFilters( IAsn1Container container ) throws DecoderException
     {
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-        //LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
-        //SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
         TLV tlv = ldapMessageContainer.getCurrentTLV();
         TLV parent = tlv.getParent();
@@ -444,20 +431,34 @@
     }
 
     /**
-     * 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
+     * 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()
     {
         searchRequestLength = 0;
 
         // The baseObject
-        searchRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( baseObject ) )
+        searchRequestLength += 1 + TLV.getNbBytes( LdapDN.getNbBytes( baseObject ) )
             + LdapDN.getNbBytes( baseObject );
 
         // The scope
@@ -494,14 +495,13 @@
                 try
                 {
                     int idLength = attribute.getID().getBytes( "UTF-8" ).length;
-                    attributeDescriptionListLength += 1 + Length.getNbBytes( idLength ) + idLength;
+                    attributeDescriptionListLength += 1 + TLV.getNbBytes( idLength ) + idLength;
                 }
                 catch ( UnsupportedEncodingException uee )
                 {
                     // Should not be possible. The encoding of the Attribute ID
                     // will check that this ID is valid, and if not, it will
-                    // throw
-                    // an exception.
+                    // throw an exception.
                     // The allocated length will be set to a null length value
                     // in order to avoid an exception thrown while encoding the
                     // Attribute ID.
@@ -510,22 +510,32 @@
             }
         }
 
-        searchRequestLength += 1 + Length.getNbBytes( attributeDescriptionListLength ) + attributeDescriptionListLength;
+        searchRequestLength += 1 + TLV.getNbBytes( attributeDescriptionListLength ) + attributeDescriptionListLength;
 
         // Return the result.
-        return 1 + Length.getNbBytes( searchRequestLength ) + searchRequestLength;
+        return 1 + TLV.getNbBytes( searchRequestLength ) + searchRequestLength;
     }
 
 
     /**
-     * Encode the SearchRequest message to a PDU. SearchRequest : 0x63 LL 0x04
-     * LL baseObject 0x0A 01 scope 0x0A 01 derefAliases 0x02 0N sizeLimit 0x02
-     * 0N timeLimit 0x01 0x01 typesOnly filter.encode() 0x30 LL
-     * attributeDescriptionList 0x04 LL attributeDescription ... 0x04 LL
-     * attributeDescription
+     * Encode the SearchRequest message to a PDU.
+     * 
+     * SearchRequest :
+     * 
+     * 0x63 LL
+     *   0x04 LL baseObject
+     *   0x0A 01 scope
+     *   0x0A 01 derefAliases
+     *   0x02 0N sizeLimit
+     *   0x02 0N timeLimit
+     *   0x01 0x01 typesOnly
+     *   filter.encode()
+     *   0x30 LL attributeDescriptionList
+     *     0x04 LL attributeDescription
+     *     ... 
+     *     0x04 LL attributeDescription
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -539,7 +549,7 @@
         {
             // The SearchRequest Tag
             buffer.put( LdapConstants.SEARCH_REQUEST_TAG );
-            buffer.put( Length.getBytes( searchRequestLength ) );
+            buffer.put( TLV.getBytes( searchRequestLength ) );
 
             // The baseObject
             Value.encode( buffer, LdapDN.getBytes( baseObject ) );
@@ -564,7 +574,7 @@
 
             // The attributeDescriptionList
             buffer.put( UniversalTag.SEQUENCE_TAG );
-            buffer.put( Length.getBytes( attributeDescriptionListLength ) );
+            buffer.put( TLV.getBytes( attributeDescriptionListLength ) );
 
             if ( ( attributes != null ) && ( attributes.size() != 0 ) )
             {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java Tue Oct  3 06:49:43 2006
@@ -23,15 +23,18 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 
 
 /**
- * A SearchResultDone Message. Its syntax is : SearchResultDone ::= [APPLICATION
- * 5] LDAPResult It's a Response, so it inherites from LdapResponse.
+ * A SearchResultDone Message. Its syntax is : 
+ * 
+ * SearchResultDone ::= [APPLICATION 5] 
+ * 
+ * LDAPResult It's a Response, so it inherites from LdapResponse.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -61,23 +64,28 @@
 
 
     /**
-     * Compute the SearchResultDone length SearchResultDone : 0x65 L1 | +-->
-     * LdapResult L1 = Length(LdapResult) Length(SearchResultDone) =
-     * Length(0x65) + Length(L1) + L1
+     * Compute the SearchResultDone length 
+     * 
+     * SearchResultDone : 
+     * 0x65 L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(SearchResultDone) = Length(0x65) + Length(L1) + L1
      */
     public int computeLength()
     {
         int ldapResponseLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+        return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength;
     }
 
 
     /**
      * Encode the SearchResultDone message to a PDU.
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -91,7 +99,7 @@
         {
             // The tag
             buffer.put( LdapConstants.SEARCH_RESULT_DONE_TAG );
-            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+            buffer.put( TLV.getBytes( getLdapResponseLength() ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java Tue Oct  3 06:49:43 2006
@@ -20,13 +20,12 @@
 package org.apache.directory.shared.ldap.codec.search;
 
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -132,8 +131,7 @@
     /**
      * Set the entry DN
      * 
-     * @param objectName
-     *            The objectName to set.
+     * @param objectName The objectName to set.
      */
     public void setObjectName( LdapDN objectName )
     {
@@ -157,7 +155,6 @@
      */
     public void setPartialAttributeList( Attributes partialAttributeList )
     {
-
         this.partialAttributeList = ( Attributes ) partialAttributeList;
     }
 
@@ -165,12 +162,11 @@
     /**
      * Create a new attributeValue
      * 
-     * @param type
-     *            The attribute's name
+     * @param type The attribute's name
      */
-    public void addAttributeValues( LdapString type )
+    public void addAttributeValues( String type )
     {
-        currentAttributeValue = new BasicAttribute( StringTools.lowerCase( type.getString() ) );
+        currentAttributeValue = new BasicAttribute( StringTools.lowerCase( type ) );
 
         partialAttributeList.put( currentAttributeValue );
     }
@@ -230,7 +226,7 @@
     public int computeLength()
     {
         // The entry
-        searchResultEntryLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( objectName ) )
+        searchResultEntryLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( objectName ) )
             + LdapDN.getNbBytes( objectName );
 
         // The attributes sequence
@@ -252,7 +248,7 @@
 
                 // Get the type length
                 int idLength = attribute.getID().getBytes().length;
-                localAttributeLength = 1 + Length.getNbBytes( idLength ) + idLength;
+                localAttributeLength = 1 + TLV.getNbBytes( idLength ) + idLength;
 
                 if ( attribute.size() != 0 )
                 {
@@ -274,18 +270,18 @@
                                     String stringValue = ( String ) value;
 
                                     int stringLength = StringTools.getBytesUtf8( stringValue ).length;
-                                    localValuesLength += 1 + Length.getNbBytes( stringLength ) + stringLength;
+                                    localValuesLength += 1 + TLV.getNbBytes( stringLength ) + stringLength;
                                 }
                                 else
                                 {
                                     byte[] binaryValue = ( byte[] ) value;
-                                    localValuesLength += 1 + Length.getNbBytes( binaryValue.length )
+                                    localValuesLength += 1 + TLV.getNbBytes( binaryValue.length )
                                         + binaryValue.length;
                                 }
 
                             }
 
-                            localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength;
+                            localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                         }
                         else
                         {
@@ -310,17 +306,17 @@
                 }
 
                 // add the attribute length to the attributes length
-                attributesLength += 1 + Length.getNbBytes( localAttributeLength ) + localAttributeLength;
+                attributesLength += 1 + TLV.getNbBytes( localAttributeLength ) + localAttributeLength;
 
                 attributeLength.add( new Integer( localAttributeLength ) );
                 valsLength.add( new Integer( localValuesLength ) );
             }
         }
 
-        searchResultEntryLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength;
+        searchResultEntryLength += 1 + TLV.getNbBytes( attributesLength ) + attributesLength;
 
         // Return the result.
-        return 1 + Length.getNbBytes( searchResultEntryLength ) + searchResultEntryLength;
+        return 1 + TLV.getNbBytes( searchResultEntryLength ) + searchResultEntryLength;
     }
 
 
@@ -360,14 +356,14 @@
         {
             // The SearchResultEntry Tag
             buffer.put( LdapConstants.SEARCH_RESULT_ENTRY_TAG );
-            buffer.put( Length.getBytes( searchResultEntryLength ) );
+            buffer.put( TLV.getBytes( searchResultEntryLength ) );
 
             // The objectName
             Value.encode( buffer, LdapDN.getBytes( objectName ) );
 
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );
-            buffer.put( Length.getBytes( attributesLength ) );
+            buffer.put( TLV.getBytes( attributesLength ) );
 
             // The partial attribute list
             if ( ( partialAttributeList != null ) && ( partialAttributeList.size() != 0 ) )
@@ -383,7 +379,7 @@
                     // The partial attribute list sequence
                     buffer.put( UniversalTag.SEQUENCE_TAG );
                     int localAttributeLength = ( ( Integer ) attributeLength.get( attributeNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localAttributeLength ) );
+                    buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
                     Value.encode( buffer, attribute.getID() );
@@ -391,7 +387,7 @@
                     // The values
                     buffer.put( UniversalTag.SET_TAG );
                     int localValuesLength = ( ( Integer ) valsLength.get( attributeNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localValuesLength ) );
+                    buffer.put( TLV.getBytes( localValuesLength ) );
 
                     if ( attribute.size() != 0 )
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java Tue Oct  3 06:49:43 2006
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.ldap.codec.search;
 
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
@@ -34,8 +34,9 @@
 
 
 /**
- * A SearchResultReference Message. Its syntax is : SearchResultReference ::=
- * [APPLICATION 19] SEQUENCE OF LDAPURL
+ * A SearchResultReference Message. Its syntax is : 
+ * 
+ * SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -81,8 +82,7 @@
     /**
      * Add a new reference to the list.
      * 
-     * @param searchResultReference
-     *            The search result reference
+     * @param searchResultReference The search result reference
      */
     public void addSearchResultReference( LdapURL searchResultReference )
     {
@@ -102,11 +102,22 @@
 
 
     /**
-     * Compute the SearchResultReference length SearchResultReference : 0x73 L1 |
-     * +--> 0x04 L2 reference +--> 0x04 L3 reference +--> ... +--> 0x04 Li
-     * reference +--> ... +--> 0x04 Ln reference L1 = n*Length(0x04) +
-     * sum(Length(Li)) + sum(Length(reference[i])) Length(SearchResultReference) =
-     * Length(0x73 + Length(L1) + L1
+     * Compute the SearchResultReference length
+     * 
+     * SearchResultReference :
+     * 
+     * 0x73 L1
+     *  |
+     *  +--> 0x04 L2 reference
+     *  +--> 0x04 L3 reference
+     *  +--> ...
+     *  +--> 0x04 Li reference
+     *  +--> ...
+     *  +--> 0x04 Ln reference
+     * 
+     * L1 = n*Length(0x04) + sum(Length(Li)) + sum(Length(reference[i]))
+     * 
+     * Length(SearchResultReference) = Length(0x73 + Length(L1) + L1
      */
     public int computeLength()
     {
@@ -118,19 +129,23 @@
         while ( referencesIterator.hasNext() )
         {
             int ldapUrlLength = ( ( LdapURL ) referencesIterator.next() ).getNbBytes();
-            searchResultReferenceLength += 1 + Length.getNbBytes( ldapUrlLength ) + ldapUrlLength;
+            searchResultReferenceLength += 1 + TLV.getNbBytes( ldapUrlLength ) + ldapUrlLength;
         }
 
-        return 1 + Length.getNbBytes( searchResultReferenceLength ) + searchResultReferenceLength;
+        return 1 + TLV.getNbBytes( searchResultReferenceLength ) + searchResultReferenceLength;
     }
 
 
     /**
-     * Encode the SearchResultReference message to a PDU. SearchResultReference :
-     * 0x73 LL 0x04 LL reference [0x04 LL reference]*
+     * Encode the SearchResultReference message to a PDU.
+     * 
+     * SearchResultReference :
+     * 
+     * 0x73 LL
+     *   0x04 LL reference
+     *   [0x04 LL reference]*
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -144,7 +159,7 @@
         {
             // The SearchResultReference Tag
             buffer.put( LdapConstants.SEARCH_RESULT_REFERENCE_TAG );
-            buffer.put( Length.getBytes( searchResultReferenceLength ) );
+            buffer.put( TLV.getBytes( searchResultReferenceLength ) );
 
             // The references. We must at least have one reference
             Iterator referencesIterator = searchResultReferences.iterator();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilter.java Tue Oct  3 06:49:43 2006
@@ -25,18 +25,26 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
- * A Object that stores the substring filter. A substring filter follow this
- * grammar : substring = attr "=" ([initial] any [final] | (initial [any]
- * [final) | ([initial] [any] final) initial = value any = "*" *(value "*")
+ * A Object that stores the substring filter. 
+ * 
+ * A substring filter follow this
+ * grammar : 
+ * 
+ * substring = attr "=" ( ([initial] any [final] | 
+ *                        (initial [any] [final) | 
+ *                        ([initial] [any] final) ) 
+ *                       
+ * initial = value 
+ * any = "*" *(value "*")
  * final = value
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -47,25 +55,30 @@
     // ----------------------------------------------------------------------------
 
     /** The substring filter type (an attributeDescription) */
-    private LdapString type;
+    private String type;
+    
+    /** The type length */
+    private transient int typeLength;
 
     /**
      * This member is used to control the length of the three parts of the
-     * substring filter *
+     * substring filter
      */
     private transient int substringsLength;
 
     /** The initial filter */
-    private LdapString initialSubstrings;
+    private String initialSubstrings;
 
     /** The any filter. It's a list of LdapString */
     private ArrayList anySubstrings;
 
     /** The final filter */
-    private LdapString finalSubstrings;
+    private String finalSubstrings;
 
+    /** Temporary storage for substringsFilter length */
     private transient int substringsFilterLength;
 
+    /** Temporary storage for substringsFilter sequence length */
     private transient int substringsFilterSequenceLength;
 
 
@@ -96,10 +109,9 @@
     /**
      * Add a internal substring
      * 
-     * @param anySubstrings
-     *            The anySubstrings to set.
+     * @param anySubstrings The anySubstrings to set.
      */
-    public void addAnySubstrings( LdapString anySubstrings )
+    public void addAnySubstrings( String anySubstrings )
     {
         this.anySubstrings.add( anySubstrings );
     }
@@ -110,7 +122,7 @@
      * 
      * @return Returns the finalSubstrings.
      */
-    public LdapString getFinalSubstrings()
+    public String getFinalSubstrings()
     {
         return finalSubstrings;
     }
@@ -119,10 +131,9 @@
     /**
      * Set the final substring
      * 
-     * @param finalSubstrings
-     *            The finalSubstrings to set.
+     * @param finalSubstrings The finalSubstrings to set.
      */
-    public void setFinalSubstrings( LdapString finalSubstrings )
+    public void setFinalSubstrings( String finalSubstrings )
     {
         this.finalSubstrings = finalSubstrings;
     }
@@ -133,7 +144,7 @@
      * 
      * @return Returns the initialSubstrings.
      */
-    public LdapString getInitialSubstrings()
+    public String getInitialSubstrings()
     {
         return initialSubstrings;
     }
@@ -142,10 +153,9 @@
     /**
      * Set the initial substring
      * 
-     * @param initialSubstrings
-     *            The initialSubstrings to set.
+     * @param initialSubstrings The initialSubstrings to set.
      */
-    public void setInitialSubstrings( LdapString initialSubstrings )
+    public void setInitialSubstrings( String initialSubstrings )
     {
         this.initialSubstrings = initialSubstrings;
     }
@@ -156,7 +166,7 @@
      * 
      * @return Returns the type.
      */
-    public LdapString getType()
+    public String getType()
     {
         return type;
     }
@@ -165,10 +175,9 @@
     /**
      * Set the attribute to match
      * 
-     * @param type
-     *            The type to set.
+     * @param type The type to set.
      */
-    public void setType( LdapString type )
+    public void setType( String type )
     {
         this.type = type;
     }
@@ -184,8 +193,7 @@
 
 
     /**
-     * @param substringsLength
-     *            The substringsLength to set.
+     * @param substringsLength The substringsLength to set.
      */
     public void setSubstringsLength( int substringsLength )
     {
@@ -194,21 +202,36 @@
 
 
     /**
-     * Compute the SubstringFilter length SubstringFilter : 0xA4 L1 | +--> 0x04
-     * L2 type +--> 0x30 L3 | [+--> 0x80 L4 initial] [+--> 0x81 L5-1 any] [+-->
-     * 0x81 L5-2 any] [+--> ... [+--> 0x81 L5-i any] [+--> ... [+--> 0x81 L5-n
-     * any] [+--> 0x82 L6 final]
+     * Compute the SubstringFilter length 
+     * 
+     * SubstringFilter : 
+     * 0xA4 L1 
+     *   | 
+     *   +--> 0x04 L2 type 
+     *   +--> 0x30 L3 
+     *          | 
+     *         [+--> 0x80 L4 initial] 
+     *         [+--> 0x81 L5-1 any] 
+     *         [+--> 0x81 L5-2 any] 
+     *         [+--> ... 
+     *         [+--> 0x81 L5-i any] 
+     *         [+--> ... 
+     *         [+--> 0x81 L5-n any] 
+     *         [+--> 0x82 L6 final]
      */
     public int computeLength()
     {
         // The type
-        substringsFilterLength = 1 + Length.getNbBytes( type.getNbBytes() ) + type.getNbBytes();
+        typeLength = StringTools.getBytesUtf8( type ).length;
+        
+        substringsFilterLength = 1 + TLV.getNbBytes( typeLength ) + typeLength;
         substringsFilterSequenceLength = 0;
 
         if ( initialSubstrings != null )
         {
-            substringsFilterSequenceLength += 1 + Length.getNbBytes( initialSubstrings.getNbBytes() )
-                + initialSubstrings.getNbBytes();
+            int initialLength = StringTools.getBytesUtf8( initialSubstrings ).length; 
+            substringsFilterSequenceLength += 1 + TLV.getNbBytes( initialLength )
+                + initialLength;
         }
 
         if ( anySubstrings != null )
@@ -217,32 +240,44 @@
 
             while ( anyIterator.hasNext() )
             {
-                LdapString any = ( LdapString ) anyIterator.next();
-                substringsFilterSequenceLength += 1 + Length.getNbBytes( any.getNbBytes() ) + any.getNbBytes();
+                String any = ( String ) anyIterator.next();
+                int anyLength = StringTools.getBytesUtf8( any ).length; 
+                substringsFilterSequenceLength += 1 + TLV.getNbBytes( anyLength ) + anyLength;
             }
         }
 
         if ( finalSubstrings != null )
         {
-            substringsFilterSequenceLength += 1 + Length.getNbBytes( finalSubstrings.getNbBytes() )
-                + finalSubstrings.getNbBytes();
+            int finalLength = StringTools.getBytesUtf8( finalSubstrings ).length; 
+            substringsFilterSequenceLength += 1 + TLV.getNbBytes( finalLength )
+                + finalLength;
         }
 
-        substringsFilterLength += 1 + Length.getNbBytes( substringsFilterSequenceLength )
+        substringsFilterLength += 1 + TLV.getNbBytes( substringsFilterSequenceLength )
             + substringsFilterSequenceLength;
 
-        return 1 + Length.getNbBytes( substringsFilterLength ) + substringsFilterLength;
+        return 1 + TLV.getNbBytes( substringsFilterLength ) + substringsFilterLength;
     }
 
 
     /**
-     * Encode the Substrings Filter to a PDU. Substrings Filter : 0xA4 LL 0x30
-     * LL substringsFilter 0x04 LL type 0x30 LL substrings sequence | 0x80 LL
-     * initial | / [0x81 LL any]* |/ [0x82 LL final] +--[0x81 LL any]+ \ [0x82
-     * LL final] \ 0x82 LL final
+     * Encode the Substrings Filter to a PDU. 
+     * 
+     * Substrings Filter :
+     * 
+     * 0xA4 LL 
+     * 0x30 LL substringsFilter
+     *   0x04 LL type
+     *   0x30 LL substrings sequence
+     *    |  0x80 LL initial
+     *    | /  [0x81 LL any]* 
+     *    |/   [0x82 LL final]
+     *    +--[0x81 LL any]+
+     *     \   [0x82 LL final]
+     *      \
+     *       0x82 LL final
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -256,14 +291,14 @@
         {
             // The SubstringFilter Tag
             buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_TAG );
-            buffer.put( Length.getBytes( substringsFilterLength ) );
+            buffer.put( TLV.getBytes( substringsFilterLength ) );
 
             // The type
             Value.encode( buffer, type.getBytes() );
 
             // The SubstringSequenceFilter Tag
             buffer.put( UniversalTag.SEQUENCE_TAG );
-            buffer.put( Length.getBytes( substringsFilterSequenceLength ) );
+            buffer.put( TLV.getBytes( substringsFilterSequenceLength ) );
 
             if ( ( initialSubstrings == null ) && ( ( anySubstrings == null ) || ( anySubstrings.size() == 0 ) )
                 && ( finalSubstrings == null ) )
@@ -274,9 +309,10 @@
             // The initial substring
             if ( initialSubstrings != null )
             {
+                byte[] initialBytes = StringTools.getBytesUtf8( initialSubstrings );
                 buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG );
-                buffer.put( Length.getBytes( initialSubstrings.getNbBytes() ) );
-                buffer.put( initialSubstrings.getBytes() );
+                buffer.put( TLV.getBytes( initialBytes.length ) );
+                buffer.put( initialBytes );
             }
 
             // The any substrings
@@ -286,19 +322,21 @@
 
                 while ( anyIterator.hasNext() )
                 {
-                    LdapString any = ( LdapString ) anyIterator.next();
+                    String any = ( String ) anyIterator.next();
+                    byte[] anyBytes = StringTools.getBytesUtf8( any );
                     buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_ANY_TAG );
-                    buffer.put( Length.getBytes( any.getNbBytes() ) );
-                    buffer.put( any.getBytes() );
+                    buffer.put( TLV.getBytes( anyBytes.length ) );
+                    buffer.put( anyBytes );
                 }
             }
 
             // The final substring
             if ( finalSubstrings != null )
             {
+                byte[] finalBytes = StringTools.getBytesUtf8( finalSubstrings );
                 buffer.put( ( byte ) LdapConstants.SUBSTRINGS_FILTER_FINAL_TAG );
-                buffer.put( Length.getBytes( finalSubstrings.getNbBytes() ) );
-                buffer.put( finalSubstrings.getBytes() );
+                buffer.put( TLV.getBytes( finalBytes.length ) );
+                buffer.put( finalBytes );
             }
         }
         catch ( BufferOverflowException boe )
@@ -333,7 +371,7 @@
 
             while ( anyIterator.hasNext() )
             {
-                sb.append( ( LdapString ) anyIterator.next() ).append( '*' );
+                sb.append( ( String ) anyIterator.next() ).append( '*' );
             }
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java?view=diff&rev=452497&r1=452496&r2=452497
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java Tue Oct  3 06:49:43 2006
@@ -55,7 +55,7 @@
     public static final ChangeType MODIFY = new ChangeType( "MODIFY", MODIFY_VALUE );
 
     public static final ChangeType MODDN = new ChangeType( "MODDN", MODDN_VALUE );
-
+    
     private final String label;
 
     private final int value;
@@ -76,18 +76,16 @@
 
     public String toString()
     {
-        return ( label );
+        return label;
     }
 
 
     /**
      * Gets the changeType enumeration type for an integer value.
      * 
-     * @param value
-     *            the value to get the enumeration for
+     * @param value the value to get the enumeration for
      * @return the enueration type for the value if the value is valid
-     * @throws IllegalArgumentException
-     *             if the value is undefined
+     * @throws IllegalArgumentException if the value is undefined
      */
     public static ChangeType getChangeType( int value )
     {



Mime
View raw message