public abstract class AbstractPatternWorker extends java.lang.Object implements PatternWorker
The most important usage note is that it is not possible for sub-classes
to pass the libraries
array of Object
instances
(the list of exported libraries to register) in the constructor of a
super class. For this reason, a separate setLibraries
method has been provided which must be called in the sub-class'
constructor, after the super
constructor has been
invoked.
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
library
Library object (exports functions/variables to rulesets) to register
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractPatternWorker()
Default constructor, which can only be called by a sub-class.
|
Modifier and Type | Method and Description |
---|---|
void |
finish()
Hook to provide termination processing for a pattern worker.
|
protected Aast |
getCopy()
Get the current copy AST.
|
java.lang.Object |
getLibrary()
Get the user function/property library exposed by this pattern worker.
|
protected AstSymbolResolver |
getResolver()
Get the
AstSymbolResolver for the current context. |
protected Aast |
getSource()
Get the current source AST.
|
void |
initialize()
Initialization, no work done by default.
|
boolean |
isConditionalRuleSets()
Check if conditional rule-sets is activated.
|
boolean |
isFlagActivated(java.lang.String flag)
If conditional rule-set is enabled, check if the given flag is activated.
|
boolean |
isRuntimeQueryMode()
Check if the current mode is for runtime-conversion of query/tables.
|
void |
registerTree(Aast ast)
Register the given tree with the AST resolver.
|
java.lang.Object |
resolveConstant(java.lang.String constant)
This method is called each time the pattern engine needs to resolve
a string constant into a numeric, boolean, or string literal value.
|
protected void |
setLibrary(java.lang.Object library)
Sets the library that must be registered.
|
void |
visitAst(Aast ast)
This method is called each time a new AST is visited, just before the
pattern engine processes that AST.
|
private java.lang.Object library
protected AbstractPatternWorker()
public void initialize()
initialize
in interface PatternWorker
public boolean isRuntimeQueryMode()
public boolean isFlagActivated(java.lang.String flag)
flag
- The flag to check.PatternEngine.isFlagActivated(String)
public boolean isConditionalRuleSets()
PatternEngine.isConditionalRuleSets()
public void registerTree(Aast ast)
ast
- Tree to register.public void finish()
finish
in interface PatternWorker
public java.lang.Object getLibrary()
getLibrary
in interface PatternWorker
null
if the pattern
worker implementation does not need to register a library.PatternWorker.getLibrary()
public java.lang.Object resolveConstant(java.lang.String constant)
It must return an object of the following type (or null
):
resolveConstant
in interface PatternWorker
constant
- A string representing a constant to be resolved.null
.public void visitAst(Aast ast)
visitAst
in interface PatternWorker
ast
- The root node of the source AST about to be processed by the
pattern engine.protected void setLibrary(java.lang.Object library)
library
- Instance of exported libraries to be registered with the
resolver
. Must not be null
.java.lang.IllegalArgumentException
- if library
is null
.protected Aast getSource()
protected Aast getCopy()
protected AstSymbolResolver getResolver()
AstSymbolResolver
for the current context.AstSymbolResolver.getResolver()