Class AbstractContainer
- java.lang.Object
-
- org.apache.directory.api.asn1.ber.AbstractContainer
-
- All Implemented Interfaces:
Asn1Container
- Direct Known Subclasses:
AdDirSyncContainer
,AdPolicyHintsContainer
,CancelContainer
,CertGenerationContainer
,ControlsContainer
,EndTransactionRequestContainer
,EndTransactionResponseContainer
,EntryChangeContainer
,GracefulDisconnectContainer
,GracefulShutdownContainer
,LdapMessageContainer
,PagedResultsContainer
,PasswordModifyRequestContainer
,PasswordModifyResponseContainer
,PasswordPolicyContainer
,PersistentSearchContainer
,SortRequestContainer
,SortResponseContainer
,StoredProcedureContainer
,SubentriesContainer
,SyncDoneValueContainer
,SyncInfoValueContainer
,SyncRequestValueContainer
,SyncStateValueContainer
,VirtualListViewRequestContainer
,VirtualListViewResponseContainer
,WhoAmIResponseContainer
public abstract class AbstractContainer extends Object implements 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clean()
Clean the container for the next usage.TLV
getCurrentTLV()
Gets the currentTLVint
getDecodedBytes()
Grammar<?>
getGrammar()
Gets the grammarint
getMaxPDUSize()
int
getNewTlvId()
Gets a new TLV idTLV
getParentTLV()
TLVStateEnum
getState()
Gets the current grammar stateByteBuffer
getStream()
Gets the current stream containing the bytes to decodeint
getTlvId()
Gets the current TLV idEnum<?>
getTransition()
Gets the transitionvoid
incrementDecodedBytes(int nb)
Increment the decodedBytes by the latest received buffer's size.boolean
isGathering()
boolean
isGrammarEndAllowed()
Checks that we can have a end state after this transitionvoid
rewind()
Move backward in the stream to the first byte for a given TLV.void
setCurrentTLV(TLV currentTLV)
Sets the current TLVvoid
setDecodedBytes(int decodedBytes)
void
setGathering(boolean gathering)
Set the isGathering flagvoid
setGrammar(Grammar<?> grammar)
Sets the grammarvoid
setGrammarEndAllowed(boolean grammarEndAllowed)
Sets the flag to allow a end transitionvoid
setMaxPDUSize(int maxPDUSize)
Set the maximum PDU size.void
setParentTLV(TLV parentTLV)
Sets the parent TLVvoid
setState(TLVStateEnum state)
Sets the new current statevoid
setStream(ByteBuffer stream)
Stores the Stream being decodedvoid
setTransition(Enum<?> transition)
Updates the transition from a state to anothervoid
updateParent()
Update the parent's length
-
-
-
Method Detail
-
getGrammar
public Grammar<?> getGrammar()
Gets the grammar- Specified by:
getGrammar
in interfaceAsn1Container
- Returns:
- Returns the grammar used to decode a LdapMessage.
-
setGrammar
public void setGrammar(Grammar<?> grammar)
Sets the grammar- Specified by:
setGrammar
in interfaceAsn1Container
- Parameters:
grammar
- The grammar to set
-
getState
public TLVStateEnum getState()
Gets the current grammar state- Specified by:
getState
in interfaceAsn1Container
- Returns:
- Returns the current grammar state
-
setState
public void setState(TLVStateEnum state)
Sets the new current state- Specified by:
setState
in interfaceAsn1Container
- Parameters:
state
- The new state
-
isGrammarEndAllowed
public boolean isGrammarEndAllowed()
Checks that we can have a end state after this transition- Specified by:
isGrammarEndAllowed
in 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:
setGrammarEndAllowed
in interfaceAsn1Container
- Parameters:
grammarEndAllowed
- true or false, depending on the next transition being an end or not.
-
getTransition
public Enum<?> getTransition()
Gets the transition- Specified by:
getTransition
in interfaceAsn1Container
- Returns:
- Returns the transition from the previous state to the new state
-
setTransition
public void setTransition(Enum<?> transition)
Updates the transition from a state to another- Specified by:
setTransition
in interfaceAsn1Container
- Parameters:
transition
- The transition to set
-
setCurrentTLV
public void setCurrentTLV(TLV currentTLV)
Sets the current TLV- Specified by:
setCurrentTLV
in interfaceAsn1Container
- Parameters:
currentTLV
- The current TLV
-
getCurrentTLV
public TLV getCurrentTLV()
Gets the currentTLV- Specified by:
getCurrentTLV
in interfaceAsn1Container
- Returns:
- Returns the current TLV being decoded
-
getParentTLV
public TLV getParentTLV()
- Specified by:
getParentTLV
in interfaceAsn1Container
- Returns:
- The parent TLV.
-
setParentTLV
public void setParentTLV(TLV parentTLV)
Sets the parent TLV- Specified by:
setParentTLV
in 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:
getNewTlvId
in interfaceAsn1Container
- Returns:
- a unique value representing the current TLV id
-
getTlvId
public int getTlvId()
Gets the current TLV id- Specified by:
getTlvId
in interfaceAsn1Container
- Returns:
- a unique value representing the current TLV id
-
getDecodedBytes
public int getDecodedBytes()
- Specified by:
getDecodedBytes
in 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)
- Specified by:
setDecodedBytes
in 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:
incrementDecodedBytes
in interfaceAsn1Container
- Parameters:
nb
- The buffer size.
-
getMaxPDUSize
public int getMaxPDUSize()
- Specified by:
getMaxPDUSize
in interfaceAsn1Container
- Returns:
- The maximum PDU size.
-
setMaxPDUSize
public void setMaxPDUSize(int maxPDUSize)
Set the maximum PDU size.- Specified by:
setMaxPDUSize
in interfaceAsn1Container
- Parameters:
maxPDUSize
- The maximum PDU size (if negative or null, will be replaced by the max integer value)
-
getStream
public ByteBuffer getStream()
Gets the current stream containing the bytes to decode- Specified by:
getStream
in interfaceAsn1Container
- Returns:
- The current stream
-
setStream
public void setStream(ByteBuffer stream)
Stores the Stream being decoded- Specified by:
setStream
in 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:
rewind
in interfaceAsn1Container
-
updateParent
public void updateParent()
Update the parent's length- Specified by:
updateParent
in interfaceAsn1Container
-
isGathering
public boolean isGathering()
- Specified by:
isGathering
in 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:
setGathering
in interfaceAsn1Container
- Parameters:
gathering
- true to ask the Asn1Decoder to gather the data into the container. If not set, the default value is 'false'
-
-