Package com.singularsys.jep.misc.publishingvariable

# 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 Summary

  Constructors
  Constructor
  Description
  `VariableTableUpdater(VariableTable vt)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearNonConstants()`
  Called when the non-constant variables have been removed.
  `protected void`
  `constantAdded(String name, Object value)`
  Called when a constant is added
  `void`
  `onError(Throwable throwable)`
  Called when there is an error in the publisher.
  `protected void`
  `tableCleared()`
  Called when the variable table has been cleared.
  `protected void`
  `variableAdded(String name, Object value)`
  Called when a variable is added to the table.
  `protected void`
  `variableChanged(String name, Object oldValue, Object newValue)`
  Called when a variable value has changed.
  `protected void`
  `variableRemoved(String name)`
  Called when a variable is removed from the table.

  ### Methods inherited from class com.singularsys.jep.misc.publishingvariable.VariableTableSubscriber

  `cancel, onComplete, onNext, onSubscribe`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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