org.apache.asn1new.ber.tlv
Class Length

java.lang.Object
  extended by org.apache.asn1new.ber.tlv.Length
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Length
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The Length part of a TLV. We are not dealing with indefinite length.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
private  int currentLength
          Stores the number of bytes already read for a long Length form
private  boolean definiteForm
          A flag used with definite forms length.
private  int expectedLength
          If the Length is in a long form, this variable store the expected number of bytes to be read to obtain the length
private  int length
          The length of the following value
static int LENGTH_EXTENSION_RESERVED
          Value of the reserved extension
static int LENGTH_LONG_FORM
          A mask to get the Length form
static long serialVersionUID
           
static int SHORT_MASK
          A mask to get the long form value
private  int size
          The size of the Length part.
 
Constructor Summary
Length()
          Creates a new object.
 
Method Summary
 java.lang.Object clone()
          Clone the object
static byte[] getBytes(int length)
          Utility function that return a byte array representing the length
 int getCurrentLength()
          Get the current number of bytes read
 int getExpectedLength()
          Get the expected length
 int getLength()
          Get the Value length
static int getNbBytes(int length)
          Utility function that return the number of bytes necessary to store the length
 int getSize()
          Get the size of the Length element
 void incCurrentLength()
          Increment the Length being read
 void incSize()
          Increment the size of the Length element.
 boolean isDefiniteForm()
          Get the length's type
 void reset()
          Reset the Length object
 void setCurrentLength(int currentLength)
          Set the current length of the Length
 void setDefiniteForm(boolean definiteForm)
          Set the length's form
 void setExpectedLength(int expectedLength)
          Set the expected long form length
 void setLength(int length)
          Set the length of the Value part
 void setSize(int size)
          Set the Length's size
 java.lang.String toString()
          Return a String representing the Length
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
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

SHORT_MASK

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

See Also:
Constant Field Values

length

private int length
The length of the following value


size

private int size
The size of the Length part.


expectedLength

private transient int expectedLength
If the Length is in a long form, this variable store the expected number of bytes to be read to obtain the length


currentLength

private int currentLength
Stores the number of bytes already read for a long Length form


definiteForm

private boolean definiteForm
A flag used with definite forms length.

Constructor Detail

Length

public Length()
Creates a new object.

Method Detail

reset

public void reset()
Reset the Length object


getLength

public int getLength()
Get the Value length

Returns:
Returns the length of the value part.

setLength

public void setLength(int length)
Set the length of the Value part

Parameters:
length - The length of the Value part.

getCurrentLength

public int getCurrentLength()
Get the current number of bytes read

Returns:
Returns the currentLength.

setCurrentLength

public void setCurrentLength(int currentLength)
Set the current length of the Length

Parameters:
currentLength - The currentLength to set.

incCurrentLength

public void incCurrentLength()
Increment the Length being read


getExpectedLength

public int getExpectedLength()
Get the expected length

Returns:
Returns the expected Length of the long form Length.

setExpectedLength

public void setExpectedLength(int expectedLength)
Set the expected long form length

Parameters:
expectedLength - The long form expected length to set.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone the object

Overrides:
clone in class java.lang.Object
Returns:
A deep copy of the Length
Throws:
java.lang.CloneNotSupportedException - Thrown if any problem occurs.

getSize

public int getSize()
Get the size of the Length element

Returns:
Returns the size of the Length element.

incSize

public void incSize()
Increment the size of the Length element.


toString

public java.lang.String toString()
Return a String representing the Length

Overrides:
toString in class java.lang.Object
Returns:
The length

setSize

public void setSize(int size)
Set the Length's size

Parameters:
size - The lengthSize to set.

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.

isDefiniteForm

public boolean isDefiniteForm()
Get the length's type

Returns:
Returns the definiteForm flag.

setDefiniteForm

public void setDefiniteForm(boolean definiteForm)
Set the length's form

Parameters:
definiteForm - The definiteForm flag to set.


Copyright © 2005-2009 . All Rights Reserved.