org.apache.directory.shared.ldap.codec
Class LdapMessage

java.lang.Object
  extended byorg.apache.directory.shared.asn1.Asn1Object
      extended byorg.apache.directory.shared.ldap.codec.LdapMessage
Direct Known Subclasses:
AbandonRequest, AddRequest, BindRequest, CompareRequest, DelRequest, ExtendedRequest, LdapResponse, ModifyDNRequest, ModifyRequest, SearchRequest, SearchResultEntry, SearchResultReference, UnBindRequest

public class LdapMessage
extends org.apache.directory.shared.asn1.Asn1Object

The main ldapObject : every Ldap Message are encapsulated in it. It contains a message Id, a operation (protocolOp) and one ore more Controls.

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.asn1.Asn1Object
parent
 
Constructor Summary
LdapMessage()
          Creates a new LdapMessage object.
 
Method Summary
 void addControl(Control control)
          Add a control to the Controls array
 int computeLength()
          Compute the LdapMessage length LdapMessage : 0x30 L1 | +--> 0x02 0x0(1-4) [0..2^31-1] (MessageId) +--> protocolOp [+--> Controls] MessageId length = Length(0x02) + length(MessageId) + MessageId.length L1 = length(ProtocolOp) LdapMessage length = Length(0x30) + Length(L1) + MessageId length + L1
 java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
          Generate the PDU which contains the encoded object.
 AbandonRequest getAbandonRequest()
          Get a AbandonRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 AddRequest getAddRequest()
          Get a AddRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 AddResponse getAddResponse()
          Get a AddResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 BindRequest getBindRequest()
          Get a BindRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 BindResponse getBindResponse()
          Get a BindResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 CompareRequest getCompareRequest()
          Get a CompareRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 CompareResponse getCompareResponse()
          Get a CompareResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 java.util.ArrayList getControls()
          Get the Control Objects
 Control getControls(int i)
          Get the Control Object at a specific index
 Control getCurrentControl()
          Get the current Control Object
 DelRequest getDelRequest()
          Get a DelRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 DelResponse getDelResponse()
          Get a DelResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 ExtendedRequest getExtendedRequest()
          Get a ExtendedRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 ExtendedResponse getExtendedResponse()
          Get a ExtendedResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 LdapResponse getLdapResponse()
          Get the encapsulated Ldap response.
 int getMessageId()
          Get the message ID
 int getMessageType()
          Get the message type
 java.lang.String getMessageTypeName()
          Get the message type Name
 ModifyDNRequest getModifyDNRequest()
          Get a ModifyDNRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 ModifyDNResponse getModifyDNResponse()
          Get a ModifyDNResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 ModifyRequest getModifyRequest()
          Get a ModifyRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 ModifyResponse getModifyResponse()
          Get a ModifyResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 SearchRequest getSearchRequest()
          Get a SearchRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 SearchResultDone getSearchResultDone()
          Get a SearchResultDone ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 SearchResultEntry getSearchResultEntry()
          Get a SearchResultEntry ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 SearchResultReference getSearchResultReference()
          Get a SearchResultReference ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 UnBindRequest getUnBindRequest()
          Get a UnBindRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.
 void initControl()
          Init the controls array
 void setMessageId(int messageId)
          Set the message ID
 void setProtocolOP(org.apache.directory.shared.asn1.Asn1Object protocolOp)
          Set the ProtocolOP
 java.lang.String toString()
          Get a String representation of a LdapMessage
 
Methods inherited from class org.apache.directory.shared.asn1.Asn1Object
addLength, getCurrentLength, getExpectedLength, getParent, setCurrentLength, setExpectedLength, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LdapMessage

public LdapMessage()
Creates a new LdapMessage object.

Method Detail

getControls

public Control getControls(int i)
Get the Control Object at a specific index

Parameters:
i - The index of the Control Object to get
Returns:
The selected Control Object

getControls

public java.util.ArrayList getControls()
Get the Control Objects

Returns:
The Control Objects

getCurrentControl

public Control getCurrentControl()
Get the current Control Object

Returns:
The current Control Object

addControl

public void addControl(Control control)
Add a control to the Controls array

Parameters:
control - The Control to add

initControl

public void initControl()
Init the controls array


getMessageId

public int getMessageId()
Get the message ID

Returns:
The message ID

setMessageId

public void setMessageId(int messageId)
Set the message ID

Parameters:
messageId - The message ID

