org.apache.directory.api.asn1
Class AbstractAsn1Object

java.lang.Object
  extended by org.apache.directory.api.asn1.AbstractAsn1Object
All Implemented Interfaces:
Asn1Object

public abstract class AbstractAsn1Object
extends Object
implements Asn1Object

An abstract class which implements basic TLV operations.

Author:
Apache Directory Project

Constructor Summary
protected AbstractAsn1Object()
          Default constructor.
protected AbstractAsn1Object(int tlvId)
          Constructor associated with a TLV identifier.
 
Method Summary
 void addLength(int length)
          Add a length to the object
 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.
 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)
          Sets the parent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.api.asn1.Asn1Object
computeLength
 

Constructor Detail

AbstractAsn1Object

protected AbstractAsn1Object(int tlvId)
Constructor associated with a TLV identifier. 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

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

encode

public ByteBuffer encode(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 encoded PDU.
Throws:
EncoderException - if the buffer can't be encoded

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

setCurrentLength

public void setCurrentLength(int currentLength)
Set the current length

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

getExpectedLength

public int getExpectedLength()
Get the expected object length.

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

setExpectedLength

public void setExpectedLength(int expectedLength)
Set the expected length

Specified by:
setExpectedLength in interface Asn1Object
Parameters:
expectedLength - The expectedLength 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)
Sets the parent

Parameters:
parent - The parent to set.

getTlvId

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


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.