Class PublishingVariableFactory

java.lang.Object
com.singularsys.jep.VariableFactory
com.singularsys.jep.misc.publishingvariable.PublishingVariableFactory
All Implemented Interfaces:
JepComponent, Serializable

public class PublishingVariableFactory extends VariableFactory
A factory for creating PublishingVariables. Each variable created by this factory will use the same SubmissionPublisher to publish changes to its value, so by default all changes to variables will be reported by the same publisher.

If you only want to monitor some variables, set the publisher to null in the PublishingVariableFactory(SubmissionPublisher) constructor and set the individual variables publisher using the PublishingVariable.setPublisher(SubmissionPublisher) method.

The publisher can be shared with a PublishingVariableTable to also report changes to the table, such as adding and removing variables.

Since:
Jep 4.1
See Also:
  • Constructor Details

  • Method Details

    • init

      public void init(Jep j)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Overrides:
      init in class VariableFactory
      Parameters:
      j - the current Jep instance
    • createVariable

      public Variable createVariable(String name, Object value)
      Description copied from class: VariableFactory
      Create a variable with a name and value. Subclasses should overwrite this method to return variables of the correct type
      Overrides:
      createVariable in class VariableFactory
      Parameters:
      name - name of variable
      value - initial value
      Returns:
      reference to Variable object
    • createVariable

      public Variable createVariable(String name)
      Description copied from class: VariableFactory
      Create a variable with a name but not value Calls VariableFactory.createVariable(String, Object) so subclasses need not override this method.
      Overrides:
      createVariable in class VariableFactory
      Parameters:
      name - name of variable
      Returns:
      reference to Variable object
    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Create a light weight instance of this factory. This creates a new instance of this factory with a null publisher. The publisher can then be set by calling setPublisher(SubmissionPublisher) on the new instance.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Overrides:
      getLightWeightInstance in class VariableFactory
      Returns:
      a new PublishingVariableFactory with a null publisher.
    • getPublisher

      public SubmissionPublisher<VariableTableAction> getPublisher()
      Get the current publisher for the variables created by this factory.
      Returns:
      the publisher
    • setPublisher

      public void setPublisher(SubmissionPublisher<VariableTableAction> publisher)
      Set the publisher for the variables created by this factory. Any variables created by this factory after setting the publisher will use the new publisher to publish changes to their value.
      Parameters:
      publisher - the publisher to set