All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface uhr.core.role.StateCommandableInfo

public interface StateCommandableInfo
This interface describes the relevant state machine structure. This information is used to more effectively use the StateCommandable class. The info may be static or dynamic, but we expect most to be static and so have no removals and such. For dynamic use create a new StateCommandableInfo class having the proper data for that point in time.

First add all transitions, then add propagated and default commands. This allows the implementation to check that the propagated and default commands exist.

After making all mutations perform the makeReadOnly() method.


Method Index

 o addDefaultCommand(String, String)
Adds the default command for a state.
 o addPropagatedCommand(String)
Adds a propagated command.
 o addTransition(String, String, String)
Adds one row to the state transition table.
 o getAllCommands()
Returns all the commands in the order added.
 o getAllowableCommands(String)
Returns the allowable commands for the state.
 o getAllStates()
Returns all posible states.
 o getDefaultCommand(String)
Returns the default command for the state or null if none.
 o getTableRow(int)
Returns one row in the state transition table.
 o getTableRowCount()
Returns the number of rows in the state transition table.
 o hasCommand(String)
Determines if the command exists, false if not.
 o isCommandPropagated(String)
Returns true if the command is propagated, false if not or if not a valid command.
 o isDynamic()
Determines whether this information is dynamic or not.
 o isReadOnly()
Determines whether this information is read only.
 o listStateTransitionTable()
Returns a list of all rows in the table in the order added.
 o makeReadOnly()
Makes the information read only.
 o setDynamic(boolean)
Sets whether this information is static or dynamic.

Methods

 o addTransition
 public abstract void addTransition(String state,
                                    String command,
                                    String newState)
Adds one row to the state transition table. If in the state, the command would cause a transition to the newState. States and commands should be well formed names with no slashes, commas or spaces. Periods are okay. By convention start them with a capital letter, such as "Start" or "Running". Naturally all states and commands are case sensitive. Avoid duplicate adds.

The first transition added must be the start state.

Sample arguments are ("Created", "Init", "Initialized").

The commands should be added in a pleasing, informative, consistent order. They will be shown to users in that order.

Parameters:
state - the state under consideration.
command - the command received in the state.
newState - the new state the command would cause a transition to if in the state.
 o addPropagatedCommand
 public abstract void addPropagatedCommand(String command)
Adds a propagated command. This is relevant only for containers. Propagated commands are propagated to children who have that command, and to their children, etc. For example "Close" is a good propagated command. It will allow all parts needing to release resources to do so when their Close command is called. In this manner large complex systems can more easily behave correctly.

We assume this is unrelated to state. If this turns out to be false, we will add addPropagatedCommand(state, command).

Parameters:
command - the propagated command.
 o addDefaultCommand
 public abstract void addDefaultCommand(String state,
                                        String command)
Adds the default command for a state. This the most sensible command to do when in that state. It's designed to allow a StateCommandable to be "cycled through" from beginning to final state, or at least back to whare it stated.

Parameters:
state - the state in question.
command - the default command for the state.
 o setDynamic
 public abstract void setDynamic(boolean isDynamic)
Sets whether this information is static or dynamic. The default if false, which is most cases.

Parameters:
isDynamic - true if dynamic, false if not.
 o makeReadOnly
 public abstract void makeReadOnly()
Makes the information read only. This allows an instance to be safely reused and passed to whomever needs to read it. This should be called after all mutations are done, after which no more mutations are allowed.

This method itself is a mutation, so it may only be called once.

 o isDynamic
 public abstract boolean isDynamic()
Determines whether this information is dynamic or not.

Returns:
true if dynamic, false if not.
 o isReadOnly
 public abstract boolean isReadOnly()
Determines whether this information is read only.

Returns:
true if read only, false if mutations are still allowed.
 o getAllCommands
 public abstract Enumeration getAllCommands()
Returns all the commands in the order added.

Returns:
an enumeration of all commands.
 o getAllowableCommands
 public abstract Enumeration getAllowableCommands(String state)
Returns the allowable commands for the state. All commands not included are not allowed.

Parameters:
state - the state in question.
Returns:
an enumeration of all allowable commands for the state.
 o isCommandPropagated
 public abstract boolean isCommandPropagated(String command)
Returns true if the command is propagated, false if not or if not a valid command.

Parameters:
command - the command in question.
Returns:
true if propagated to children, false if not.
 o hasCommand
 public abstract boolean hasCommand(String command)
Determines if the command exists, false if not.

Parameters:
command - the command in question.
Returns:
true if it exists, false if not.
 o getAllStates
 public abstract Enumeration getAllStates()
Returns all posible states.

Returns:
an enumeration of all possible states.
 o getDefaultCommand
 public abstract String getDefaultCommand(String state)
Returns the default command for the state or null if none.

Parameters:
state - the state in question.
Returns:
the default command for the state or null if none.
 o getTableRowCount
 public abstract int getTableRowCount()
Returns the number of rows in the state transition table.

Returns:
the number of rows in the state transition table.
 o getTableRow
 public abstract String[] getTableRow(int rowNumber)
Returns one row in the state transition table.

Parameters:
rowNumber - the row number to return. Zero based is used.
Returns:
a String array holding one table row. Array indexes 0, 1, 2 refer to table columns "state", "command", "newState".
Throws: IllegalArgumentException
if the rowNumber is invalid.
 o listStateTransitionTable
 public abstract String listStateTransitionTable()
Returns a list of all rows in the table in the order added.

Returns:
a new line delimited list of all rows in the table or null if the table is empty.

All Packages  Class Hierarchy  This Package  Previous  Next  Index