All Packages Class Hierarchy This Package Previous Next Index
Class bvyy.smf.DiscreteLinearStateModel
java.lang.Object
|
+----bvyy.smf.StateMachine
|
+----bvyy.smf.DiscreteLinearStateModel
- public class DiscreteLinearStateModel
- extends StateMachine
Make a state machine in the manner of a linked list.
This is a flyweight pattern.
Intent
To implement a state machine for linear models. (For exampe a numeric list,
where you can move along the list by n items.)
Motivation
To reduce the number of classes required for this specific type of state
machine and hence improve performance. State is recorded as an interger
rather than a series of state classes.
- Version:
- 1.0.2 24 May 1998
- Author:
- (c) 1998 Brian Voon Yee Yap
- See Also:
- ContinuousLinearStateModel
-
DiscreteLinearStateModel()
-
-
DiscreteLinearStateModel(String)
- Construct a state machine.
-
fireStateChange(ModifiableChangeEvent)
- Change the state from the current state to a new state.
-
getDefaultValue()
- Get the default value.
-
getDownVerb()
- Gets the down verb.
-
getMax()
- Get maximum value
-
getMin()
- Get minimum value
-
getState()
- Returns the current state of the state machine in a StringTokenizer.
-
getStateTransitions()
- Gets the states that can be reached from the current state.
-
getUpVerb()
- Gets the up verb.
-
setDefaultValue(int)
- Set the default value.
-
setDownVerb(String)
- Sets the down verb.
-
setMax(int)
- Set maximum value.
-
setMin(int)
- Set minimum value.
If the current value, or default values are less than the new minimum
they will be set to the new minimum.
-
setUpVerb(String)
- Sets the up verb.
DiscreteLinearStateModel
public DiscreteLinearStateModel()
DiscreteLinearStateModel
public DiscreteLinearStateModel(String spec)
- Construct a state machine.
This method is synchronised to prevent conflicts from other clients who
might want to update the state of this machine. They will have to wait until
after the object is created.
- Parameters:
- spec - The format of the input token shall be:
- LSM,[major version],[minor version]
- name
- defaultvalue
- maxValue
- minvalue
- upVerb
- downVerb
The delimeter is |.
fireStateChange
public void fireStateChange(ModifiableChangeEvent newState) throws PropertyVetoException
- Change the state from the current state to a new state. If the state
request is not possible then no transition happens. This might happen in a
multi-user game where another user has acted just before this user.
Modifiers are not implemented in this version.
- Parameters:
- newState - is a property change event. The old and new value objects
should be string objects.
- Throws: PropertyVetoException
- thrown if a vetoable listener vetoes the
change.
- Overrides:
- fireStateChange in class StateMachine
getState
public String getState()
- Returns the current state of the state machine in a StringTokenizer.
The format of the StringTokenizer is:
- myName,[major version],[minor version]
- myvalue
- Overrides:
- getState in class StateMachine
getStateTransitions
public String getStateTransitions()
- Gets the states that can be reached from the current state. A
StringTokenizer of new states is returned.
The format of the StringTokenizer is:
- LSM,[major version],[minor version]
- name
- currentvalue
- maxValue
- minvalue
- upVerb
- downVerb
The delimeter is "|".
- Overrides:
- getStateTransitions in class StateMachine
setDefaultValue
public void setDefaultValue(int newDefault)
- Set the default value.
- Parameters:
- newDefault - The default is set to this value unless it is outside the
maximum or minimum value. The it is set to the maximum
or minimum value.
getDefaultValue
public int getDefaultValue()
- Get the default value.
setMax
public void setMax(int newMax)
- Set maximum value.
If the current value, or default values are greater than the new maximum
they will be set to the new maximum. This in turn will fire any necessary
validations. If this change is voided, then nothing is done.
If the maxvalue is below the minimum value then the maximum value will be
set to the minimum value.
- Parameters:
- newMax - The new maximum value.
getMax
public int getMax()
- Get maximum value
setMin
public void setMin(int newMin)
- Set minimum value.
If the current value, or default values are less than the new minimum
they will be set to the new minimum. This in turn will fire any necessary
validations. If this change is voided, then nothing is done.
If you attempt to set the minimum above the maximum, it will be set to the
maximum.
- Parameters:
- newMin - The new minimum value.
getMin
public int getMin()
- Get minimum value
setUpVerb
public void setUpVerb(String newUpVerb)
- Sets the up verb.
- Parameters:
- newUpVerb - the new verb.
getUpVerb
public String getUpVerb()
- Gets the up verb.
setDownVerb
public void setDownVerb(String newDownVerb)
- Sets the down verb.
- Parameters:
- newDownVerb - the new verb.
getDownVerb
public String getDownVerb()
- Gets the down verb.
All Packages Class Hierarchy This Package Previous Next Index
|