Class SmallNumberRule
- java.lang.Object
-
- com.singularsys.extensions.rewrite.SmallNumberRule
-
- All Implemented Interfaces:
RewriteVisitor.ConstantRuleI,JepComponent,java.io.Serializable
public class SmallNumberRule extends java.lang.Object implements RewriteVisitor.ConstantRuleI
A rule where numbers very close to zero are replaces by zero.- Since:
- Jep 4.0/Extentions 2.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected NodeFactorynfA NodeFactory used for construction nodes.
-
Constructor Summary
Constructors Constructor Description SmallNumberRule(double tolerance)Create the rule
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Nodeapply(ASTConstant node)Rewrites the node.JepComponentgetLightWeightInstance()Gets a light-weight instance suitable for using in multiple threads.doublegetTolerance()voidinit(Jep jep)Initialize the component.voidsetTolerance(double tolerance)booleantest(ASTConstant node)Returns true if node needs to be rewritten, according to this rule.
-
-
-
Field Detail
-
nf
protected NodeFactory nf
A NodeFactory used for construction nodes.
-
-
Method Detail
-
init
public void init(Jep jep)
Description copied from interface:JepComponentInitialize 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
test
public boolean test(ASTConstant node) throws ParseException
Description copied from interface:RewriteVisitor.ConstantRuleIReturns true if node needs to be rewritten, according to this rule.- Specified by:
testin interfaceRewriteVisitor.ConstantRuleI- Throws:
ParseException- if for some reason rewriting cannot be performed.
-
apply
public Node apply(ASTConstant node) throws ParseException
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
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either an new instance, null or 'this'.
-
getTolerance
public double getTolerance()
-
setTolerance
public void setTolerance(double tolerance)
-
-