org.apache.directory.api.asn1.ber
Class Asn1Decoder

java.lang.Object
  extended by org.apache.directory.api.asn1.ber.Asn1Decoder
All Implemented Interfaces:
TLVBerDecoderMBean

public class Asn1Decoder
extends Object
implements TLVBerDecoderMBean

A BER TLV Tag component decoder. This decoder instantiate a Tag. The tag won't be implementations should not copy the handle to the Tag object delivered but should copy the data if they need it over the long term.

Author:
Apache Directory Project

Constructor Summary
Asn1Decoder()
          A public constructor of an Asn1 Decoder.
 
Method Summary
 void allowIndefiniteLength()
          Allow indefinite length.
 void decode(ByteBuffer stream, Asn1Container container)
          The decoder main function.
 void disallowIndefiniteLength()
          Disallow indefinite length.
 int getMaxLengthLength()
          Get the actual maximum number of bytes that can be used to encode the Length
 int getMaxTagLength()
          Get the actual maximum number of bytes that can be used to encode the Tag
 boolean isIndefiniteLengthAllowed()
          Tell if indefinite length form could be used for Length
 void setMaxLengthLength(int maxLengthLength)
          Set the number of bytes that can be used to encode the Value length, including the first byte.
 void setMaxTagLength(int maxTagLength)
          Set the maximum number of bytes that should be used to encode a Tag label, including the first byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Asn1Decoder

public Asn1Decoder()
A public constructor of an Asn1 Decoder.

Method Detail

decode

public void decode(ByteBuffer stream,
                   Asn1Container container)
            throws org.apache.directory.api.asn1.DecoderException
The decoder main function. This is where we read bytes from the stream and go through the automaton. It's an inifnite loop which stop when no more bytes are to be read. It can occurs if the ByteBuffer is exhausted or if the PDU has been fully decoded.

Parameters:
stream - The ByteBuffer containing the PDU to decode
container - The container that store the state, the result and other elements.
Throws:
org.apache.directory.api.asn1.DecoderException - Thrown if anything went wrong!

getMaxLengthLength

public int getMaxLengthLength()
Get the actual maximum number of bytes that can be used to encode the Length

Specified by:
getMaxLengthLength in interface TLVBerDecoderMBean
Returns:
The maximum bytes of the Length

getMaxTagLength

public int getMaxTagLength()
Get the actual maximum number of bytes that can be used to encode the Tag

Specified by:
getMaxTagLength in interface TLVBerDecoderMBean
Returns:
The maximum length of the Tag

disallowIndefiniteLength

public void disallowIndefiniteLength()
Disallow indefinite length.

Specified by:
disallowIndefiniteLength in interface TLVBerDecoderMBean

allowIndefiniteLength

public void allowIndefiniteLength()
Allow indefinite length.

Specified by:
allowIndefiniteLength in interface TLVBerDecoderMBean

isIndefiniteLengthAllowed

public boolean isIndefiniteLengthAllowed()
Tell if indefinite length form could be used for Length

Specified by:
isIndefiniteLengthAllowed in interface TLVBerDecoderMBean
Returns:
true if the Indefinite form is allowed

setMaxLengthLength

public void setMaxLengthLength(int maxLengthLength)
                        throws org.apache.directory.api.asn1.DecoderException
Set the number of bytes that can be used to encode the Value length, including the first byte. Max is 127 if the Length use a definite form, default is 1

Specified by:
setMaxLengthLength in interface TLVBerDecoderMBean
Parameters:
maxLengthLength - the number of byte to use
Throws:
org.apache.directory.api.asn1.DecoderException - Thrown if the indefinite length is allowed or if the length's Length is above 126 bytes

setMaxTagLength

public void setMaxTagLength(int maxTagLength)
Set the maximum number of bytes that should be used to encode a Tag label, including the first byte. Default is 1, no maximum

Specified by:
setMaxTagLength in interface TLVBerDecoderMBean
Parameters:
maxTagLength - The length to use


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