org.opends.server.protocols.ldap
Class LDAPMessage

java.lang.Object
  extended by org.opends.server.protocols.ldap.LDAPMessage
All Implemented Interfaces:
ProtocolElement

public class LDAPMessage
extends java.lang.Object
implements ProtocolElement

This class defines the data structures and methods to use when interacting with an LDAP message, which is the basic envelope used to hold LDAP requests and responses.


Constructor Summary
LDAPMessage(int messageID, ProtocolOp protocolOp)
          Creates a new LDAP message with the provided message ID and protocol op but no controls.
LDAPMessage(int messageID, ProtocolOp protocolOp, java.util.ArrayList<LDAPControl> controls)
          Creates a new LDAP message with the provided message ID, protocol op, and set of controls.
 
Method Summary
static LDAPMessage decode(ASN1Sequence messageSequence)
          Decodes the provided ASN.1 sequence as an LDAP message.
 ASN1Element encode()
          Encodes this LDAP message to an ASN.1 element.
 AbandonRequestProtocolOp getAbandonRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as an abandon request protocol op.
 AddRequestProtocolOp getAddRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as an add request protocol op.
 AddResponseProtocolOp getAddResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as an add response protocol op.
 BindRequestProtocolOp getBindRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a bind request protocol op.
 BindResponseProtocolOp getBindResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as a bind response protocol op.
 CompareRequestProtocolOp getCompareRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a compare request protocol op.
 CompareResponseProtocolOp getCompareResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as a compare response protocol op.
 java.util.ArrayList<LDAPControl> getControls()
          Retrieves the set of controls for this LDAP message.
 DeleteRequestProtocolOp getDeleteRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a delete request protocol op.
 DeleteResponseProtocolOp getDeleteResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as a delete response protocol op.
 ExtendedRequestProtocolOp getExtendedRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as an extended request protocol op.
 ExtendedResponseProtocolOp getExtendedResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as an extended response protocol op.
 int getMessageID()
          Retrieves the message ID for this LDAP message.
 ModifyDNRequestProtocolOp getModifyDNRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a modify DN request protocol op.
 ModifyDNResponseProtocolOp getModifyDNResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as a modify DN response protocol op.
 ModifyRequestProtocolOp getModifyRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a modify request protocol op.
 ModifyResponseProtocolOp getModifyResponseProtocolOp()
          Retrieves the protocol op for this LDAP message as a modify response protocol op.
 java.lang.String getProtocolElementName()
          Retrieves the name of the protocol associated with this protocol element.
 ProtocolOp getProtocolOp()
          Retrieves the protocol op for this LDAP message.
 java.lang.String getProtocolOpName()
          Retrieves the protocol op name for this LDAP message.
 byte getProtocolOpType()
          Retrieves the protocol op type for this LDAP message.
 SearchRequestProtocolOp getSearchRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as a search request protocol op.
 SearchResultDoneProtocolOp getSearchResultDoneProtocolOp()
          Retrieves the protocol op for this LDAP message as a search result done protocol op.
 SearchResultEntryProtocolOp getSearchResultEntryProtocolOp()
          Retrieves the protocol op for this LDAP message as a search result entry protocol op.
 SearchResultReferenceProtocolOp getSearchResultReferenceProtocolOp()
          Retrieves the protocol op for this LDAP message as a search result reference protocol op.
 UnbindRequestProtocolOp getUnbindRequestProtocolOp()
          Retrieves the protocol op for this LDAP message as an unbind request protocol op.
 void setMessageID(int messageID)
          Specifies the message ID for this LDAP message.
 void setProtocolOp(ProtocolOp protocolOp)
          Specifies the protocol op for this LDAP message.
 java.lang.String toString()
          Retrieves a string representation of this LDAP message.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this protocol element to the provided buffer.
 void toString(java.lang.StringBuilder buffer, int indent)
          Appends a string representation of this protocol element to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPMessage

public LDAPMessage(int messageID,
                   ProtocolOp protocolOp)
