org.apache.directory.api.ldap.codec.decorators
Class AddRequestDecorator

java.lang.Object
  extended by org.apache.directory.api.ldap.codec.api.MessageDecorator<M>
      extended by org.apache.directory.api.ldap.codec.decorators.RequestDecorator<M>
          extended by org.apache.directory.api.ldap.codec.decorators.ResultResponseRequestDecorator<M,R>
              extended by org.apache.directory.api.ldap.codec.decorators.SingleReplyRequestDecorator<AddRequest,AddResponse>
                  extended by org.apache.directory.api.ldap.codec.decorators.AddRequestDecorator
All Implemented Interfaces:
Decorator<AddRequest>, AbandonableRequest, AddRequest, Message, Request, ResultResponseRequest<AddResponse>, SingleReplyRequest<AddResponse>

public final class AddRequestDecorator
extends SingleReplyRequestDecorator<AddRequest,AddResponse>
implements AddRequest

A decorator for the AddRequest message

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.api.ldap.codec.api.MessageDecorator
messageLength
 
Fields inherited from interface org.apache.directory.api.ldap.model.message.AddRequest
RESP_TYPE, TYPE
 
Constructor Summary
AddRequestDecorator(LdapApiService codec, AddRequest decoratedMessage)
          Makes a AddRequest a MessageDecorator.
 
Method Summary
 AddRequest addAllControls(Control[] controls)
          Adds an array of controls to this Message.
 void addAttributeType(String type)
          Create a new attributeValue
 void addAttributeValue(byte[] value)
          Add a new value to the current attribute
 void addAttributeValue(String value)
          Add a new value to the current attribute
 void addAttributeValue(Value<?> value)
          Add a new value to the current attribute
 AddRequest addControl(Control control)
          Adds a control to this Message.
 int computeLength()
          Compute the AddRequest length AddRequest : 0x68 L1 | +--> 0x04 L2 entry +--> 0x30 L3 (attributes) | +--> 0x30 L4-1 (attribute) | | | +--> 0x04 L5-1 type | +--> 0x31 L6-1 (values) | | | +--> 0x04 L7-1-1 value | +--> ...
 ByteBuffer encode(ByteBuffer buffer)
          Encode the AddRequest message to a PDU.
 int getAddRequestLength()
           
 List<Integer> getAttributesLength()
           
 String getCurrentAttributeType()
           
 Entry getEntry()
          Gets the entry to add.
 Dn getEntryDn()
          Gets the distinguished name of the entry to add.
 int getEntryLength()
           
 List<Integer> getValuesLength()
           
 AddRequest removeControl(Control control)
          Deletes a control removing it from this Message.
 void setAddRequestLength(int addRequestLength)
          Stores the encoded length for the AddRequest
 void setAttributesLength(List<Integer> attributesLength)
          Stores the encoded length for the attributes
 AddRequest setEntry(Entry entry)
          Sets the Entry to add.
 AddRequest setEntryDn(Dn entry)
          Sets the distinguished name of the entry to add.
 void setEntryLength(int entryLength)
          Stores the encoded length for the Entry
 AddRequest setMessageId(int messageId)
          Sets the Message ID for this request
 void setValuesLength(List<Integer> valuesLength)
          Stores the encoded length for the values
 
Methods inherited from class org.apache.directory.api.ldap.codec.decorators.SingleReplyRequestDecorator
abandon, addAbandonListener, getResponseType, isAbandoned
 
Methods inherited from class org.apache.directory.api.ldap.codec.decorators.ResultResponseRequestDecorator
getResultResponse, hasResponse
 
Methods inherited from class org.apache.directory.api.ldap.codec.api.MessageDecorator
get, getCodecService, getControl, getControls, getControlsLength, getCurrentControl, getDecorated, getDecorator, getMessageId, getMessageLength, getType, hasControl, put, setControlsLength, setMessageLength, toString
 
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.model.message.SingleReplyRequest
getResponseType
 
Methods inherited from interface org.apache.directory.api.ldap.model.message.ResultResponseRequest
getResultResponse
 
Methods inherited from interface org.apache.directory.api.ldap.model.message.Request
hasResponse
 
Methods inherited from interface org.apache.directory.api.ldap.model.message.Message
get, getControl, getControls, getMessageId, getType, hasControl, put
 
Methods inherited from interface org.apache.directory.api.ldap.model.message.AbandonableRequest
abandon, addAbandonListener, isAbandoned
 

Constructor Detail

AddRequestDecorator

public AddRequestDecorator(LdapApiService codec,
                           AddRequest decoratedMessage)
Makes a AddRequest a MessageDecorator.

Parameters:
decoratedMessage - the decorated AddRequest
Method Detail

setAddRequestLength

public void setAddRequestLength(int addRequestLength)
Stores the encoded length for the AddRequest

Parameters:
addRequestLength - The encoded length

getAddRequestLength

