Class PublishingVariableFactory
java.lang.Object
com.singularsys.jep.VariableFactory
com.singularsys.jep.misc.publishingvariable.PublishingVariableFactory
- All Implemented Interfaces:
JepComponent,Serializable
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:
-
Field Summary
Fields inherited from class com.singularsys.jep.VariableFactory
defaultValue -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with a specified of SubmissionPublishers. -
Method Summary
Modifier and TypeMethodDescriptioncreateVariable(String name) Create a variable with a name but not value CallsVariableFactory.createVariable(String, Object)so subclasses need not override this method.createVariable(String name, Object value) Create a variable with a name and value.Create a light weight instance of this factory.Get the current publisher for the variables created by this factory.voidInitialize the component.voidsetPublisher(SubmissionPublisher<VariableTableAction> publisher) Set the publisher for the variables created by this factory.Methods inherited from class com.singularsys.jep.VariableFactory
copyVariable, getDefaultValue, setDefaultValue
-
Constructor Details
-
PublishingVariableFactory
Constructor with a specified of SubmissionPublishers.If the publisher is null, then the variables created by this factory will not, by default publish any changes, however, the publisher can be set later using the
PublishingVariable.setPublisher(SubmissionPublisher).- Parameters:
pub- the SubmissionPublishers, this can be null
-
-
Method Details
-
init
Description copied from interface:JepComponentInitialize 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:
initin interfaceJepComponent- Overrides:
initin classVariableFactory- Parameters:
j- the current Jep instance
-
createVariable
Description copied from class:VariableFactoryCreate a variable with a name and value. Subclasses should overwrite this method to return variables of the correct type- Overrides:
createVariablein classVariableFactory- Parameters:
name- name of variablevalue- initial value- Returns:
- reference to Variable object
-
createVariable
Description copied from class:VariableFactoryCreate a variable with a name but not value CallsVariableFactory.createVariable(String, Object)so subclasses need not override this method.- Overrides:
createVariablein classVariableFactory- Parameters:
name- name of variable- Returns:
- reference to Variable object
-
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 callingsetPublisher(SubmissionPublisher)on the new instance.- Specified by:
getLightWeightInstancein interfaceJepComponent- Overrides:
getLightWeightInstancein classVariableFactory- Returns:
- a new PublishingVariableFactory with a null publisher.
-
getPublisher
Get the current publisher for the variables created by this factory.- Returns:
- the publisher
-
setPublisher
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
-