Creates a new LDAP message with the provided message ID and protocol op but no controls.

Parameters:
messageID - The message ID for this LDAP message.
protocolOp - The protocol op for this LDAP message.

LDAPMessage

public LDAPMessage(int messageID,
                   ProtocolOp protocolOp,
                   java.util.ArrayList<LDAPControl> controls)
Creates a new LDAP message with the provided message ID, protocol op, and set of controls.

Parameters:
messageID - The message ID for this LDAP message.
protocolOp - The protocol op for this LDAP message.
controls - The set of controls for this LDAP message.
Method Detail

getMessageID

public int getMessageID()
Retrieves the message ID for this LDAP message.

Returns:
The message ID for this LDAP message.

setMessageID

public void setMessageID(int messageID)
Specifies the message ID for this LDAP message.

Parameters:
messageID - The message ID for this LDAP message.

getProtocolOp

public ProtocolOp getProtocolOp()
Retrieves the protocol op for this LDAP message.

Returns:
The protocol op for this LDAP message.

getProtocolOpType

public byte getProtocolOpType()
Retrieves the protocol op type for this LDAP message.

Returns:
The protocol op type for this LDAP message.

getProtocolOpName

public java.lang.String getProtocolOpName()
Retrieves the protocol op name for this LDAP message.

Returns:
The protocol op name for this LDAP message.

getAbandonRequestProtocolOp

public AbandonRequestProtocolOp getAbandonRequestProtocolOp()
                                                     throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an abandon request protocol op.

Returns:
The protocol op for this LDAP message as an abandon request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an abandon request protocol op.

getAddRequestProtocolOp

public AddRequestProtocolOp getAddRequestProtocolOp()
                                             throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an add request protocol op.

Returns:
The protocol op for this LDAP message as an add request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an add request protocol op.

getAddResponseProtocolOp

public AddResponseProtocolOp getAddResponseProtocolOp()
                                               throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an add response protocol op.

Returns:
The protocol op for this LDAP message as an add response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an add response protocol op.

getBindRequestProtocolOp

public BindRequestProtocolOp getBindRequestProtocolOp()
                                               throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a bind request protocol op.

Returns:
The protocol op for this LDAP message as a bind request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a bind request protocol op.

getBindResponseProtocolOp

public BindResponseProtocolOp getBindResponseProtocolOp()
                                                 throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a bind response protocol op.

Returns:
The protocol op for this LDAP message as a bind response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a bind response protocol op.

getCompareRequestProtocolOp

public CompareRequestProtocolOp getCompareRequestProtocolOp()
                                                     throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a compare request protocol op.

Returns:
The protocol op for this LDAP message as a compare request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a compare request protocol op.

getCompareResponseProtocolOp

public CompareResponseProtocolOp getCompareResponseProtocolOp()
                                                       throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a compare response protocol op.

Returns:
The protocol op for this LDAP message as a compare response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a compare response protocol op.

getDeleteRequestProtocolOp

public DeleteRequestProtocolOp getDeleteRequestProtocolOp()
                                                   throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a delete request protocol op.

Returns:
The protocol op for this LDAP message as a delete request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a delete request protocol op.

getDeleteResponseProtocolOp

public DeleteResponseProtocolOp getDeleteResponseProtocolOp()
                                                     throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a delete response protocol op.

Returns:
The protocol op for this LDAP message as a delete response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a delete response protocol op.

getExtendedRequestProtocolOp

public ExtendedRequestProtocolOp getExtendedRequestProtocolOp()
                                                       throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an extended request protocol op.

Returns:
The protocol op for this LDAP message as an extended request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an extended request protocol op.

getExtendedResponseProtocolOp

public ExtendedResponseProtocolOp getExtendedResponseProtocolOp()
                                                         throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an extended response protocol op.

Returns:
The protocol op for this LDAP message as an extended response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an extended response protocol op.

getModifyRequestProtocolOp

