|
State |
|
1 /* 2 * State.java 3 * 4 * Copyright (c) 2000-2001, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June1991. 9 * 10 * A copy of this licence is included in the distribution in the file 11 * licence.html, and is also available at http://gate.ac.uk/gate/licence.html. 12 * 13 * Valentin Tablan, October 2000 14 * 15 * $Id: State.java,v 1.2 2001/04/17 18:09:11 oana Exp $ 16 */ 17 package guk.im; 18 19 import java.util.*; 20 21 /** 22 * A state of the {@link LocaleHandler} FSM. 23 * 24 */ 25 public class State{ 26 27 /** 28 * Creates a new state 29 * 30 * @param isFinal 31 */ 32 public State(boolean isFinal ){ 33 this.finalState = isFinal; 34 } 35 36 /** 37 * Default constructor; creates a non final state 38 * 39 */ 40 public State(){ 41 this.finalState = false; 42 } 43 44 /** 45 * Adds anew action to this state. 46 * 47 * @param key 48 * @param action 49 */ 50 public Action addAction(Key key, Action action){ 51 return (Action)transitionFunction.put(key, action); 52 } 53 54 /** 55 * Gets the action this state will activate for a given {@link Key} 56 * 57 * @param key 58 */ 59 public Action getNext(Key key){ 60 return (Action)transitionFunction.get(key); 61 } 62 63 /** 64 * Is this state final? 65 * 66 */ 67 public boolean isFinal(){ 68 return finalState; 69 } 70 71 /** 72 * Has this state any actions? 73 * 74 */ 75 public boolean hasNext(){ 76 return !transitionFunction.isEmpty(); 77 } 78 79 /** 80 * Sets the final attribute. 81 * 82 * @param pFinal 83 */ 84 public void setFinal(boolean pFinal){ 85 finalState = pFinal; 86 } 87 //maps from Key to Action 88 /** 89 * The transition function for this state. 90 * 91 */ 92 Map transitionFunction = new HashMap(); 93 94 /** 95 * Is this state final? 96 * 97 */ 98 boolean finalState; 99 }//class State 100
|
State |
|