KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > orbutil > fsm > StateImpl


1 /*
2  * @(#)StateImpl.java 1.9 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.spi.orbutil.fsm ;
9
10 import com.sun.corba.se.impl.orbutil.fsm.NameBase ;
11
12 import java.util.Map JavaDoc ;
13 import java.util.HashMap JavaDoc ;
14 import java.util.Set JavaDoc ;
15 import java.util.HashSet JavaDoc ;
16
17 import com.sun.corba.se.impl.orbutil.fsm.GuardedAction ;
18 import com.sun.corba.se.impl.orbutil.fsm.NameBase ;
19
20 /** Base class for all states in a StateEngine. This must be used
21 * as the base class for all states in transitions added to a StateEngine.
22 */

23 public class StateImpl extends NameBase implements State {
24     private Action defaultAction ;
25     private State defaultNextState ;
26     private Map JavaDoc inputToGuardedActions ;
27
28     public StateImpl( String JavaDoc name )
29     {
30     super( name ) ;
31     defaultAction = null ;
32     inputToGuardedActions = new HashMap JavaDoc() ;
33     }
34
35     public void preAction( FSM fsm )
36     {
37     }
38
39     public void postAction( FSM fsm )
40     {
41     }
42
43     // Methods for use only by StateEngineImpl.
44

45     public State getDefaultNextState()
46     {
47     return defaultNextState ;
48     }
49
50     public void setDefaultNextState( State defaultNextState )
51     {
52     this.defaultNextState = defaultNextState ;
53     }
54
55     public Action getDefaultAction()
56     {
57     return defaultAction ;
58     }
59
60     public void setDefaultAction( Action defaultAction )
61     {
62     this.defaultAction = defaultAction ;
63     }
64
65     public void addGuardedAction( Input in, GuardedAction ga )
66     {
67     Set JavaDoc gas = (Set JavaDoc)inputToGuardedActions.get( in ) ;
68     if (gas == null) {
69         gas = new HashSet JavaDoc() ;
70         inputToGuardedActions.put( in, gas ) ;
71     }
72
73     gas.add( ga ) ;
74     }
75
76     public Set JavaDoc getGuardedActions( Input in )
77     {
78     return (Set JavaDoc)inputToGuardedActions.get( in ) ;
79     }
80 }
81
82
Popular Tags