org.apache.directory.shared.asn1
Class AbstractAsn1Object

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
All Implemented Interfaces:
Asn1Object
Direct Known Subclasses:
CascadeControlCodec, Control, EntryChangeControlCodec, Filter, GracefulAction, LdapAuthentication, LdapMessage, LdapResult, ManageDsaITControlCodec, PSearchControlCodec, StoredProcedure, SubEntryControlCodec

public abstract class AbstractAsn1Object
extends java.lang.Object
implements Asn1Object

An abstract class which implements basic TLV operations.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Field Summary
protected  AbstractAsn1Object parent
          The encapsulating Object
 
Constructor Summary
protected AbstractAsn1Object()
          Default constructor.
protected AbstractAsn1Object(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.
 java.nio.ByteBuffer encode(java.nio.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.
 AbstractAsn1Object getParent()
          Get the parent
 int getTlvId()
           
 void setCurrentLength(int currentLength)
          Set the current length
 void setExpectedLength(int expectedLength)
          Set the expected length
 void setParent(AbstractAsn1Object 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 AbstractAsn1Object parent
The encapsulating Object

Constructor Detail

AbstractAsn1Object

protected AbstractAsn1Object(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.

AbstractAsn1Object

protected AbstractAsn1Object()
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.

Specified by:
getCurrentLength in interface Asn1Object
Returns:
The current object's length

computeLength

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

Specified by:
computeLength in interface Asn1Object
Returns:
The object's computed length

encode

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

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

getExpectedLength

public int getExpectedLength()
Get the expected object length.

Specified by:
getExpectedLength in interface Asn1Object
Returns:
The expected object's length

addLength

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

Specified by:
addLength in interface Asn1Object
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

Specified by:
setExpectedLength in interface Asn1Object
Parameters:
expectedLength - The expectedLength to set.

setCurrentLength

public void setCurrentLength(int currentLength)
Set the current length

Specified by:
setCurrentLength in interface Asn1Object
Parameters:
currentLength - The currentLength to set.

getParent

public AbstractAsn1Object getParent()
Get the parent

Specified by:
getParent in interface Asn1Object
Returns:
Returns the parent.

setParent

public void setParent(AbstractAsn1Object parent)
Set the parent

Parameters:
parent - The parent to set.

getTlvId

public int getTlvId()
Returns:
The TLV identifier associated with this object


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