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. package com.sun.corba.se.spi.orbutil.fsm ;
  8. import com.sun.corba.se.impl.orbutil.fsm.NameBase ;
  9. import java.util.Map ;
  10. import java.util.HashMap ;
  11. import java.util.Set ;
  12. import java.util.HashSet ;
  13. import com.sun.corba.se.impl.orbutil.fsm.GuardedAction ;
  14. import com.sun.corba.se.impl.orbutil.fsm.NameBase ;
  15. /** Base class for all states in a StateEngine. This must be used
  16. * as the base class for all states in transitions added to a StateEngine.
  17. */
  18. public class StateImpl extends NameBase implements State {
  19. private Action defaultAction ;
  20. private State defaultNextState ;
  21. private Map inputToGuardedActions ;
  22. public StateImpl( String name )
  23. {
  24. super( name ) ;
  25. defaultAction = null ;
  26. inputToGuardedActions = new HashMap() ;
  27. }
  28. public void preAction( FSM fsm )
  29. {
  30. }
  31. public void postAction( FSM fsm )
  32. {
  33. }
  34. // Methods for use only by StateEngineImpl.
  35. public State getDefaultNextState()
  36. {
  37. return defaultNextState ;
  38. }
  39. public void setDefaultNextState( State defaultNextState )
  40. {
  41. this.defaultNextState = defaultNextState ;
  42. }
  43. public Action getDefaultAction()
  44. {
  45. return defaultAction ;
  46. }
  47. public void setDefaultAction( Action defaultAction )
  48. {
  49. this.defaultAction = defaultAction ;
  50. }
  51. public void addGuardedAction( Input in, GuardedAction ga )
  52. {
  53. Set gas = (Set)inputToGuardedActions.get( in ) ;
  54. if (gas == null) {
  55. gas = new HashSet() ;
  56. inputToGuardedActions.put( in, gas ) ;
  57. }
  58. gas.add( ga ) ;
  59. }
  60. public Set getGuardedActions( Input in )
  61. {
  62. return (Set)inputToGuardedActions.get( in ) ;
  63. }
  64. }