org.apache.asn1.ber
Class Length

java.lang.Object
  extended byorg.apache.asn1.ber.Length

public class Length
extends java.lang.Object

The length component of a BER TLV Tuple.

Version:
$Rev: 157644 $
Author:
Apache Directory Project

Field Summary
private  java.nio.ByteBuffer buf
          a byte buffer used to collect the arriving length octets
static int END_MASK
          the end long form terminate bit flag mask
static int INDEFINITE
          used to mark length as indefinite
private  boolean isFixated
          whether or not this length has been fixated
private  int numOctets
          the number of octets needed to complete this length component
static int UNDEFINED
          used to mark length as undefined
private  int value
          the value for this tlv length
 
Constructor Summary
Length()
           
 
Method Summary
(package private)  void add(byte octet)
          Adds an octet to this Length component and as a side effect fixates the Length component if all the required length data has arrived.
(package private)  void clear()
          Clears this tag's data of all bytes and values calculated so all is as it was when this instance was created.
(package private)  void fixate()
          Fixates the data within this Length calculating all the derived properties from the existing set of octets.
 int getLength()
          Gets the length of the value.
static int getLength(java.nio.ByteBuffer octets)
          Decodes the length of a value for a tlv using the Length field bytes.
 boolean isFixated()
          Checks to see if the length has been fixated.
 int size()
          Gets the number of octets currently in this Length component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEFINITE

public static final int INDEFINITE
used to mark length as indefinite

See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
used to mark length as undefined

See Also:
Constant Field Values

END_MASK

public static final int END_MASK
the end long form terminate bit flag mask

See Also:
Constant Field Values

value

private int value
the value for this tlv length


numOctets

private int numOctets
the number of octets needed to complete this length component


isFixated

private boolean isFixated
whether or not this length has been fixated


buf

private final java.nio.ByteBuffer buf
a byte buffer used to collect the arriving length octets

Constructor Detail

Length

public Length()
Method Detail

isFixated

public boolean isFixated()
Checks to see if the length has been fixated.

Returns:
true if it is fixated, false if not

clear

void clear()
Clears this tag's data of all bytes and values calculated so all is as it was when this instance was created.


fixate

void fixate()
      throws org.apache.asn1.codec.DecoderException
Fixates the data within this Length calculating all the derived properties from the existing set of octets. While fixated octets cannot be added.

Throws:
org.apache.asn1.codec.DecoderException - if this Length is invalid

add

void add(byte octet)
   throws org.apache.asn1.codec.DecoderException
Adds an octet to this Length component and as a side effect fixates the Length component if all the required length data has arrived.

Parameters:
octet - the 8 bit byte to add
Throws:
org.apache.asn1.codec.DecoderException

getLength

public int getLength()
Gets the length of the value.

Returns:
the length of the value

size

public int size()
Gets the number of octets currently in this Length component.

Returns:
the number of octets currently within this Length component

getLength

public static int getLength(java.nio.ByteBuffer octets)
                     throws org.apache.asn1.codec.DecoderException
Decodes the length of a value for a tlv using the Length field bytes.

Parameters:
octets - the length field bytes in the TLV
Returns:
the length of the TLV
Throws:
org.apache.asn1.codec.DecoderException - if the precision cannot hold the number


Copyright © 2004-2006 . All Rights Reserved.