org.apache.directory.shared.ldap.codec.modify
Class ModifyRequestCodec

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.ldap.codec.LdapMessageCodec
          extended by org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec
All Implemented Interfaces:
Asn1Object

public class ModifyRequestCodec
extends LdapMessageCodec

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

Version:
$Rev: 918756 $, $Date: 2010-03-04 00:05:29 +0100 (Thu, 04 Mar 2010) $,
Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.codec.LdapMessageCodec
ldapMessageLength
 
Fields inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
parent
 
Constructor Summary
ModifyRequestCodec()
          Creates a new ModifyRequest object.
 
Method Summary
 void addAttributeTypeAndValues(java.lang.String type)
          Add a new attributeTypeAndValue
 void addAttributeValue(byte[] value)
          Add a new value to the current attribute
 void addAttributeValue(java.lang.String value)
          Add a new value to the current attribute
 void addAttributeValue(Value<?> value)
          Add a new value to the current attribute
 void addModification(int operation)
          Add a new modification to the list
protected  int computeLengthProtocolOp()
          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 | +--> ...
protected  void encodeProtocolOp(java.nio.ByteBuffer buffer)
          Encode the ModifyRequest message to a PDU.
 java.lang.String getCurrentAttributeType()
          Return the current attribute's type
 int getCurrentOperation()
          Get the current operation
 MessageTypeEnum getMessageType()
          Get the message type
 java.lang.String getMessageTypeName()
          Get the message type Name
 java.util.List<Modification> getModifications()
          Get the entry's attributes
 DN getObject()
          Get the modification's DN
 void initModifications()
          Initialize the ArrayList for modifications.
 void setCurrentOperation(int currentOperation)
          Store the current operation
 void setCurrentOperation(ModificationOperation currentOperation)
          Store the current operation
 void setModifications(java.util.List<Modification> modifications)
          sets the modifications
 void setObject(DN object)
          Set the modification DN.
 java.lang.String toString()
          Get a String representation of a ModifyRequest
 
Methods inherited from class org.apache.directory.shared.ldap.codec.LdapMessageCodec
addControl, addControls, computeLength, encode, getCodecControl, getControls, getControls, getCurrentControl, getMessageId, initControls, setMessageId, toString
 
Methods inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
addLength, encode, getCurrentLength, getExpectedLength, getParent, getTlvId, setCurrentLength, setExpectedLength, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModifyRequestCodec

public ModifyRequestCodec()
Creates a new ModifyRequest object.

Method Detail

getMessageType

public MessageTypeEnum getMessageType()
Get the message type

Specified by:
getMessageType in class LdapMessageCodec
Returns:
Returns the type.

getMessageTypeName

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

Specified by:
getMessageTypeName in class LdapMessageCodec
Returns:
The message type name

initModifications

public void initModifications()
Initialize the ArrayList for modifications.


getModifications

public java.util.List<Modification> getModifications()
Get the entry's attributes

Returns:
Returns the modifications.

addModification

public void addModification(int operation)
Add a new modification to the list

Parameters:
operation - The type of operation (add, delete or replace)

addAttributeTypeAndValues

public void addAttributeTypeAndValues(java.lang.String type)
Add a new attributeTypeAndValue

Parameters:
type - The attribute's name

addAttributeValue

public void addAttributeValue(java.lang.String value)
Add a new value to the current attribute

Parameters:
value - The value to add

addAttributeValue

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

Parameters:
value - The value to add

addAttributeValue

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

Parameters:
value - The value to add

getCurrentAttributeType

public java.lang.String getCurrentAttributeType()
Return the current attribute's type


getObject

public DN getObject()
Get the modification's DN

Returns:
Returns the object.

setObject

public void setObject(DN object)
Set the modification DN.

Parameters:
object - The DN to set.

getCurrentOperation

public int getCurrentOperation()
Get the current operation

Returns:
Returns the currentOperation.

setCurrentOperation

public void setCurrentOperation(int currentOperation)
Store the current operation

Parameters:
currentOperation - The currentOperation to set.

setCurrentOperation

public void setCurrentOperation(ModificationOperation currentOperation)
Store the current operation

Parameters:
currentOperation - The currentOperation to set.

setModifications

public void setModifications(java.util.List<Modification> modifications)
sets the modifications

Parameters:
modifications - the list of modifications

computeLengthProtocolOp

protected int computeLengthProtocolOp()
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

Specified by:
computeLengthProtocolOp in class LdapMessageCodec

encodeProtocolOp

protected void encodeProtocolOp(java.nio.ByteBuffer buffer)
                         throws EncoderException
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
 

Specified by:
encodeProtocolOp in class LdapMessageCodec
Parameters:
buffer - The buffer where to put the PDU
Throws:
EncoderException

toString

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

Overrides:
toString in class java.lang.Object
Returns:
A ModifyRequest String


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.