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
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the non-constant variables have been removed.protected voidconstantAdded(String name, Object value) Called when a constant is addedvoidCalled when there is an error in the publisher.protected voidCalled when the variable table has been cleared.protected voidvariableAdded(String name, Object value) Called when a variable is added to the table.protected voidvariableChanged(String name, Object oldValue, Object newValue) Called when a variable value has changed.protected voidvariableRemoved(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
-
Constructor Details
-
VariableTableUpdater
Constructor.- Parameters:
vt- the table to update when messages are received.
-
-
Method Details
-
variableChanged
Description copied from class:VariableTableSubscriberCalled when a variable value has changed. Intended to be overridden by subclasses. Default implementation does nothing.- Overrides:
variableChangedin classVariableTableSubscriber- Parameters:
name- name of the variableoldValue- previous value of the variablenewValue- value of the variable after the change
-
variableAdded
Description copied from class:VariableTableSubscriberCalled when a variable is added to the table. Intended to be overridden by subclasses. Default implementation does nothing.- Overrides:
variableAddedin classVariableTableSubscriber- Parameters:
name- the name of the variable which has been added.value- the value of the variable which has been added.
-
constantAdded
Description copied from class:VariableTableSubscriberCalled when a constant is added- Overrides:
constantAddedin classVariableTableSubscriber- Parameters:
name- name of variablevalue- value of variable
-
variableRemoved
Description copied from class:VariableTableSubscriberCalled when a variable is removed from the table. Intended to be overridden by subclasses. Default implementation does nothing.- Overrides:
variableRemovedin classVariableTableSubscriber- Parameters:
name- the name of the variable which has been removed.
-
tableCleared
protected void tableCleared()Description copied from class:VariableTableSubscriberCalled when the variable table has been cleared. Intended to be overridden by subclasses. Default implementation does nothing.- Overrides:
tableClearedin classVariableTableSubscriber
-
clearNonConstants
public void clearNonConstants()Description copied from class:VariableTableSubscriberCalled when the non-constant variables have been removed. Intended to be overridden by subclasses. Default implementation does nothing.- Overrides:
clearNonConstantsin classVariableTableSubscriber
-
onError
Called when there is an error in the publisher. This implementation throws a RuntimeException.- Specified by:
onErrorin interfaceFlow.Subscriber<VariableTableAction>- Overrides:
onErrorin classVariableTableSubscriber- Parameters:
throwable- the exception
-