org.apache.asn1new.ber.grammar
Class AbstractGrammar

java.lang.Object
  extended by org.apache.asn1new.ber.grammar.AbstractGrammar
All Implemented Interfaces:
IGrammar

public abstract class AbstractGrammar
extends java.lang.Object
implements IGrammar

The abstract IGrammar which is the Mother of all the grammars. It contains the transitions table.

Author:
Apache Directory Project

Field Summary
private static boolean DEBUG
          A speedup for logs
private static org.slf4j.Logger log
          The logger
protected  java.lang.String name
          The grammar name
protected  IStates statesEnum
          The grammar's states
protected  GrammarTransition[][] transitions
          Table of transitions.
 
Constructor Summary
AbstractGrammar()
           
 
Method Summary
protected  void checkLength(Asn1Object object, TLV tlv)
          Checks the Length.
 void executeAction(IAsn1Container container)
          The main function.
 java.lang.String getName()
          Return the grammar's name
 IStates getStatesEnum()
          Get the states of the current grammar
 GrammarTransition getTransition(int state, int tag)
          Get the transition associated with the state and tag
 void setName(java.lang.String name)
          Set the grammar's name
 void setStatesEnum(IStates statesEnum)
          Set the states for this grammar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.slf4j.Logger log
The logger


DEBUG

private static boolean DEBUG
A speedup for logs


transitions

protected GrammarTransition[][] transitions
Table of transitions. It's a two dimension array, the first dimension indice the states, the second dimension indices the Tag value, so it is 256 wide.


name

protected java.lang.String name
The grammar name


statesEnum

protected IStates statesEnum
The grammar's states

Constructor Detail

AbstractGrammar

public AbstractGrammar()
Method Detail

getName

public java.lang.String getName()
Return the grammar's name

Specified by:
getName in interface IGrammar
Returns:
The grammar name

setName

public void setName(java.lang.String name)
Set the grammar's name

Specified by:
setName in interface IGrammar
Parameters:
name - DOCUMENT ME!

checkLength

protected void checkLength(Asn1Object object,
                           TLV tlv)
                    throws org.apache.asn1.codec.DecoderException
Checks the Length. If the current TLV length is above the expected length of the PDU, an exception is thrown. The current Object contains the sum of all included Objects and element, which is compared with the PDU's expected length (the Length part of the PDU containing the Object).

Parameters:
object - The Object that is being decoded.
tlv - The current TLV
Throws:
org.apache.asn1.codec.DecoderException - Thrown if the expected length is lower than the sum of all the included elements.

getTransition

public GrammarTransition getTransition(int state,
                                       int tag)
Get the transition associated with the state and tag

Parameters:
state - The current state
tag - The current tag
Returns:
A valid transition if any, or null.

executeAction

public void executeAction(IAsn1Container container)
                   throws org.apache.asn1.codec.DecoderException
The main function. This is where an action is executed. If the action is null, nothing is done.

Specified by:
executeAction in interface IGrammar
Parameters:
container - The Asn1Container
Throws:
org.apache.asn1.codec.DecoderException - Thrown if anything went wrong

getStatesEnum

public IStates getStatesEnum()
Get the states of the current grammar

Specified by:
getStatesEnum in interface IGrammar
Returns:
Returns the statesEnum.

setStatesEnum

public void setStatesEnum(IStates statesEnum)
Set the states for this grammar

Parameters:
statesEnum - The statesEnum to set.


Copyright © 2005-2009 . All Rights Reserved.