Class PublishingVariable
java.lang.Object
com.singularsys.jep.Variable
com.singularsys.jep.misc.publishingvariable.PublishingVariable
- All Implemented Interfaces:
Serializable
A Variable that can publish messages when its value is changed.
These are normally created by a
PublishingVariableFactory
which sets the publisher in the constructor.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPublishingVariable(String name, Object value, SubmissionPublisher<VariableTableAction> pub) Create a variable with a given publisherCreate a variable with a given publisher -
Method Summary
Modifier and TypeMethodDescriptionGet the publisher for this variable.voidsetPublisher(SubmissionPublisher<VariableTableAction> publisher) Set the publisher for this variable.booleanSets the value of the variable and publishes a message if the publisher is not null.Methods inherited from class com.singularsys.jep.Variable
copyPropertiesFrom, getHook, getName, getValue, hasValidValue, hookKeys, isConstant, removeHook, setHook, setIsConstant, setValidValue, setValueRaw, toString
-
Constructor Details
-
PublishingVariable
Create a variable with a given publisher- Parameters:
name- name of variablepub- the SubmissionPublisher
-
PublishingVariable
Create a variable with a given publisher- Parameters:
name- name of variablevalue- initial value of the variablepub- the SubmissionPublisher
-
-
Method Details
-
setValue
Sets the value of the variable and publishes a message if the publisher is not null.- Overrides:
setValuein classVariable- Parameters:
object- the new value- Returns:
- false if tried to change a constant value.
- Throws:
IllegalStateException- if the publisher is closed.
-
getPublisher
Get the publisher for this variable.- Returns:
- the publisher
-
setPublisher
Set the publisher for this variable. If you just need to watch a subset of variables, you can use create aPublishingVariableFactorywith nullSubmissionPublisherand then set the publisher for the variables you want to watch.- Parameters:
publisher- the publisher to set
-