org.apache.directory.shared.asn1.ber.tlv
Class TLV

java.lang.Object
  extended by org.apache.directory.shared.asn1.ber.tlv.TLV

public class TLV
extends Object

This class is used to store Tag, Length and Value decoded from a PDU.

Author:
Apache Directory Project

Field Summary
static byte CONSTRUCTED_FLAG
          tag flag for the primitive/constructed bit - 0010 0000 - 0x20
static int LENGTH_EXTENSION_RESERVED
          Value of the reserved extension
static int LENGTH_LONG_FORM
          A mask to get the Length form
static int LENGTH_SHORT_MASK
          A mask to get the long form value
static int SHORT_MASK
          tag mask for the short tag format - 0001 1111 - 0x1F
static byte TYPE_CLASS_MASK
          mask to get the type class value
static byte TYPE_CLASS_UNIVERSAL
          value for the universal type class
 
Constructor Summary
TLV(int id)
          Creates a new TLV object.
 
Method Summary
static byte[] getBytes(int length)
          Utility function that return a byte array representing the length
 int getExpectedLength()
          Get the TLV expected length.
 int getId()
           
 int getLength()
           
 int getLengthBytesRead()
           
 int getLengthNbBytes()
           
static int getNbBytes(int length)
          Utility function that return the number of bytes necessary to store the length
 TLV getParent()
           
 int getSize()
          The TLV size is calculated by adding the Tag's size, the Length's size and the Value's length, if any.
 byte getTag()
           
 Value getValue()
           
 void incLengthBytesRead()
           
 boolean isConstructed()
          Checks to see if the current tlv's tag is constructed.
static boolean isConstructed(byte tag)
          Checks to see if the tag is constructed.
static boolean isPrimitive(byte tag)
          Checks to see if the tag represented by this Tag is primitive or constructed.
static boolean isUniversal(byte tag)
          Tells if the tag is Universal or not
 void reset()
          Reset the TLV, so it can be reused for the next PDU decoding.
 void setExpectedLength(int expectedLength)
          Set the new expected length of the current TLV.
 void setLength(int length)
           
 void setLengthBytesRead(int lengthBytesRead)
           
 void setLengthNbBytes(int lengthNbBytes)
           
 void setParent(TLV parent)
           
 void setTag(byte tag)
           
 String toString()
          Get a String representation of the TLV
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONSTRUCTED_FLAG

public static final byte CONSTRUCTED_FLAG
tag flag for the primitive/constructed bit - 0010 0000 - 0x20

See Also:
Constant Field Values

TYPE_CLASS_MASK

public static final byte TYPE_CLASS_MASK
mask to get the type class value

See Also:
Constant Field Values

TYPE_CLASS_UNIVERSAL

public static final byte TYPE_CLASS_UNIVERSAL
value for the universal type class

See Also:
Constant Field Values

SHORT_MASK

public static final int SHORT_MASK
tag mask for the short tag format - 0001 1111 - 0x1F

See Also:
Constant Field Values

LENGTH_LONG_FORM

public static final transient int LENGTH_LONG_FORM
A mask to get the Length form

See Also:
Constant Field Values

LENGTH_EXTENSION_RESERVED

public static final transient int LENGTH_EXTENSION_RESERVED
Value of the reserved extension

See Also:
Constant Field Values

LENGTH_SHORT_MASK

public static final transient int LENGTH_SHORT_MASK
A mask to get the long form value

See Also:
Constant Field Values
Constructor Detail

TLV

public TLV(int id)
Creates a new TLV object.

Method Detail

isConstructed

public static boolean isConstructed(byte tag)
Checks to see if the tag is constructed.

Returns:
true if constructed, false if primitive

isConstructed

public boolean isConstructed()
Checks to see if the current tlv's tag is constructed.

Returns:
true if constructed, false if primitive

isPrimitive

public static boolean isPrimitive(byte tag)
Checks to see if the tag represented by this Tag is primitive or constructed.

Returns:
true if it is primitive, false if it is constructed

isUniversal

public static boolean isUniversal(byte tag)
Tells if the tag is Universal or not

Returns:
true if it is primitive, false if it is constructed

reset

public void reset()
Reset the TLV, so it can be reused for the next PDU decoding.


getTag

public byte getTag()
Returns:
Returns the tag.

setTag

public void setTag(byte tag)

getValue

public Value getValue()
Returns:
Returns the value.

toString

public String toString()
Get a String representation of the TLV

Overrides:
toString in class Object
Returns:
A String

getSize

public int getSize()
The TLV size is calculated by adding the Tag's size, the Length's size and the Value's length, if any.

Returns:
Returns the size of the TLV.

getNbBytes

public static int getNbBytes(int length)
Utility function that return the number of bytes necessary to store the length

Parameters:
length - The length to store in a byte array
Returns:
The number of bytes necessary to store the length.

getBytes

public static byte[] getBytes(int length)
Utility function that return a byte array representing the length

Parameters:
length - The length to store in a byte array
Returns:
The byte array representing the length.

getParent

public TLV getParent()
Returns:
Returns the parent.

setParent

public void setParent(TLV parent)
Parameters:
parent - The parent to set.

getExpectedLength

public int getExpectedLength()
Get the TLV expected length.

Returns:
Returns the expectedLength.

setExpectedLength

public void setExpectedLength(int expectedLength)
Set the new expected length of the current TLV.

Parameters:
expectedLength - The expectedLength to set.

getLengthNbBytes

public int getLengthNbBytes()

setLengthNbBytes

public void setLengthNbBytes(int lengthNbBytes)

getLength

public int getLength()

setLength

public void setLength(int length)

getLengthBytesRead

public int getLengthBytesRead()

setLengthBytesRead

public void setLengthBytesRead(int lengthBytesRead)

incLengthBytesRead

public void incLengthBytesRead()

getId

public int getId()


Copyright © 2004-2012. All Rights Reserved.