View Javadoc

1   package cz.cuni.amis.pogamut.udk.communication.translator.observer.state;
2   
3   import cz.cuni.amis.fsm.FSMState;
4   import cz.cuni.amis.fsm.FSMTransition;
5   import cz.cuni.amis.fsm.IFSMState;
6   import cz.cuni.amis.pogamut.base.communication.messages.InfoMessage;
7   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.PathList;
8   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.PathListEnd;
9   import cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages.PathListStart;
10  import cz.cuni.amis.pogamut.udk.communication.translator.TranslatorContext;
11  import cz.cuni.amis.pogamut.udk.communication.translator.observer.support.ObserverListState;
12  import cz.cuni.amis.pogamut.udk.communication.translator.shared.events.Path;
13  
14  /**
15   * Takes care of the path list. It stores them inside a List object and when END message comes it sends
16   * them to the world view via Path event.
17   * @author Jimmy
18   */
19  @FSMState(map = {
20  					@FSMTransition(
21  							state = ObserverRunningState.class,
22  							symbol = {PathListEnd.class },
23  							transition = {}
24  					)
25  				}
26  )
27  public class PathAcceptState extends ObserverListState<PathList, TranslatorContext> {
28  
29      private String pathId = null;
30  
31  	public PathAcceptState() {
32  		super(PathListStart.class, PathList.class, PathListEnd.class);
33  	}
34  
35      @Override
36  	public void stateEntering(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> fromState, InfoMessage symbol) {
37          super.stateEntering(context, fromState, symbol);
38          pathId = ((PathListStart)symbol).getMessageId();
39      }
40  
41  	@Override
42  	public void stateLeaving(TranslatorContext context, IFSMState<InfoMessage, TranslatorContext> toState, InfoMessage symbol) {
43  		super.stateLeaving(context, toState, symbol);
44  		context.getEventQueue().pushEvent(new Path(pathId, getList()));
45  		getList().clear();
46  	}
47  }