Class VariableTableUpdater

java.lang.Object
com.singularsys.jep.misc.publishingvariable.VariableTableSubscriber
com.singularsys.jep.misc.publishingvariable.VariableTableUpdater
All Implemented Interfaces:
Flow.Subscriber<VariableTableAction>
Direct Known Subclasses:
PublishingVariableTest.SignallingTableUpdator

public class VariableTableUpdater extends VariableTableSubscriber
A VariableTableSubscriber that updates variables in the table when messages are received.

An example using the current thread is:

var pub = PublishingVariableTable.createCurrentThreadPublisher();
Jep jep = new Jep(new PublishingVariableTable(pub),
    new PublishingVariableFactory(pub));

var copy_jep = new Jep();
var copy_vt = copy_jep.getVariableTable();
var vtu = new VariableTableUpdater(copy_vt);
pub.subscribe(vtu);

var orig_x = jep.addVariable("x", 5.0);

var copy_x = copy_vt.getVariable("x");
assertEquals(5.0,copy_x.getValue());
  • Constructor Details

    • VariableTableUpdater

      public VariableTableUpdater(VariableTable vt)
      Constructor.
      Parameters:
      vt - the table to update when messages are received.
  • Method Details

    • variableChanged

      protected void variableChanged(String name, Object oldValue, Object newValue)
      Description copied from class: VariableTableSubscriber
      Called when a variable value has changed. Intended to be overridden by subclasses. Default implementation does nothing.
      Overrides:
      variableChanged in class VariableTableSubscriber
      Parameters:
      name - name of the variable
      oldValue - previous value of the variable
      newValue - value of the variable after the change
    • variableAdded

      protected void variableAdded(String name, Object value)
      Description copied from class: VariableTableSubscriber
      Called when a variable is added to the table. Intended to be overridden by subclasses. Default implementation does nothing.
      Overrides:
      variableAdded in class VariableTableSubscriber
      Parameters:
      name - the name of the variable which has been added.
      value - the value of the variable which has been added.
    • constantAdded

      protected void constantAdded(String name, Object value)
      Description copied from class: VariableTableSubscriber
      Called when a constant is added
      Overrides:
      constantAdded in class VariableTableSubscriber
      Parameters:
      name - name of variable
      value - value of variable
    • variableRemoved

      protected void variableRemoved(String name)
      Description copied from class: VariableTableSubscriber
      Called when a variable is removed from the table. Intended to be overridden by subclasses. Default implementation does nothing.
      Overrides:
      variableRemoved in class VariableTableSubscriber
      Parameters:
      name - the name of the variable which has been removed.
    • tableCleared

      protected void tableCleared()
      Description copied from class: VariableTableSubscriber
      Called when the variable table has been cleared. Intended to be overridden by subclasses. Default implementation does nothing.
      Overrides:
      tableCleared in class VariableTableSubscriber
    • clearNonConstants

      public void clearNonConstants()
      Description copied from class: VariableTableSubscriber
      Called when the non-constant variables have been removed. Intended to be overridden by subclasses. Default implementation does nothing.
      Overrides:
      clearNonConstants in class VariableTableSubscriber
    • onError

      public void onError(Throwable throwable)
      Called when there is an error in the publisher. This implementation throws a RuntimeException.
      Specified by:
      onError in interface Flow.Subscriber<VariableTableAction>
      Overrides:
      onError in class VariableTableSubscriber
      Parameters:
      throwable - the exception