Package com.singularsys.jep
Class VariableFactory
java.lang.Object
com.singularsys.jep.VariableFactory
- All Implemented Interfaces:
JepComponent
,Serializable
A factory class which is used to create variables.
By default, this class creates variables of type
Variable
.
This class should be sub-classed if the type of variable used needs to be
changed.
This class is passed to the constructor of VariableTable
which ensures that variables of the correct type are always created.
This class should only be called from the VariableTable class and not from application code.
- Since:
- 23 July 2006 - allows a defaultValue to be set.
- Author:
- Rich Morris Created on 19-Dec-2003
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Object
The default value to use when variable is created with no value -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopyVariable
(Variable var) Create a new variable which is a copy of this one.createVariable
(String name) Create a variable with a name but not value CallscreateVariable(String, Object)
so subclasses need not override this method.createVariable
(String name, Object value) Create a variable with a name and value.Gets a light-weight instance suitable for using in multiple threads.void
Initialize the component.void
setDefaultValue
(Object defaultValue) Sets the default value used whenever a new variable is created.
-
Field Details
-
defaultValue
The default value to use when variable is created with no value
-
-
Constructor Details
-
VariableFactory
public VariableFactory()
-
-
Method Details
-
init
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 interfaceJepComponent
- Parameters:
j
- the current Jep instance
-
createVariable
Create a variable with a name and value. Subclasses should overwrite this method to return variables of the correct type- Parameters:
name
- name of variablevalue
- initial value- Returns:
- reference to Variable object
-
createVariable
Create a variable with a name but not value CallscreateVariable(String, Object)
so subclasses need not override this method.- Parameters:
name
- name of variable- Returns:
- reference to Variable object
-
copyVariable
Create a new variable which is a copy of this one. Copies the isConstant and isValidValue flags copies all hook key value pairs. CallscreateVariable(String, Object)
so subclasses need not override this method, unless there are other fields which need to be copied.- Parameters:
var
-- Returns:
-
getDefaultValue
- Returns:
- Returns the defaultValue.
-
setDefaultValue
Sets the default value used whenever a new variable is created.- Parameters:
defaultValue
- The defaultValue to set.
-
getLightWeightInstance
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- either a new instance, null or 'this'.
-