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 NodeFactory
nf
A 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 Node
apply(ASTConstant node)
Rewrites the node.JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.double
getTolerance()
void
init(Jep jep)
Initialize the component.void
setTolerance(double tolerance)
boolean
test(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: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
-
test
public boolean test(ASTConstant node) throws ParseException
Description copied from interface:RewriteVisitor.ConstantRuleI
Returns true if node needs to be rewritten, according to this rule.- Specified by:
test
in 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.ConstantRuleI
Rewrites the node. Note a new node must be constructed rather than simply changing the value.- Specified by:
apply
in interfaceRewriteVisitor.ConstantRuleI
- Throws:
ParseException
-
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:
- either an new instance, null or 'this'.
-
getTolerance
public double getTolerance()
-
setTolerance
public void setTolerance(double tolerance)
-
-