Overview | Package | Class | Tree | Deprecated | Index | Help
| SMC 6_0_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.smc.model
Class SmcGuard

    java.lang.Object
      net.sf.smc.model.SmcElement
          net.sf.smc.model.SmcGuard

    public final class SmcGuard

extends SmcElement

This is the second half of a `transition` definition. This contains the:

- reference to the parent transition,
- the guard condition (which may be an empty string),
- the transition type,
- the end state,
- the push state (if this is a push transition type),
- the pop arguments (if this is a pop transition type) and
- the transition action list (may be empty).

Most transitions have no condition, go directly to the next state and have zero or more actions. The push and pop transitions allow FSM "subroutines" to be defined. If a common state machine sequence needs to be accessed from different states in the main map, then SMC encourages developers to define that common sequence in a separate map and to push to this submap from the main map states. When the submap completes its work a pop transition is used to return to the point of departure in the main map. The pop transition "returns" a transition and optional argument list which is applied to the restored main map state. In short, push and pop transitions allow redundant state sequences to be defined once instead of duplicated multiple times within a single FSM.

See Also:
  `SmcTransition`, `SmcAction`

Nested Class Summary

Nested classes/interfaces inherited from class net.sf.smc.model.SmcElement
`SmcElement.TransType`

Field Summary

Fields inherited from class net.sf.smc.model.SmcElement
`_lineNumber, _name, NIL_STATE`

Constructor Summary
`SmcGuard(java.lang.String cond, int lineNumber, SmcTransition transition)` Creates a guard instance for the given transition, line number and condition.

Method Summary
`void` | `accept(SmcVisitor visitor)` Calls the visitor's visit method for this finite state machine element.
`java.util.List<SmcAction>` | `getActions()` Returns the transition action list.
`java.lang.String` | `getCondition()` Returns the guard condition.
`java.lang.String` | `getEndState()` Returns the transition end state name.
`java.lang.String` | `getPopArgs()` Returns the pop transition arguments.
`java.lang.String` | `getPushState()` Returns the push state name.
`SmcTransition` | `getTransition()` Returns the transition to which this guard belongs.
`SmcElement.TransType` | `getTransType()` Returns the transition type.
`boolean` | `hasCtxtReference()` Returns `true` if this guard references the `ctxt` variable and `false` otherwise.
`void` | `setActions(java.util.List<SmcAction> actions)` Sets the transition actions.
`void` | `setEndState(java.lang.String endState)` Sets the transition end state name.
`void` | `setPopArgs(java.lang.String args)` Set the pop transition arguments.
`void` | `setPushState(java.lang.String state)` Sets the push state name.
`void` | `setTransType(SmcElement.TransType transType)` Sets the transition type.
`java.lang.String` | `toString()` Returns the transition guard text representation.

Methods inherited from class net.sf.smc.model.SmcElement
`getLineNumber, getName, merge`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SmcGuard

    public SmcGuard(java.lang.String cond,
                    int lineNumber,
                    SmcTransition transition)

  Creates a guard instance for the given transition, line number and condition.

  Parameters:
    `cond` - transition guard condition.
    `lineNumber` - where this guard appears in the .sm file.
    `transition` - guard belongs to this transition.

Method Detail

### accept

    public void accept(SmcVisitor visitor)

  Calls the visitor's visit method for this finite state machine element.

  Specified by:
    `accept` in class `SmcElement`
  Parameters:
    `visitor` - The visitor instance.
  See Also:
    `SmcVisitor`

### getTransition

    public SmcTransition getTransition()

  Returns the transition to which this guard belongs.

  Returns:
    the transition to which this guard belongs.

### getCondition

    public java.lang.String getCondition()

  Returns the guard condition.

  Returns:
    the guard condition.

### getTransType

    public SmcElement.TransType getTransType()

  Returns the transition type.

  Returns:
    the transition type.

### getEndState

    public java.lang.String getEndState()

  Returns the transition end state name.

  Returns:
    the transition end state name.

### getPushState

    public java.lang.String getPushState()

  Returns the push state name. This is only valid if the transition is a `push` transition. This state become the current state after the transition completes. It is not the state pushed on to the state stack.

  Returns:
    the push state name.

### getPopArgs

    public java.lang.String getPopArgs()

  Returns the pop transition arguments. This is only valid if the transition type is a `pop` transition.

  Returns:
    the pop transition arguments.

### hasCtxtReference

    public boolean hasCtxtReference()

  Returns `true` if this guard references the `ctxt` variable and `false` otherwise. The `ctxt` variable plays a similar rote as `this` or `self` in object-oriented programming languages. `ctxt` is the first parameter for all transitions and is a reference to the FSM context instance (even if a transitions has no defined parameters it still has this one).

  Returns:
    `true` if this guard references the `ctxt` variable and `false` otherwise.

### getActions

    public java.util.List<SmcAction> getActions()

  Returns the transition action list.

  Returns:
    the transition action list.

### setTransType

    public void setTransType(SmcElement.TransType transType)

  Sets the transition type.

  Parameters:
    `transType` - the transition type.

### setEndState

    public void setEndState(java.lang.String endState)

  Sets the transition end state name.

  Parameters:
    `endState` - the end state name.

### setPushState

    public void setPushState(java.lang.String state)

  Sets the push state name.

  Parameters:
    `state` - a state name.

### setPopArgs

    public void setPopArgs(java.lang.String args)

  Set the pop transition arguments.

  Parameters:
    `args` - pop transition arguments.

### setActions

    public void setActions(java.util.List<SmcAction> actions)

  Sets the transition actions. May not be `null` but may be empty.

  Parameters:
    `actions` - transition actions.

### toString

    public java.lang.String toString()

  Returns the transition guard text representation.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the transition guard text representation.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SMC 6_0_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. Charles W. Rapp. All Rights Reserved. Use is subject to license terms.