public abstract class AbstractContainer extends Object implements Asn1Container
Modifier and Type | Field and Description |
---|---|
protected int |
decodeBytes
A counter for the decoded bytes
|
protected Grammar<?> |
grammar
All the possible grammars
|
protected int[] |
stateStack
Store a stack of the current states used when switching grammars
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractContainer()
Creates a new instance of AbstractContainer with a starting state.
|
protected |
AbstractContainer(ByteBuffer stream)
Creates a new instance of AbstractContainer with a starting state.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
Clean the container for the next usage.
|
TLV |
getCurrentTLV()
Get the current TLV
|
int |
getDecodeBytes() |
Grammar<?> |
getGrammar()
Get the current grammar
|
int |
getMaxPDUSize() |
int |
getNewTlvId()
Return a new ID and increment the counter
|
TLV |
getParentTLV()
Get the parent TLV;
|
TLVStateEnum |
getState()
Get the current grammar state
|
ByteBuffer |
getStream()
Gets the current stream containing the bytes to decode
|
int |
getTlvId()
Get the current TLV id
|
Enum<?> |
getTransition()
Get the transition
|
void |
incrementDecodeBytes(int nb)
Increment the decodedBytes by the latest received buffer's size.
|
boolean |
isGathering() |
boolean |
isGrammarEndAllowed()
Check that we can have a end state after this transition
|
void |
rewind()
Move backward in the stream to the first byte for a given TLV.
|
void |
setCurrentTLV(TLV currentTLV)
Set the current TLV
|
void |
setGathering(boolean isGathering)
Set the isGathering flag
|
void |
setGrammarEndAllowed(boolean grammarEndAllowed)
Set the flag to allow a end transition
|
void |
setMaxPDUSize(int maxPDUSize)
Set the maximum PDU size.
|
void |
setParentTLV(TLV parentTLV)
Set the parent TLV.
|
void |
setState(TLVStateEnum state)
Set the new current state
|
void |
setStream(ByteBuffer stream)
Stores the Stream being decoded
|
void |
setTransition(Enum<?> transition)
Update the transition from a state to another
|
void |
updateParent()
Look for the closest parent which has an expected length above 0
|
protected int[] stateStack
protected int decodeBytes
protected AbstractContainer()
protected AbstractContainer(ByteBuffer stream)
stream
- the buffer containing the data to decodepublic Grammar<?> getGrammar()
getGrammar
in interface Asn1Container
public TLVStateEnum getState()
getState
in interface Asn1Container
public void setState(TLVStateEnum state)
setState
in interface Asn1Container
state
- The new statepublic boolean isGrammarEndAllowed()
isGrammarEndAllowed
in interface Asn1Container
public void setGrammarEndAllowed(boolean grammarEndAllowed)
setGrammarEndAllowed
in interface Asn1Container
grammarEndAllowed
- true or false, depending on the next transition
being an end or not.public Enum<?> getTransition()
getTransition
in interface Asn1Container
public void setTransition(Enum<?> transition)
setTransition
in interface Asn1Container
transition
- The transition to setpublic void setCurrentTLV(TLV currentTLV)
setCurrentTLV
in interface Asn1Container
currentTLV
- The current TLVpublic TLV getCurrentTLV()
getCurrentTLV
in interface Asn1Container
public TLV getParentTLV()
getParentTLV
in interface Asn1Container
public void setParentTLV(TLV parentTLV)
setParentTLV
in interface Asn1Container
parentTLV
- The parent TLV to set.public void clean()
public int getNewTlvId()
getNewTlvId
in interface Asn1Container
public int getTlvId()
Asn1Container
getTlvId
in interface Asn1Container
public int getDecodeBytes()
getDecodeBytes
in interface Asn1Container
public void incrementDecodeBytes(int nb)
incrementDecodeBytes
in interface Asn1Container
nb
- The buffer size.public int getMaxPDUSize()
getMaxPDUSize
in interface Asn1Container
public void setMaxPDUSize(int maxPDUSize)
setMaxPDUSize
in interface Asn1Container
maxPDUSize
- The maximum PDU size (if negative or null, will be
replaced by the max integer value)public ByteBuffer getStream()
getStream
in interface Asn1Container
public void setStream(ByteBuffer stream)
setStream
in interface Asn1Container
stream
- The stream being decodedpublic void rewind()
rewind
in interface Asn1Container
public void updateParent()
updateParent
in interface Asn1Container
public boolean isGathering()
isGathering
in interface Asn1Container
public void setGathering(boolean isGathering)
setGathering
in interface Asn1Container
isGathering
- true to ask the Asn1Decoder to gather the data
into the container. If not set, the default value is 'false'Copyright © 2003-2014 The Apache Software Foundation. All Rights Reserved.