Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.StateMachine
Source: src/com/multiversesocial/hyperview/StateMachine.java

StateMachine

HyperView V3.2 — class
version V3.2 class

Summary

A basic state machine by Tony Swain. This is designed to work from one Thread. Thus never a need to synchronize

Source file: StateMachine.java

Hierarchy

Extends: none

Implements: StateMachineConstants, StateMachineListener

Referenced HyperView classes

Media files used

Declaration & members

public class StateMachine implements StateMachineConstants, StateMachineListener

Declared in src/com/multiversesocial/hyperview/StateMachine.java, lines 12–445. 10 field(s), 3 constructor(s), 8 method(s), plus 9 nested type(s). Every member has an anchor you can link to (e.g. StateMachine.html#<id>).

Fields (10)

DeclarationValue / initializerDescriptionSource
private int allocatedStatesNo comment in source; assigned in add(); used in toString().line 18
byte[] bufferNo comment in source; assigned in StateMachine(), cleanUp().line 22
int bufferSizeNo comment in source; assigned in StateMachine(); used in toString().line 23
int currentStateNo comment in source; used in toString().line 19
public static final int MAX_STATES= 8 (constant)byte/short/char/int/long/float/double/String/data[n]line 16
private StateMachineListener notifierNo comment in source; assigned in StateMachine(), addNotifier(), removeNotifier(), cleanUp(); used in toString().line 15
StateDispatch[] stateDispatchNo comment in source; assigned in StateMachine(), makeStateObjects(), add(), cleanUp(); used in toString().line 17
public volatile int stateFlagsNo comment in source; assigned in StateMachine(), orStateFlags(); used in getStateFlags(), toString().line 14
volatile int systemBufferIndexNo comment in source; used in toString().line 21
volatile int userBufferIndexNo comment in source; used in toString().line 20

Constructors (3)

SignatureDescriptionSource
StateMachine()3 statement(s); calls super().line 25
StateMachine(StateMachineListener tNotifier)6 statement(s); calls super(), makeStateObjects().line 31
StateMachine(HyperConnectionNode tNode, StateMachineListener tNotifier)6 statement(s); calls super(), makeStateObjects().line 40

Methods (8)

SignatureDescriptionSource
int add(StateDispatch tDispatch) throws StateMachine.OutOfChannelSpaceException4 statement(s); creates OutOfChannelSpaceException.line 75
public void addNotifier(StateMachineListener tObject) throws StateMachine.IllegalStateMachineAddObjectNotifierException2 statement(s); creates IllegalStateMachineAddObjectNotifierException.line 121
public void cleanUp()3 statement(s).line 135
public int getStateFlags()Returns stateFlags.
Implements StateMachineListener.getStateFlags()
line 50
public void makeStateObjects()2 statement(s); creates GetByte, GetShort, GetChar.line 61
public int orStateFlags(int tInt)2 statement(s).
Implements StateMachineListener.orStateFlags()
line 55
public void removeNotifier()Sets notifier = null.line 130
public String toString()13 statement(s); calls sb.append(), notifier.toString(), stateDispatch[tz].toString(), sb.toString(); creates StringBuilder.
Overrides Object.toString()
line 87

Nested & additional classes

GetByte (nested type, lines 145–184)

class GetByte extends StateDispatch

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
GetByte()1 statement(s); calls super().line 147

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)5 statement(s); calls System.exit(), readBuffer.get(), notifier.notifyAll().
Overrides StateDispatch.processInput()
line 152

GetShort (nested type, lines 188–242)

class GetShort extends StateDispatch

Fields (3)

DeclarationValue / initializerDescriptionSource
int countNo comment in source; assigned in GetShort().line 190
int currentByteNo comment in source; assigned in GetShort().line 192
short inValNo comment in source; assigned in GetShort().line 191

Constructors (1)

SignatureDescriptionSource
GetShort()3 statement(s); calls super().line 194

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)7 statement(s); calls System.exit(), readBuffer.get(), notifier.orStateFlags(), notifier.notifyAll().
Overrides StateDispatch.processInput()
line 202

GetChar (nested type, lines 246–294)

class GetChar extends StateDispatch

Fields (3)

DeclarationValue / initializerDescriptionSource
private int currentByteNo comment in source; assigned in GetChar(); used in processInput().line 249
public volatile int inLengthNo comment in source; assigned in GetChar().line 248
private int retValNo comment in source; assigned in GetChar(), processInput().line 250

Constructors (1)

SignatureDescriptionSource
GetChar()2 statement(s); calls super().line 252

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)10 statement(s); calls System.exit(), readBuffer.get(), notifier.notifyAll().
Overrides StateDispatch.processInput()
line 257

GetInt (nested type, lines 299–347)

class GetInt extends StateDispatch

Fields (3)

DeclarationValue / initializerDescriptionSource
private int currentByteNo comment in source; assigned in GetInt(); used in processInput().line 302
public volatile int inLengthNo comment in source; assigned in GetInt().line 301
private int retValNo comment in source; assigned in GetInt(), processInput().line 303

Constructors (1)

SignatureDescriptionSource
GetInt()2 statement(s); calls super().line 305

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)10 statement(s); calls System.exit(), readBuffer.get(), notifier.notifyAll().
Overrides StateDispatch.processInput()
line 310

GetLong (nested type, lines 351–396)

class GetLong extends StateDispatch

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
GetLong()1 statement(s); calls super().line 353

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)12 statement(s); calls System.exit(), readBuffer.get(), notifier.notifyAll().
Overrides StateDispatch.processInput()
line 357

GetString (nested type, lines 400–410)

class GetString extends StateDispatch

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
GetString()1 statement(s); calls super().line 402

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)Returns -1.
Overrides StateDispatch.processInput()
line 406

GetData (nested type, lines 415–427)

class GetData extends StateDispatch

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
GetData()1 statement(s); calls super().line 418

Methods (1)

SignatureDescriptionSource
public int processInput(HyperNodeReadVector tReadVector, int tLength)Returns -1.
Overrides StateDispatch.processInput()
line 422

OutOfChannelSpaceException (nested type, lines 429–435)

class OutOfChannelSpaceException extends Exception

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
OutOfChannelSpaceException()1 statement(s); calls super().line 431

Methods (0)

None declared.

IllegalStateMachineAddObjectNotifierException (nested type, lines 437–443)

class IllegalStateMachineAddObjectNotifierException extends Exception

Fields (0)

None declared.

Constructors (1)

SignatureDescriptionSource
IllegalStateMachineAddObjectNotifierException()1 statement(s); calls super().line 439

Methods (0)

None declared.

Examples

Real usage taken from elsewhere in the HyperView 3.2 source (file and line shown; source path src/com/multiversesocial/hyperview/).

instantiation — HyperConnectionNode.java, line 129

  129  stateMachine = new StateMachine(this,(StateMachineListener)null);

subclass — ServerStateMachine.java, line 8

    8  public class ServerStateMachine extends StateMachine
    9  {

declaration — HyperNodeReadVector.java, line 17

   17  StateMachine stateMachine      = null;
Hits--