Class SmallNumberRule
java.lang.Object
com.singularsys.extensions.rewrite.SmallNumberRule
- All Implemented Interfaces:
RewriteVisitor.ConstantRuleI,JepComponent,Serializable
A rule where numbers very close to zero are replaces by zero.
- Since:
- Jep 4.0/Extensions 2.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NodeFactoryA NodeFactory used for construction nodes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(ASTConstant node) Rewrites the node.Gets a light-weight instance suitable for using in multiple threads.doublevoidInitialize the component.voidsetTolerance(double tolerance) booleantest(ASTConstant node) Returns true if node needs to be rewritten, according to this rule.
-
Field Details
-
nf
A NodeFactory used for construction nodes.
-
-
Constructor Details
-
SmallNumberRule
public SmallNumberRule(double tolerance) Create the rule- Parameters:
tolerance- numbers smaller than this are considered zero
-
-
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- Parameters:
jep- the current Jep instance
-
test
Description copied from interface:RewriteVisitor.ConstantRuleIReturns true if node needs to be rewritten, according to this rule.- Specified by:
testin interfaceRewriteVisitor.ConstantRuleI
-
apply
Description copied from interface:RewriteVisitor.ConstantRuleIRewrites the node. Note a new node must be constructed rather than simply changing the value.- Specified by:
applyin interfaceRewriteVisitor.ConstantRuleI- Throws:
ParseException
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-
getTolerance
public double getTolerance() -
setTolerance
public void setTolerance(double tolerance)
-