public class VariableAccessReplacer
extends Object
Replace all access to variables and args by new variables. The variable names to replace as well as their replacement name and type have to be configured in nameAndTypeMapping before calling replaceIn().
The VariableReplacedListener can be set if clients want to react to variable replacement.
| Constructor and description |
|---|
VariableAccessReplacer(Map<String, Map> nameAndTypeMapping)Creates a replacer with the supplied name/type mapping. |
VariableAccessReplacer(Map<String, Map> nameAndTypeMapping, VariableReplacedListener listener)Creates a replacer with the supplied name/type mapping and listener. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public VariableReplacedListener |
getListener()Returns the listener notified when replacements occur. |
|
public void |
replaceIn(ASTNode root)Replaces matching variable accesses within the supplied AST subtree. |
|
public void |
setListener(VariableReplacedListener listener)Sets the listener notified when replacements occur. |
|
public void |
setNameAndTypeMapping(Map<String, Map> nameAndTypeMapping)Sets the variable replacement mapping. |
Creates a replacer with the supplied name/type mapping.
nameAndTypeMapping - the variables to replace and their replacementsCreates a replacer with the supplied name/type mapping and listener.
nameAndTypeMapping - the variables to replace and their replacementslistener - the listener notified about replacementsReturns the listener notified when replacements occur.
Replaces matching variable accesses within the supplied AST subtree.
root - the AST subtree to mutateSets the listener notified when replacements occur.
listener - the replacement listenerCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.