org.apache.directory.api.ldap.codec.api
Class MessageDecorator<E extends Message>

java.lang.Object
  extended by org.apache.directory.api.ldap.codec.api.MessageDecorator<E>
All Implemented Interfaces:
Decorator<E>, Message
Direct Known Subclasses:
IntermediateResponseDecorator, RequestDecorator, ResponseDecorator, SearchRequestDecorator, SearchResultEntryDecorator, SearchResultReferenceDecorator

public abstract class MessageDecorator<E extends Message>
extends Object
implements Message, Decorator<E>

A decorator for the generic LDAP Message

Author:
Apache Directory Project

Field Summary
protected  int messageLength
          The encoded Message length
 
Constructor Summary
protected MessageDecorator(LdapApiService codec, E decoratedMessage)
          Makes a Message an Decorator object.
 
Method Summary
 Message addAllControls(Control[] controls)
          Adds an array of controls to this Message.
 Message addControl(Control control)
          Adds a control to this Message.
 Object get(Object key)
          Gets a message scope parameter.
 LdapApiService getCodecService()
          Gets the codec service responsible for managing the encoding and decoding of the decorated objects.
 Control getControl(String oid)
          Gets the control associated with the given OID.
 Map<String,Control> getControls()
          Gets the controls associated with this message mapped by OID.
 int getControlsLength()
           
 CodecControl<? extends Control> getCurrentControl()
          Get the current Control Object
 E getDecorated()
          Gets the object being decorated by this IDecorator.
static MessageDecorator<? extends Message> getDecorator(LdapApiService codec, Message decoratedMessage)
           
 int getMessageId()
          Gets the session unique message sequence id for this message.
 int getMessageLength()
           
 MessageTypeEnum getType()
          Gets the LDAP message type code associated with this Message.
 boolean hasControl(String oid)
          Checks whether or not this message has the specified control.
 Object put(Object key, Object value)
          Sets a message scope parameter.
 Message removeControl(Control control)
          Deletes a control removing it from this Message.
 void setControlsLength(int controlsLength)
           
 Message setMessageId(int messageId)
          Sets the Message ID for this request
 void setMessageLength(int messageLength)
           
 String toString()
          Delegates to the toString() method of the decorated Message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.api.ldap.codec.api.Decorator
computeLength, encode
 

Field Detail

messageLength

protected int messageLength
The encoded Message length

Constructor Detail

MessageDecorator

protected MessageDecorator(LdapApiService codec,
                           E decoratedMessage)
Makes a Message an Decorator object.

Method Detail

getDecorator

public static MessageDecorator<? extends Message> getDecorator(LdapApiService codec,
                                                               Message decoratedMessage)

setControlsLength

public void setControlsLength(int controlsLength)
Parameters:
controlsLength - the encoded controls length

getControlsLength

public int getControlsLength()
Returns:
the encoded controls length

setMessageLength

public void setMessageLength(int messageLength)
Parameters:
messageLength - The encoded message length

getMessageLength

public int getMessageLength()
Returns:
The encoded message length

getCurrentControl

public CodecControl<? extends Control> getCurrentControl()
Get the current Control Object

Returns:
The current Control Object

getType

public MessageTypeEnum getType()
Gets the LDAP message type code associated with this Message. Each request and response type has a unique message type code defined by the protocol in RFC 2251.

Specified by:
getType in interface Message
Returns:
the message type code.

getControls

public Map<String,Control> getControls()
Gets the controls associated with this message mapped by OID.

Specified by:
getControls in interface Message
Returns:
Map of OID strings to Control object instances.

getControl

public Control getControl(String oid)
Gets the control associated with the given OID.

Specified by:
getControl in interface Message
Parameters:
oid - The Cntrol's OID we are looking for
Returns:
The Control object instance with the OID.

hasControl

public boolean hasControl(String oid)
Checks whether or not this message has the specified control.

Specified by:
hasControl in interface Message
Parameters:
oid - the OID of the control
Returns:
true if this message has the control, false if it does not

addControl

public Message addControl(Control control)
                   throws MessageException
Adds a control to this Message.

Specified by:
addControl in interface Message
Parameters:
control - the control to add.
Returns:
A Message reference
Throws:
MessageException - if controls cannot be added to this Message or the control is not known etc.

addAllControls

public Message addAllControls(Control[] controls)
                       throws MessageException
Adds an array of controls to this Message.

Specified by:
addAllControls in interface Message
Parameters:
controls - the controls to add.
Returns:
A Message reference
Throws:
MessageException - if controls cannot be added to this Message or they are not known etc.

removeControl

public Message removeControl(Control control)
                      throws MessageException
Deletes a control removing it from this Message.

Specified by:
removeControl in interface Message
Parameters:
control - the control to remove.
Returns:
A Message reference
Throws:
MessageException - if controls cannot be added to this Message or the control is not known etc.

getMessageId

public int getMessageId()
Gets the session unique message sequence id for this message. Requests and their responses if any have the same message id. Clients at the initialization of a session start with the first message's id set to 1 and increment it with each transaction.

Specified by:
getMessageId in interface Message
Returns:
the session unique message id.

get

public Object get(Object key)
Gets a message scope parameter. Message scope parameters are temporary variables associated with a message and are set locally to be used to associate housekeeping information with a request or its processing. These parameters are never transmitted nor recieved, think of them as transient data associated with the message or its processing. These transient parameters are not locked down so modifications can occur without firing LockExceptions even when this Lockable is in the locked state.

Specified by:
get in interface Message
Parameters:
key - the key used to access a message parameter.
Returns:
the transient message parameter value.

put

public Object put(Object key,
                  Object value)
Sets a message scope parameter. These transient parameters are not locked down so modifications can occur without firing LockExceptions even when this Lockable is in the locked state.

Specified by:
put in interface Message
Parameters:
key - the parameter key
value - the parameter value
Returns:
the old value or null

setMessageId

public Message setMessageId(int messageId)
Sets the Message ID for this request

Specified by:
setMessageId in interface Message
Parameters:
messageId - The message Id
Returns:
A Message reference

toString

public String toString()
Delegates to the toString() method of the decorated Message.

Overrides:
toString in class Object

getDecorated

public E getDecorated()
Gets the object being decorated by this IDecorator.

Specified by:
getDecorated in interface Decorator<E extends Message>
Returns:
The decorated object

getCodecService

public LdapApiService getCodecService()
Gets the codec service responsible for managing the encoding and decoding of the decorated objects.

Specified by:
getCodecService in interface Decorator<E extends Message>
Returns:
the codec service


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.