cz.cuni.amis.pogamut.ut2004.communication.translator.observer.support
Class ObserverListState<MESSAGE,CONTEXT extends TranslatorContext>

java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.communication.translator.observer.support.AbstractObserverFSMState<InfoMessage,CONTEXT>
      extended by cz.cuni.amis.pogamut.ut2004.communication.translator.observer.support.ObserverListState<MESSAGE,CONTEXT>
Type Parameters:
MESSAGE -
CONTEXT -
All Implemented Interfaces:
IFSMState<InfoMessage,CONTEXT>
Direct Known Subclasses:
ItemListState, MapListState, MutatorListState, NavPointNeighboursState, PathAcceptState, PlayerListState

public abstract class ObserverListState<MESSAGE,CONTEXT extends TranslatorContext>
extends AbstractObserverFSMState<InfoMessage,CONTEXT>

Support class that takes care of batch of messages in the form of:

START_MSG MSG MSG .... MSG END_MSG

Performs class checks over the symbols that are used to enter / leave the state.

Stores all the MSGs inside a list.

To use this state you have to subclass this abstract class, use correct super() inside the constructor of your class and override stateLeaving() method (first by calling super.stateLeaving()) and use getList() to obtain the list of all messages that came between START and END message.


Constructor Summary
ObserverListState(java.lang.Class beginMessage, java.lang.Class<MESSAGE> message, java.lang.Class endMessage)
           
 
Method Summary
protected  java.util.List<MESSAGE> getList()
           
 void init(CONTEXT context)
           
protected  void innerStateSymbol(CONTEXT context, InfoMessage symbol)
           
protected  void newList()
           
 void restart(CONTEXT context)
           
 void stateEntering(CONTEXT context, IFSMState<InfoMessage,CONTEXT> fromState, InfoMessage symbol)
           
 void stateLeaving(CONTEXT context, IFSMState<InfoMessage,CONTEXT> toState, InfoMessage symbol)
           
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.communication.translator.observer.support.AbstractObserverFSMState
stateSymbol, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObserverListState

public ObserverListState(java.lang.Class beginMessage,
                         java.lang.Class<MESSAGE> message,
                         java.lang.Class endMessage)
Parameters:
beginMessage - message class that should be used to enter this state
message - class of messages we should store inside the list (must be the same as generic type MESSAGE!)
endMessage - message class that should be used to leave this state
Method Detail

getList

protected java.util.List<MESSAGE> getList()

newList

protected void newList()

init

public void init(CONTEXT context)

restart

public void restart(CONTEXT context)

stateEntering

public void stateEntering(CONTEXT context,
                          IFSMState<InfoMessage,CONTEXT> fromState,
                          InfoMessage symbol)

stateLeaving

public void stateLeaving(CONTEXT context,
                         IFSMState<InfoMessage,CONTEXT> toState,
                         InfoMessage symbol)

innerStateSymbol

protected void innerStateSymbol(CONTEXT context,
                                InfoMessage symbol)
Specified by:
innerStateSymbol in class AbstractObserverFSMState<InfoMessage,CONTEXT extends TranslatorContext>