You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/10/02 01:07:49 UTC
svn commit: r451836 [8/11] - in /directory/branches/shared/0.9.5/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/actions/ main/java/o...
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulShutdownStatesEnum.java Sun Oct 1 16:07:44 2006
@@ -39,53 +39,32 @@
// GracefulShutdown grammar states
// =========================================================================
- /** Sequence Tag */
- public static int GRACEFUL_SHUTDOWN_SEQUENCE_TAG = 0;
+ /** Initial state */
+ public static final int START_STATE = 0;
- /** Sequence Value */
- public static int GRACEFUL_SHUTDOWN_SEQUENCE_VALUE = 1;
+ /** Sequence */
+ public static int GRACEFUL_SHUTDOWN_SEQUENCE_STATE = 1;
- /** Time offline Tag */
- public static int TIME_OFFLINE_OR_DELAY_OR_END_TAG = 2;
+ /** Time offline */
+ public static int TIME_OFFLINE_STATE = 2;
- /** Time offline Value */
- public static int TIME_OFFLINE_VALUE = 3;
-
- /** Delay Tag */
- public static int DELAY_OR_END_TAG = 4;
-
- /** Delay Value */
- public static int DELAY_VALUE = 5;
+ /** Delay */
+ public static int DELAY_STATE = 3;
/** terminal state */
- public static int LAST_GRACEFUL_SHUTDOWN_STATE = 6;
-
- // =========================================================================
- // Grammars declaration.
- // =========================================================================
- /** GracefulShutdown grammar */
- public static final int GRACEFUL_SHUTDOWN_GRAMMAR_SWITCH = 0x0100;
-
- /** GracefulShutdown grammar number */
- public static final int GRACEFUL_SHUTDOWN_GRAMMAR = 0;
-
- /** The total number of grammars used */
- public static final int NB_GRAMMARS = 1;
-
- // =========================================================================
- // Grammar switches debug strings
- // =========================================================================
- /** A string representation of grammars */
- private static String[] GrammarSwitchString = new String[]
- { "GRACEFUL_SHUTDOWN_GRAMMAR_SWITCH" };
+ public static int LAST_GRACEFUL_SHUTDOWN_STATE = 4;
// =========================================================================
// States debug strings
// =========================================================================
/** A string representation of all the states */
private static String[] GracefulShutdownString = new String[]
- { "GRACEFUL_SHUTDOWN_SEQUENCE_TAG", "GRACEFUL_SHUTDOWN_SEQUENCE_VALUE", "TIME_OFFLINE_OR_DELAY_OR_END_TAG",
- "TIME_OFFLINE_VALUE", "DELAY_OR_END_TAG", "DELAY_VALUE" };
+ {
+ "START_STATE",
+ "GRACEFUL_SHUTDOWN_SEQUENCE_STATE",
+ "TIME_OFFLINE_STATE",
+ "DELAY_STATE"
+ };
/** The instance */
private static GracefulShutdownStatesEnum instance = new GracefulShutdownStatesEnum();
@@ -119,27 +98,19 @@
/**
* Get the grammar name
*
- * @param grammar
- * The grammar code
+ * @param grammar The grammar code
* @return The grammar name
*/
public String getGrammarName( int grammar )
{
- switch ( grammar )
- {
- case GRACEFUL_SHUTDOWN_GRAMMAR:
- return "GRACEFUL_SHUTDOWN_GRAMMAR";
- default:
- return "UNKNOWN";
- }
+ return "GRACEFUL_SHUTDOWN_GRAMMAR";
}
/**
* Get the grammar name
*
- * @param grammar
- * The grammar class
+ * @param grammar The grammar class
* @return The grammar name
*/
public String getGrammarName( IGrammar grammar )
@@ -156,32 +127,11 @@
/**
* Get the string representing the state
*
- * @param grammar
- * The current grammar being used
- * @param state
- * The state number
+ * @param state The state number
* @return The String representing the state
*/
- public String getState( int grammar, int state )
+ public String getState( int state )
{
-
- if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
- {
- return ( state == END_STATE ) ? "END_STATE"
- : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
- }
- else
- {
-
- switch ( grammar )
- {
-
- case GRACEFUL_SHUTDOWN_GRAMMAR:
- return ( ( state == GRAMMAR_END ) ? "GRACEFUL_SHUTDOWN_END_STATE" : GracefulShutdownString[state] );
-
- default:
- return "UNKNOWN";
- }
- }
+ return ( ( state == GRAMMAR_END ) ? "GRACEFUL_SHUTDOWN_END_STATE" : GracefulShutdownString[state] );
}
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponse.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequest.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponse.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AndFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ExtensibleMatchFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java Sun Oct 1 16:07:44 2006
@@ -32,16 +32,10 @@
*/
public abstract class Filter extends Asn1Object
{
- // ~ Constructors
- // -------------------------------------------------------------------------------
-
/**
* The constructor.
*/
public Filter()
{
}
-
- // ~ Methods
- // ------------------------------------------------------------------------------------
}
Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/NotFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/OrFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/PresentFilter.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultDone.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java Sun Oct 1 16:07:44 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/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultReference.java Sun Oct 1 16:07:44 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();