public int getAddRequestLength()
Returns:
The encoded AddRequest's length

setEntryLength

public void setEntryLength(int entryLength)
Stores the encoded length for the Entry

Parameters:
entryLength - The encoded length

getEntryLength

public int getEntryLength()
Returns:
The encoded Entry's length

setAttributesLength

public void setAttributesLength(List<Integer> attributesLength)
Stores the encoded length for the attributes

Parameters:
attributesLength - The encoded length

getAttributesLength

public List<Integer> getAttributesLength()
Returns:
The encoded values length

setValuesLength

public void setValuesLength(List<Integer> valuesLength)
Stores the encoded length for the values

Parameters:
valuesLength - The encoded length

getValuesLength

public List<Integer> getValuesLength()
Returns:
The encoded values length

setMessageId

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

Specified by:
setMessageId in interface AddRequest
Specified by:
setMessageId in interface Message
Overrides:
setMessageId in class MessageDecorator<AddRequest>
Parameters:
messageId - The message Id
Returns:
A Message reference

addControl

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

Specified by:
addControl in interface AddRequest
Specified by:
addControl in interface Message
Overrides:
addControl in class MessageDecorator<AddRequest>
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 AddRequest addAllControls(Control[] controls)
                          throws MessageException
Adds an array of controls to this Message.

Specified by:
addAllControls in interface AddRequest
Specified by:
addAllControls in interface Message
Overrides:
addAllControls in class MessageDecorator<AddRequest>
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 AddRequest removeControl(Control control)
                         throws MessageException
Deletes a control removing it from this Message.

Specified by:
removeControl in interface AddRequest
Specified by:
removeControl in interface Message
Overrides:
removeControl in class MessageDecorator<AddRequest>
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.

getEntryDn

public Dn getEntryDn()
Gets the distinguished name of the entry to add.

Specified by:
getEntryDn in interface AddRequest
Returns:
the Dn of the added entry.

setEntryDn

public AddRequest setEntryDn(Dn entry)
Sets the distinguished name of the entry to add.

Specified by:
setEntryDn in interface AddRequest
Parameters:
entry - the Dn of the added entry.
Returns:
The AddRequest instance

getEntry

public Entry getEntry()
Gets the entry to add.

Specified by:
getEntry in interface AddRequest
Returns:
the added Entry

setEntry

public AddRequest setEntry(Entry entry)
Sets the Entry to add.

Specified by:
setEntry in interface AddRequest
Parameters:
entry - the added Entry
Returns:
The AddRequest instance

addAttributeType

public void addAttributeType(String type)
                      throws LdapException
Create a new attributeValue

Parameters:
type - The attribute's name (called 'type' in the grammar)
Throws:
LdapException

getCurrentAttributeType

public String getCurrentAttributeType()
Returns:
Returns the currentAttribute type.

addAttributeValue

public void addAttributeValue(String value)
                       throws LdapException
Add a new value to the current attribute

Parameters:
value - The value to add
Throws:
LdapException

addAttributeValue

public void addAttributeValue(Value<?> value)
                       throws LdapException
Add a new value to the current attribute

Parameters:
value - The value to add
Throws:
LdapException

addAttributeValue

public void addAttributeValue(byte[] value)
                       throws LdapException
Add a new value to the current attribute

Parameters:
value - The value to add
Throws:
LdapException

computeLength

public int computeLength()
Compute the AddRequest length AddRequest : 0x68 L1 | +--> 0x04 L2 entry +--> 0x30 L3 (attributes) | +--> 0x30 L4-1 (attribute) | | | +--> 0x04 L5-1 type | +--> 0x31 L6-1 (values) | | | +--> 0x04 L7-1-1 value | +--> ... | +--> 0x04 L7-1-n value | +--> 0x30 L4-2 (attribute) | | | +--> 0x04 L5-2 type | +--> 0x31 L6-2 (values) | | | +--> 0x04 L7-2-1 value | +--> ... | +--> 0x04 L7-2-n value | +--> ... | +--> 0x30 L4-m (attribute) | +--> 0x04 L5-m type +--> 0x31 L6-m (values) | +--> 0x04 L7-m-1 value +--> ... +--> 0x04 L7-m-n value

Specified by:
computeLength in interface Decorator<AddRequest>
Returns:
The object's computed length

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Encode the AddRequest message to a PDU. AddRequest : 0x68 LL 0x04 LL entry 0x30 LL attributesList 0x30 LL attributeList 0x04 LL attributeDescription 0x31 LL attributeValues 0x04 LL attributeValue ... 0x04 LL attributeValue ... 0x30 LL attributeList 0x04 LL attributeDescription 0x31 LL attributeValue 0x04 LL attributeValue ... 0x04 LL attributeValue

Specified by:
encode in interface Decorator<AddRequest>
Parameters:
buffer - The buffer where to put the PDU
Returns:
The PDU.
Throws:
EncoderException - if the buffer can't be encoded


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