Class NullWrappedFunctionFactory
- java.lang.Object
-
- com.singularsys.jep.misc.nullwrapper.NullWrappedFunctionFactory
-
- All Implemented Interfaces:
JepComponent
,java.io.Serializable
public class NullWrappedFunctionFactory extends java.lang.Object implements JepComponent
A factory to create the appropriate type of wrapped function.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NullWrappedFunctionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.protected PostfixMathCommandI
getSpecialFunction(PostfixMathCommandI fun)
Handles special functions.PostfixMathCommandI
getWrappedFunction(PostfixMathCommandI fun)
Gets a wrapped function, returns a function which will handle null values correctly.void
init(Jep jep)
Initialize the component.
-
-
-
Method Detail
-
getWrappedFunction
public PostfixMathCommandI getWrappedFunction(PostfixMathCommandI fun)
Gets a wrapped function, returns a function which will handle null values correctly. This method:- Calls
getSpecialFunction(PostfixMathCommandI)
and returns any non null results. - If
fun
implementsCallbackEvaluationI
then it cannot be wrapped and null is returned. - If
fun
implementsNullWrappedFunctionI
then it is alread wrapped andfun
is returned. - If
fun
implementsUnaryFunction
then it is wrapped byNullWrapperUnary
which is returned. - If
fun
implementsBinaryFunction
then it is wrapped byNullWrapperBinary
which is returned. - If
fun
implementsNaryFunction
then it is wrapped byNullWrapperNary
which is returned. - If
fun
implementsNaryBinaryFunction
then it is wrapped byNullWrapperNaryBinary
which is returned. - If
fun
has zero arguments then it does not need to wrap functions andfun
. - If
fun
implementsPostfixMathCommand
then it is wrapped byNullWrapperPfmc
which is returned. - Otherwise
fun
is returned.
- Parameters:
fun
- the function to be wrapped- Returns:
- the wrapped function or null see above for details
- Calls
-
getSpecialFunction
protected PostfixMathCommandI getSpecialFunction(PostfixMathCommandI fun)
Handles special functions. Subclasses can override this method to add treatment of other special functions. This methods performs the following actions:If
andTernaryConditional
are replaced byNullWrappedIf
.LazyLogical
functions are replaced byNullLazyLogical
.- Increment functions which extend
AbstractInc
are wrapped byNullAbstractInc
Assign
,List
,Ele
,IsNull
, all handle null correctly so the original function is returned.- For
Case
,Switch
,SwitchDefault
instances of these which handle nulls correctly are returned.
- Parameters:
fun
- original function- Returns:
- the new function or null if no special function found.
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- this
-
init
public void init(Jep jep)
Description copied from interface:JepComponent
Initialize the component. This methods 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:
jep
- the current Jep instance
-
-