org.apache.directory.shared.asn1
Class Asn1Object

java.lang.Object
  extended by org.apache.directory.shared.asn1.Asn1Object
Direct Known Subclasses:
Control, EntryChangeControl, Filter, GracefulAction, LdapAuthentication, LdapMessage, LdapResult, ManageDsaITControl, PSearchControl, SubEntryControl

public abstract class Asn1Object
extends Object

An abstract class which implements basic TLV operations.

Author:
Apache Directory Project

Field Summary
protected  Asn1Object parent
          The encapsulating Object
 
Constructor Summary
protected Asn1Object()
          Default constructor.
protected Asn1Object(int tlvId)
          Constructor associated with a TLV indentifier.
 
Method Summary
 void addLength(int length)
          Add a length to the object
abstract  int computeLength()
          Compute the object length, which is the sum of all inner length.
 ByteBuffer encode(ByteBuffer buffer)
          Encode the object to a PDU.
 int getCurrentLength()
          Get the current object length, which is the sum of all inner length already decoded.
 int getExpectedLength()
          Get the expected object length.
 Asn1Object getParent()
          Get the parent
 int getTlvId()
           
 void setCurrentLength(int currentLength)
          Set the current length
 void setExpectedLength(int expectedLength)
          Set the expected length
 void setParent(Asn1Object parent)
          Set the parent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected transient Asn1Object parent
The encapsulating Object

Constructor Detail

Asn1Object

protected Asn1Object(int tlvId)
Constructor associated with a TLV indentifier. Used when decoded a TLV, we create an association between the decode Asn1Object and the TLV which is the encoded form.

Parameters:
tlvId - The TLV Id.

Asn1Object

protected Asn1Object()
Default constructor. The TLV Id is set to -1. This constructor is called when an Asn1Object is created to be encoded, not decoded.

Method Detail

getCurrentLength

public int getCurrentLength()
Get the current object length, which is the sum of all inner length already decoded.

Returns:
The current object's length

computeLength

public abstract int computeLength()
Compute the object length, which is the sum of all inner length.

Returns:
The object's computed length

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Encode the object to a PDU.

Parameters:
buffer - The buffer where to put the PDU
Returns:
The PDU.
Throws:
EncoderException

getExpectedLength

public int getExpectedLength()
Get the expected object length.

Returns:
The expected object's length

addLength

public void addLength(int length)
               throws DecoderException
Add a length to the object

Parameters:
length - The length to add.
Throws:
DecoderException - Thrown if the current length exceed the expected length

setExpectedLength

public void setExpectedLength(int expectedLength)
Set the expected length

Parameters:
expectedLength - The expectedLength to set.

setCurrentLength

public void setCurrentLength(int currentLength)
Set the current length

Parameters:
currentLength - The currentLength to set.

getParent

public Asn1Object getParent()
Get the parent

Returns:
Returns the parent.

setParent

public void setParent(Asn1Object parent)
Set the parent

Parameters:
parent - The parent to set.

getTlvId

public int getTlvId()


Copyright © 2004-2012. All Rights Reserved.