getMessageType

public int getMessageType()
Get the message type

Returns:
The message type

getMessageTypeName

public java.lang.String getMessageTypeName()
Get the message type Name

Returns:
The message type name

getLdapResponse

public LdapResponse getLdapResponse()
Get the encapsulated Ldap response.

Returns:
Returns the Ldap response.

getAbandonRequest

public AbandonRequest getAbandonRequest()
Get a AbandonRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the AbandonRequest ldapObject.

getAddRequest

public AddRequest getAddRequest()
Get a AddRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the AddRequest ldapObject.

getAddResponse

public AddResponse getAddResponse()
Get a AddResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the AddResponse ldapObject.

getBindRequest

public BindRequest getBindRequest()
Get a BindRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the BindRequest ldapObject.

getBindResponse

public BindResponse getBindResponse()
Get a BindResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the BindResponse ldapObject.

getCompareRequest

public CompareRequest getCompareRequest()
Get a CompareRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the CompareRequest ldapObject.

getCompareResponse

public CompareResponse getCompareResponse()
Get a CompareResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the CompareResponse ldapObject.

getDelRequest

public DelRequest getDelRequest()
Get a DelRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the DelRequest ldapObject.

getDelResponse

public DelResponse getDelResponse()
Get a DelResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the DelResponse ldapObject.

getExtendedRequest

public ExtendedRequest getExtendedRequest()
Get a ExtendedRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ExtendedRequest ldapObject.

getExtendedResponse

public ExtendedResponse getExtendedResponse()
Get a ExtendedResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ExtendedResponse ldapObject.

getModifyDNRequest

public ModifyDNRequest getModifyDNRequest()
Get a ModifyDNRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ModifyDNRequest ldapObject.

getModifyDNResponse

public ModifyDNResponse getModifyDNResponse()
Get a ModifyDNResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ModifyDNResponse ldapObject.

getModifyRequest

public ModifyRequest getModifyRequest()
Get a ModifyRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ModifyRequest ldapObject.

getModifyResponse

public ModifyResponse getModifyResponse()
Get a ModifyResponse ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the ModifyResponse ldapObject.

getSearchRequest

public SearchRequest getSearchRequest()
Get a SearchRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the SearchRequest ldapObject.

getSearchResultDone

public SearchResultDone getSearchResultDone()
Get a SearchResultDone ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the SearchRequestDone ldapObject.

getSearchResultEntry

public SearchResultEntry getSearchResultEntry()
Get a SearchResultEntry ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the SearchResultEntry ldapObject.

getSearchResultReference

public SearchResultReference getSearchResultReference()
Get a SearchResultReference ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the SearchResultReference ldapObject.

getUnBindRequest

public UnBindRequest getUnBindRequest()
Get a UnBindRequest ldapObject, assuming that the caller knows that it is the LdapMessage exact type.

Returns:
Returns the UnBindRequest ldapObject.

setProtocolOP

public void setProtocolOP(org.apache.directory.shared.asn1.Asn1Object protocolOp)
Set the ProtocolOP

Parameters:
protocolOp - The protocolOp to set.

computeLength

public int computeLength()
Compute the LdapMessage length LdapMessage : 0x30 L1 | +--> 0x02 0x0(1-4) [0..2^31-1] (MessageId) +--> protocolOp [+--> Controls] MessageId length = Length(0x02) + length(MessageId) + MessageId.length L1 = length(ProtocolOp) LdapMessage length = Length(0x30) + Length(L1) + MessageId length + L1


encode

public java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
                           throws org.apache.directory.shared.asn1.codec.EncoderException
Generate the PDU which contains the encoded object. The generation is done in two phases : - first, we compute the length of each part and the global PDU length - second, we produce the PDU. 0x30 L1 | +--> 0x02 L2 MessageId (L2 = Length(MessageId) +--> ProtocolOp +--> Controls L1 = Length(0x02) + Length(L2) + L2 + Length(ProtocolOp) + Length(Controls) LdapMessageLength = Length(0x30) + Length(L1) + L1

Parameters:
buffer - The encoded PDU
Returns:
A ByteBuffer that contaons the PDU
Throws:
org.apache.directory.shared.asn1.codec.EncoderException - If anything goes wrong.

toString

public java.lang.String toString()
Get a String representation of a LdapMessage

Returns:
A LdapMessage String


Copyright © 2003-2006 . All Rights Reserved.