View Javadoc

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