public ModifyRequestProtocolOp getModifyRequestProtocolOp()
                                                   throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a modify request protocol op.

Returns:
The protocol op for this LDAP message as a modify request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a modify request protocol op.

getModifyResponseProtocolOp

public ModifyResponseProtocolOp getModifyResponseProtocolOp()
                                                     throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a modify response protocol op.

Returns:
The protocol op for this LDAP message as a modify response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a modify response protocol op.

getModifyDNRequestProtocolOp

public ModifyDNRequestProtocolOp getModifyDNRequestProtocolOp()
                                                       throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a modify DN request protocol op.

Returns:
The protocol op for this LDAP message as a modify DN request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a modify DN request protocol op.

getModifyDNResponseProtocolOp

public ModifyDNResponseProtocolOp getModifyDNResponseProtocolOp()
                                                         throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a modify DN response protocol op.

Returns:
The protocol op for this LDAP message as a modify DN response protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a modify DN response protocol op.

getSearchRequestProtocolOp

public SearchRequestProtocolOp getSearchRequestProtocolOp()
                                                   throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a search request protocol op.

Returns:
The protocol op for this LDAP message as a search request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a search request protocol op.

getSearchResultDoneProtocolOp

public SearchResultDoneProtocolOp getSearchResultDoneProtocolOp()
                                                         throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a search result done protocol op.

Returns:
The protocol op for this LDAP message as a search result done protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a search result done protocol op.

getSearchResultEntryProtocolOp

public SearchResultEntryProtocolOp getSearchResultEntryProtocolOp()
                                                           throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a search result entry protocol op.

Returns:
The protocol op for this LDAP message as a search result entry protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a search result entry protocol op.

getSearchResultReferenceProtocolOp

public SearchResultReferenceProtocolOp getSearchResultReferenceProtocolOp()
                                                                   throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as a search result reference protocol op.

Returns:
The protocol op for this LDAP message as a search result reference protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not a search result reference protocol op.

getUnbindRequestProtocolOp

public UnbindRequestProtocolOp getUnbindRequestProtocolOp()
                                                   throws java.lang.ClassCastException
Retrieves the protocol op for this LDAP message as an unbind request protocol op.

Returns:
The protocol op for this LDAP message as an unbind request protocol op.
Throws:
java.lang.ClassCastException - If the protocol op is not an unbind request protocol op.

setProtocolOp

public void setProtocolOp(ProtocolOp protocolOp)
Specifies the protocol op for this LDAP message.

Parameters:
protocolOp - The protocol op for this LDAP message.

getControls

public java.util.ArrayList<LDAPControl> getControls()
Retrieves the set of controls for this LDAP message. It may be modified by the caller.

Returns:
The set of controls for this LDAP message.

encode

public ASN1Element encode()
Encodes this LDAP message to an ASN.1 element.

Returns:
The ASN.1 element containing the encoded LDAP message.

decode

public static LDAPMessage decode(ASN1Sequence messageSequence)
                          throws LDAPException
Decodes the provided ASN.1 sequence as an LDAP message.

Parameters:
messageSequence - The ASN.1 sequence to decode as an LDAP message.
Returns:
The decoded LDAP message.
Throws:
LDAPException - If a problem occurs while attempting to decode the LDAP message.

getProtocolElementName

public java.lang.String getProtocolElementName()
Retrieves the name of the protocol associated with this protocol element.

Specified by:
getProtocolElementName in interface ProtocolElement
Returns:
The name of the protocol associated with this protocol element.

toString

public java.lang.String toString()
Retrieves a string representation of this LDAP message.

Specified by:
toString in interface ProtocolElement
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this LDAP message.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this protocol element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Parameters:
buffer - The buffer into which the string representation should be written.

toString

public void toString(java.lang.StringBuilder buffer,
                     int indent)
Appends a string representation of this protocol element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Parameters:
buffer - The buffer into which the string representation should be written.
indent - The number of spaces that should be used to indent the resulting string representation.