org.apache.directory.shared.ldap.codec.controls
Class ControlImpl

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.ldap.codec.controls.AbstractControl
          extended by org.apache.directory.shared.ldap.codec.controls.ControlImpl
All Implemented Interfaces:
Asn1Object, CodecControl, Control

public class ControlImpl
extends AbstractControl

A genericcodec Control.

Version:
$Rev: 764131 $, $Date: 2009-04-11 03:03:00 +0200 (Sat, 11 Apr 2009) $,
Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.codec.controls.AbstractControl
decoder, value, valueLength
 
Fields inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
parent
 
Constructor Summary
ControlImpl(java.lang.String oid)
          Default constructor.
 
Method Summary
 int computeLength()
          Compute the Control length
 java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
          Generate the PDU which contains the Control.
 byte[] getValue()
          Get the raw control encoded bytes
 void setValue(byte[] value)
          Set the encoded control value
 
Methods inherited from class org.apache.directory.shared.ldap.codec.controls.AbstractControl
computeLength, getDecoder, getOid, hasValue, isCritical, setCritical, toString
 
Methods inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
addLength, 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

ControlImpl

public ControlImpl(java.lang.String oid)
Default constructor.

Method Detail

setValue

public void setValue(byte[] value)
Set the encoded control value

Specified by:
setValue in interface Control
Overrides:
setValue in class AbstractControl
Parameters:
encodedValue - The encoded control value to store

getValue

public byte[] getValue()
Get the raw control encoded bytes

Specified by:
getValue in interface Control
Overrides:
getValue in class AbstractControl
Returns:
the encoded bytes for the control

computeLength

public int computeLength()
Compute the Control length
 
 Control :
 
 0x30 L1
  |
  +--> 0x04 L2 controlType
 [+--> 0x01 0x01 criticality]
 [+--> 0x04 L3 controlValue] 
 
 Control length = Length(0x30) + length(L1) 
                  + Length(0x04) + Length(L2) + L2
                  [+ Length(0x01) + 1 + 1]
                  [+ Length(0x04) + Length(L3) + L3]
 

Specified by:
computeLength in interface Asn1Object
Specified by:
computeLength in interface CodecControl
Overrides:
computeLength in class AbstractControl

encode

public java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
                           throws EncoderException
Generate the PDU which contains the Control.
 
 Control : 
 
 0x30 LL
   0x04 LL type 
   [0x01 0x01 criticality]
   [0x04 LL value]
 

Specified by:
encode in interface Asn1Object
Specified by:
encode in interface CodecControl
Overrides:
encode in class AbstractControl
Parameters:
buffer - The encoded PDU
Returns:
A ByteBuffer that contaons the PDU
Throws:
EncoderException - If anything goes wrong.


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.