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

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.ldap.codec.controls.AbstractControl
All Implemented Interfaces:
Asn1Object, CodecControl, Control
Direct Known Subclasses:
CascadeControl, ControlImpl, EntryChangeControl, ManageDsaITControl, PagedResultsControl, PersistentSearchControl, SubentriesControl, SyncDoneValueControl, SyncInfoValueControl, SyncRequestValueControl, SyncStateValueControl

public abstract class AbstractControl
extends AbstractAsn1Object
implements Control, CodecControl

A Asn1Object to store a Control.

Version:
$Rev: 912399 $, $Date: 2010-02-21 21:52:31 +0100 (Dim, 21 fév 2010) $,
Author:
Apache Directory Project

Field Summary
protected  ControlDecoder decoder
           
protected  byte[] value
          Optional control value
protected  int valueLength
          The encoded value length
 
Fields inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
parent
 
Constructor Summary
AbstractControl(String oid)
          Default constructor.
 
Method Summary
 int computeLength()
          Compute the Control length
 int computeLength(int valueLength)
          
 ByteBuffer encode(ByteBuffer buffer)
          Generate the PDU which contains the Control.
 ControlDecoder getDecoder()
          Get the associated decoder
 String getOid()
          Get the OID
 byte[] getValue()
          Get the control value
 boolean hasValue()
          Tells if the Control has a value or not
 boolean isCritical()
          Get the criticality
 void setCritical(boolean criticality)
          Set the criticality
 void setValue(byte[] value)
          Set the encoded control value
 String toString()
          Return a String representing a Control
 
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
 

Field Detail

value

protected byte[] value
Optional control value


valueLength

protected int valueLength
The encoded value length


decoder

protected ControlDecoder decoder
Constructor Detail

AbstractControl

public AbstractControl(String oid)
Default constructor.

Method Detail

getOid

public String getOid()
Get the OID

Specified by:
getOid in interface Control
Returns:
A string which represent the control oid

getValue

public byte[] getValue()
Get the control value

Specified by:
getValue in interface Control
Returns:
The control value

setValue

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

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

isCritical

public boolean isCritical()
Get the criticality

Specified by:
isCritical in interface Control
Returns:
true if the criticality flag is true.

setCritical

public void setCritical(boolean criticality)
Set the criticality

Specified by:
setCritical in interface Control
Parameters:
criticality - The criticality value

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
Specified by:
computeLength in class AbstractAsn1Object

computeLength

public int computeLength(int valueLength)


encode

public ByteBuffer encode(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 AbstractAsn1Object
Parameters:
buffer - The encoded PDU
Returns:
A ByteBuffer that contaons the PDU
Throws:
EncoderException - If anything goes wrong.

hasValue

public boolean hasValue()
Tells if the Control has a value or not

Specified by:
hasValue in interface Control
Returns:
true if th Control has a value, even containing no bytes.

getDecoder

public ControlDecoder getDecoder()
Description copied from interface: CodecControl
Get the associated decoder

Specified by:
getDecoder in interface CodecControl
Returns:
The Control decoder

toString

public String toString()
Return a String representing a Control

Overrides:
toString in class Object


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