Class VariableShifter
- java.lang.Object
-
- com.singularsys.extensions.rewrite.VariableShifter
-
- All Implemented Interfaces:
RewriteVisitor.VariableRuleI
,JepComponent
,java.io.Serializable
public class VariableShifter extends java.lang.Object implements RewriteVisitor.VariableRuleI
Replaces a variable "x" by "x + d" where d is a double value. This adds aNode.HookKey
to all matching variable nodes. These can be removed by callingremoveHooks(Node)
- Since:
- Jep 4.0/Extentions 2.1
- See Also:
RewriteVisitor
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VariableShifter(java.lang.String name, double value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Node
apply(ASTVarNode node)
Rewrites the nodeJepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.static Node.HookKey
getVariableShifterHook()
Hook used by this classvoid
init(Jep jep)
Initialize the component.static void
removeHooks(Node node)
Remove all instances of the hook used by this classboolean
test(ASTVarNode node)
Returns true if node needs to be rewritten, according to this rule.
-
-
-
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
-
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'.
-
test
public boolean test(ASTVarNode node) throws ParseException
Description copied from interface:RewriteVisitor.VariableRuleI
Returns true if node needs to be rewritten, according to this rule.- Specified by:
test
in interfaceRewriteVisitor.VariableRuleI
- Throws:
ParseException
- if for some reason rewriting cannot be performed.
-
apply
public Node apply(ASTVarNode node) throws ParseException
Description copied from interface:RewriteVisitor.VariableRuleI
Rewrites the node- Specified by:
apply
in interfaceRewriteVisitor.VariableRuleI
- Throws:
ParseException
-
removeHooks
public static void removeHooks(Node node) throws JepException
Remove all instances of the hook used by this class- Parameters:
node
-- Throws:
JepException
-
getVariableShifterHook
public static Node.HookKey getVariableShifterHook()
Hook used by this class- Returns:
-
-