Class PublishingVariable

java.lang.Object
com.singularsys.jep.Variable
com.singularsys.jep.misc.publishingvariable.PublishingVariable
All Implemented Interfaces:
Serializable

public class PublishingVariable extends Variable
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:
  • Constructor Details

    • PublishingVariable

      public PublishingVariable(String name, SubmissionPublisher<VariableTableAction> pub)
      Create a variable with a given publisher
      Parameters:
      name - name of variable
      pub - the SubmissionPublisher
    • PublishingVariable

      public PublishingVariable(String name, Object value, SubmissionPublisher<VariableTableAction> pub)
      Create a variable with a given publisher
      Parameters:
      name - name of variable
      value - initial value of the variable
      pub - the SubmissionPublisher
  • Method Details

    • setValue

      public boolean setValue(Object object)
      Sets the value of the variable and publishes a message if the publisher is not null.
      Overrides:
      setValue in class Variable
      Parameters:
      object - the new value
      Returns:
      false if tried to change a constant value.
      Throws:
      IllegalStateException - if the publisher is closed.
    • getPublisher

      public SubmissionPublisher<VariableTableAction> getPublisher()
      Get the publisher for this variable.
      Returns:
      the publisher
    • setPublisher

      public void setPublisher(SubmissionPublisher<VariableTableAction> publisher)
      Set the publisher for this variable. If you just need to watch a subset of variables, you can use create a PublishingVariableFactory with null SubmissionPublisher and then set the publisher for the variables you want to watch.
      Parameters:
      publisher - the publisher to set