org.malai.interaction
Class State

java.lang.Object
  extended by org.malai.interaction.State
All Implemented Interfaces:
IState
Direct Known Subclasses:
AbortingState, InitState, IntermediaryState, TerminalState

public abstract class State
extends java.lang.Object
implements IState

A state is a component of a state machine.

This file is part of Malai.
Copyright (c) 2009-2012 Arnaud BLOUIN

Malai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Malai is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

10/10/2010

Since:
0.1
Author:
Arnaud BLOUIN

Field Summary
protected  java.lang.String name
          The name of the state.
protected  Interaction stateMachine
          The state machine that contains the state.
protected  java.util.List<ITransition> transitions
          The list of the transitions that leave the state.
 
Constructor Summary
State(java.lang.String name)
          Creates the state.
 
Method Summary
 void addTransition(ITransition trans)
          Adds a transition to the state.
 java.lang.String getName()
           
 Interaction getStateMachine()
           
 ITransition getTransition(int i)
           
 java.util.List<ITransition> getTransitions()
           
 void setStateMachine(IStateMachine sm)
          Sets the state machine of the state.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of the state.


transitions

protected java.util.List<ITransition> transitions
The list of the transitions that leave the state.


stateMachine

protected Interaction stateMachine
The state machine that contains the state.

Constructor Detail

State

public State(java.lang.String name)
Creates the state.

Parameters:
name - The name of the state.
Throws:
java.lang.IllegalArgumentException - If the given name is null.
Since:
0.1
Method Detail

setStateMachine

public void setStateMachine(IStateMachine sm)
Description copied from interface: IState
Sets the state machine of the state.

Specified by:
setStateMachine in interface IState
Parameters:
sm - The new state machine. If null, nothing is done.

getStateMachine

public Interaction getStateMachine()
Specified by:
getStateMachine in interface IState
Returns:
The state machine that contains the state.

addTransition

public void addTransition(ITransition trans)
Description copied from interface: IState
Adds a transition to the state.

Specified by:
addTransition in interface IState
Parameters:
trans - The new transition. Must not be null.

getName

public java.lang.String getName()
Specified by:
getName in interface IState
Returns:
The name of the state.

getTransitions

public java.util.List<ITransition> getTransitions()
Specified by:
getTransitions in interface IState
Returns:
The transitions that leaves the state.

getTransition

public ITransition getTransition(int i)
Specified by:
getTransition in interface IState
Parameters:
i - The position of the transition to get.
Returns:
The corresponding transition or null if the given index is not valid.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object