org.apache.directory.shared.asn1.ber
Class AbstractContainer

java.lang.Object
  extended byorg.apache.directory.shared.asn1.ber.AbstractContainer
All Implemented Interfaces:
IAsn1Container

public class AbstractContainer
extends java.lang.Object
implements IAsn1Container

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 zll the informations needed to decode a PDU.

Author:
Apache Directory Project

Field Summary
protected  int currentGrammar
          The current grammar
protected  boolean grammarEndAllowed
          The grammar end transition flag
protected  boolean grammarPopAllowed
          The grammar pop transition flag
protected  IGrammar[] grammars
          All the possible grammars
protected  IGrammar[] grammarStack
          The grammars that are used.
protected  int nbGrammars
          The number of stored grammars
protected  TLV parentTLV
          The parent TLV
protected  boolean[] popAllowedStack
          Store a stack of allowed pop
protected  int state
          The current state of the decoding
protected  IStates states
          Store the different states for debug purpose
protected  int[] stateStack
          Store a stack of the current states used when switching grammars
protected  TLV tlv
          The current TLV
protected  int transition
          The current transition
 
Constructor Summary
AbstractContainer()
           
 
Method Summary
 void addGrammar(IGrammar grammar)
          Add a IGrammar to use
 void clean()
          Clean the container for the next usage.
 int getCurrentGrammar()
          Gert the current grammar number
 int getCurrentGrammarType()
          Get the current grammar type.
 TLV getCurrentTLV()
          Get the current TLV
 IGrammar getGrammar()
          Get the current grammar
 TLV getParentTLV()
          Get the parent TLV;
 int getState()
          Get the current grammar state
 IStates getStates()
          Get the states for this container's grammars
 int getTransition()
          Get the transition
 void grammarEndAllowed(boolean grammarEndAllowed)
          Set the flag to allow a end transition
 void grammarPopAllowed(boolean grammarPopAllowed)
          Set the flag to allow a pop transition
 boolean isGrammarEndAllowed()
          Check that we can have a end state after this transition
 boolean isGrammarPopAllowed()
          Check that we can have a pop after this transition
 int restoreGrammar()
          restore the previous grammar (the one before a switch has occured)
 void setCurrentTLV(TLV tlv)
          Set the current TLV
 void setInitGrammar(int grammar)
          Initialize the grammar stack
 void setParentTLV(TLV parentTLV)
          Set the parent TLV.
 void setState(int state)
          Set the new current state
 void setTransition(int transition)
          Update the transition from a state to another
 void switchGrammar(int currentState, int grammar)
          Switch to another grammar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammarStack

protected IGrammar[] grammarStack
The grammars that are used. It's a stack as we can switch grammars


grammars

protected IGrammar[] grammars
All the possible grammars


stateStack

protected int[] stateStack
Store a stack of the current states used when switching grammars


popAllowedStack

protected boolean[] popAllowedStack
Store a stack of allowed pop


nbGrammars

protected int nbGrammars
The number of stored grammars


currentGrammar

protected int currentGrammar
The current grammar


state

protected int state
The current state of the decoding


transition

protected int transition
The current transition


tlv

protected TLV tlv
The current TLV


states

protected IStates states
Store the different states for debug purpose


parentTLV

protected TLV parentTLV
The parent TLV


grammarEndAllowed

protected boolean grammarEndAllowed
The grammar end transition flag


grammarPopAllowed

protected boolean grammarPopAllowed
The grammar pop transition flag

Constructor Detail

AbstractContainer

public AbstractContainer()
Method Detail

getGrammar

public IGrammar getGrammar()
Get the current grammar

Specified by:
getGrammar in interface IAsn1Container
Returns:
Returns the grammar used to decode a LdapMessage.

addGrammar

public void addGrammar(IGrammar grammar)
Add a IGrammar to use

Specified by:
addGrammar in interface IAsn1Container
Parameters:
grammar - The grammar to add.

switchGrammar

public void switchGrammar(int currentState,
                          int grammar)
Switch to another grammar

Specified by:
switchGrammar in interface IAsn1Container
Parameters:
currentState - The current state in the current grammar
grammar - The grammar to add.

restoreGrammar

public int restoreGrammar()
restore the previous grammar (the one before a switch has occured)

Specified by:
restoreGrammar in interface IAsn1Container
Returns:
The previous current state, if any.

getState

public int getState()
Get the current grammar state

Specified by:
getState in interface IAsn1Container
Returns:
Returns the current grammar state

setState

public void setState(int state)
Set the new current state

Specified by:
setState in interface IAsn1Container
Parameters:
state - The new state

isGrammarEndAllowed

public boolean isGrammarEndAllowed()
Check that we can have a end state after this transition

Specified by:
isGrammarEndAllowed in interface IAsn1Container
Returns:
true if this can be the last transition

grammarEndAllowed

public void grammarEndAllowed(boolean grammarEndAllowed)
Set the flag to allow a end transition

Specified by:
grammarEndAllowed in interface IAsn1Container

isGrammarPopAllowed

public boolean isGrammarPopAllowed()
Check that we can have a pop after this transition

Specified by:
isGrammarPopAllowed in interface IAsn1Container
Returns:
true if this can be the last transition before a pop

grammarPopAllowed

public void grammarPopAllowed(boolean grammarPopAllowed)
Set the flag to allow a pop transition

Specified by:
grammarPopAllowed in interface IAsn1Container

getTransition

public int getTransition()
Get the transition

Specified by:
getTransition in interface IAsn1Container
Returns:
Returns the transition from the previous state to the new state

setTransition

public void setTransition(int transition)
Update the transition from a state to another

Specified by:
setTransition in interface IAsn1Container
Parameters:
transition - The transition to set

getCurrentGrammar

public int getCurrentGrammar()
Gert the current grammar number

Specified by:
getCurrentGrammar in interface IAsn1Container
Returns:
Returns the currentGrammar.

getCurrentGrammarType

public int getCurrentGrammarType()
Get the current grammar type.

Specified by:
getCurrentGrammarType in interface IAsn1Container
Returns:
Returns the current Grammar type, or -1 if not found.

setInitGrammar

public void setInitGrammar(int grammar)
Initialize the grammar stack

Specified by:
setInitGrammar in interface IAsn1Container
Parameters:
grammar - Set the initial grammar

setCurrentTLV

public void setCurrentTLV(TLV tlv)
Set the current TLV

Specified by:
setCurrentTLV in interface IAsn1Container
Parameters:
tlv - The current TLV

getCurrentTLV

public TLV getCurrentTLV()
Get the current TLV

Specified by:
getCurrentTLV in interface IAsn1Container
Returns:
Returns the current TLV being decoded

getStates

public IStates getStates()
Get the states for this container's grammars

Specified by:
getStates in interface IAsn1Container
Returns:
Returns the states.

getParentTLV

public TLV getParentTLV()
Get the parent TLV;

Specified by:
getParentTLV in interface IAsn1Container
Returns:
Returns the parent TLV, if any.

setParentTLV

public void setParentTLV(TLV parentTLV)
Set the parent TLV.

Specified by:
setParentTLV in interface IAsn1Container

clean

public void clean()
Clean the container for the next usage.



Copyright © 2003-2006 . All Rights Reserved.