01: /*
02: * Created on Nov 21, 2005
03: */
04: package uk.org.ponder.rsf.flow.lite;
05:
06: import java.util.Collection;
07: import java.util.Collections;
08: import java.util.HashMap;
09: import java.util.Iterator;
10: import java.util.Map;
11:
12: public class Flow {
13: public String id;
14: public String startstate;
15: // A map from State ID to state.
16: private Map states = new HashMap();
17:
18: public void addState(State toadd) {
19: states.put(toadd.id, toadd);
20: }
21:
22: public State stateFor(String stateid) {
23: return (State) states.get(stateid);
24: }
25:
26: public Collection getStates() {
27: return Collections.unmodifiableCollection(states.values());
28: }
29:
30: public void init() {
31: for (Iterator it = getStates().iterator(); it.hasNext();) {
32: State state = (State) it.next();
33: state.init();
34: }
35: FlowUtil.validateFlow(this);
36: }
37:
38: }
|