Class Asn1Decoder
- java.lang.Object
-
- org.apache.directory.api.asn1.ber.Asn1Decoder
-
- All Implemented Interfaces:
TLVBerDecoderMBean
- Direct Known Subclasses:
CancelDecoder
,CertGenerationDecoder
,EndTransactionRequestDecoder
,EndTransactionResponseDecoder
,GracefulDisconnectDecoder
,GracefulShutdownDecoder
,PasswordModifyRequestDecoder
,PasswordModifyResponseDecoder
,StoredProcedureDecoder
,WhoAmIResponseDecoder
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
Constructors Constructor Description Asn1Decoder()
A public constructor of an Asn1 Decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 Lengthint
getMaxTagLength()
Get the actual maximum number of bytes that can be used to encode the Tagboolean
isIndefiniteLengthAllowed()
Tell if indefinite length form could be used for Lengthvoid
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.
-
-
-
Constructor Detail
-
Asn1Decoder
public Asn1Decoder()
A public constructor of an Asn1 Decoder.
-
-
Method Detail
-
decode
public void decode(ByteBuffer stream, Asn1Container container) throws 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 decodecontainer
- The container that store the state, the result and other elements.- Throws:
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 interfaceTLVBerDecoderMBean
- 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 interfaceTLVBerDecoderMBean
- Returns:
- The maximum length of the Tag
-
disallowIndefiniteLength
public void disallowIndefiniteLength()
Disallow indefinite length.- Specified by:
disallowIndefiniteLength
in interfaceTLVBerDecoderMBean
-
allowIndefiniteLength
public void allowIndefiniteLength()
Allow indefinite length.- Specified by:
allowIndefiniteLength
in interfaceTLVBerDecoderMBean
-
isIndefiniteLengthAllowed
public boolean isIndefiniteLengthAllowed()
Tell if indefinite length form could be used for Length- Specified by:
isIndefiniteLengthAllowed
in interfaceTLVBerDecoderMBean
- Returns:
true
if the Indefinite form is allowed
-
setMaxLengthLength
public void setMaxLengthLength(int maxLengthLength) throws 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 interfaceTLVBerDecoderMBean
- Parameters:
maxLengthLength
- the number of byte to use- Throws:
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 interfaceTLVBerDecoderMBean
- Parameters:
maxTagLength
- The length to use
-
-