Class AbstractContainer
java.lang.Object
org.apache.directory.api.asn1.ber.AbstractContainer
- All Implemented Interfaces:
Asn1Container
This class is the abstract container used to store the current state of a PDU
being decoded. It also stores the grammars used to decode the PDU, and all
the informations needed to decode a PDU.
- Author:
- Apache Directory Project
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance of AbstractContainer with a starting state.protectedAbstractContainer(ByteBuffer stream) Creates a new instance of AbstractContainer with a starting state. -
Method Summary
Modifier and TypeMethodDescriptionvoidclean()Clean the container for the next usage.Gets the currentTLVintGet the size of the decoded messageGrammar<? extends Asn1Container> Gets the grammarintGet the maximum PDU size allowedintGets a new TLV idGet the parent's TLVgetState()Gets the current grammar stateGets the current stream containing the bytes to decodeintgetTlvId()Gets the current TLV idEnum<?> Gets the transitionvoidincrementDecodedBytes(int nb) Increment the decodedBytes by the latest received buffer's size.booleanTells if the decoding should be done immediately or if the container should gather the data beforebooleanChecks that we can have a end state after this transitionvoidrewind()Move backward in the stream to the first byte for a given TLV.voidsetCurrentTLV(TLV currentTLV) Sets the current TLVvoidsetDecodedBytes(int decodedBytes) Set the size of the decoded messagzvoidsetGathering(boolean gathering) Set the isGathering flagvoidsetGrammar(Grammar<? extends Asn1Container> grammar) Sets the grammarvoidsetGrammarEndAllowed(boolean grammarEndAllowed) Sets the flag to allow a end transitionvoidsetMaxPDUSize(int maxPDUSize) Set the maximum PDU size.voidsetParentTLV(TLV parentTLV) Sets the parent TLVvoidsetState(TLVStateEnum state) Sets the new current statevoidsetStream(ByteBuffer stream) Stores the Stream being decodedvoidsetTransition(Enum<?> transition) Updates the transition from a state to anothervoidUpdate the parent's length
-
Constructor Details
-
AbstractContainer
protected AbstractContainer()Creates a new instance of AbstractContainer with a starting state. -
AbstractContainer
Creates a new instance of AbstractContainer with a starting state.- Parameters:
stream- the buffer containing the data to decode
-
-
Method Details
-
getGrammar
Gets the grammar- Specified by:
getGrammarin interfaceAsn1Container- Returns:
- Returns the grammar used to decode a LdapMessage.
-
setGrammar
Sets the grammar- Specified by:
setGrammarin interfaceAsn1Container- Parameters:
grammar- The grammar to set
-
getState
Gets the current grammar state- Specified by:
getStatein interfaceAsn1Container- Returns:
- Returns the current grammar state
-
setState
Sets the new current state- Specified by:
setStatein interfaceAsn1Container- Parameters:
state- The new state
-
isGrammarEndAllowed
public boolean isGrammarEndAllowed()Checks that we can have a end state after this transition- Specified by:
isGrammarEndAllowedin interfaceAsn1Container- Returns:
- true if this can be the last transition
-
setGrammarEndAllowed
public void setGrammarEndAllowed(boolean grammarEndAllowed) Sets the flag to allow a end transition- Specified by:
setGrammarEndAllowedin interfaceAsn1Container- Parameters:
grammarEndAllowed- true or false, depending on the next transition being an end or not.
-
getTransition
Gets the transition- Specified by:
getTransitionin interfaceAsn1Container- Returns:
- Returns the transition from the previous state to the new state
-
setTransition
Updates the transition from a state to another- Specified by:
setTransitionin interfaceAsn1Container- Parameters:
transition- The transition to set
-
setCurrentTLV
Sets the current TLV- Specified by:
setCurrentTLVin interfaceAsn1Container- Parameters:
currentTLV- The current TLV
-
getCurrentTLV
Gets the currentTLV- Specified by:
getCurrentTLVin interfaceAsn1Container- Returns:
- Returns the current TLV being decoded
-
getParentTLV
Get the parent's TLV- Specified by:
getParentTLVin interfaceAsn1Container- Returns:
- The parent TLV.
-
setParentTLV
Sets the parent TLV- Specified by:
setParentTLVin interfaceAsn1Container- Parameters:
parentTLV- The new parent TLV
-
clean
public void clean()Clean the container for the next usage. -
getNewTlvId
public int getNewTlvId()Gets a new TLV id- Specified by:
getNewTlvIdin interfaceAsn1Container- Returns:
- a unique value representing the current TLV id
-
getTlvId
public int getTlvId()Gets the current TLV id- Specified by:
getTlvIdin interfaceAsn1Container- Returns:
- a unique value representing the current TLV id
-
getDecodedBytes
public int getDecodedBytes()Get the size of the decoded message- Specified by:
getDecodedBytesin interfaceAsn1Container- Returns:
- The number of decoded bytes for this message. This is used to control the PDU size and avoid PDU exceeding the maximum allowed size to break the server.
-
setDecodedBytes
public void setDecodedBytes(int decodedBytes) Set the size of the decoded messagz- Specified by:
setDecodedBytesin interfaceAsn1Container- Parameters:
decodedBytes- The number of decoded bytes for this message.
-
incrementDecodedBytes
public void incrementDecodedBytes(int nb) Increment the decodedBytes by the latest received buffer's size.- Specified by:
incrementDecodedBytesin interfaceAsn1Container- Parameters:
nb- The buffer size.
-
getMaxPDUSize
public int getMaxPDUSize()Get the maximum PDU size allowed- Specified by:
getMaxPDUSizein interfaceAsn1Container- Returns:
- The maximum PDU size.
-
setMaxPDUSize
public void setMaxPDUSize(int maxPDUSize) Set the maximum PDU size.- Specified by:
setMaxPDUSizein interfaceAsn1Container- Parameters:
maxPDUSize- The maximum PDU size (if negative or null, will be replaced by the max integer value)
-
getStream
Gets the current stream containing the bytes to decode- Specified by:
getStreamin interfaceAsn1Container- Returns:
- The current stream
-
setStream
Stores the Stream being decoded- Specified by:
setStreamin interfaceAsn1Container- Parameters:
stream- The stream being decoded
-
rewind
public void rewind()Move backward in the stream to the first byte for a given TLV. This is useful when we have read some Tag and Length in order to define the next transition, and if this transition do a grammar switch.- Specified by:
rewindin interfaceAsn1Container
-
updateParent
public void updateParent()Update the parent's length- Specified by:
updateParentin interfaceAsn1Container
-
isGathering
public boolean isGathering()Tells if the decoding should be done immediately or if the container should gather the data before- Specified by:
isGatheringin interfaceAsn1Container- Returns:
- true if the container should gather the value into itself, false if the decoding of the Value part should be done immediately for constructed types.
-
setGathering
public void setGathering(boolean gathering) Set the isGathering flag- Specified by:
setGatheringin interfaceAsn1Container- Parameters:
gathering- true to ask the Asn1Decoder to gather the data into the container. If not set, the default value is 'false'
-