public interface PatternWorker
| Modifier and Type | Method and Description |
|---|---|
default void |
finish()
This method is called once (and only once) per invocation of the
pattern engine's
PatternEngine.run() method, after all rulesets
are processed, and after the pattern engine's own global post-rules
are processed. |
java.lang.Object |
getLibrary()
This method should return a worker library to be registered with the
expression engine's symbol resolver, if the implementation wishes to
expose bean-like properties or user functions to user expressions.
|
default void |
initialize()
This method is called once (and only once) per invocation of the
pattern engine's
PatternEngine.run() method, immediately after
the worker object is constructed. |
default void |
leaveAst(Aast ast)
This method is called each time an AST walk is complete, to permit cleanup scoped to that AST walk.
|
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.
|
default void |
visitAst(Aast ast)
This method is called each time a new AST is visited, just before the
pattern engine processes that AST.
|
default void initialize()
PatternEngine.run() method, immediately after
the worker object is constructed. This hook is provided to give the
worker implementation an opportunity to register symbol resolution
libraries with the pattern engine's symbol resolver, as well as to
perform any internal initialization.default void finish()
PatternEngine.run() method, after all rulesets
are processed, and after the pattern engine's own global post-rules
are processed. This hook is provided to allow the worker implementation
to perform any necessary resource cleanup or other post-processing. It
is safe to assume that no rule will be executed after this method
completes.java.lang.Object getLibrary()
It is invoked by a RuleContainer when it registers the
pattern worker implementation.
null if the pattern
worker implementation does not need to register a library.java.lang.Object resolveConstant(java.lang.String constant)
It must return an object of the following type (or null):
constant - A string representing a constant to be resolved.null
if constant was not recognized as a placeholder
for a literal.default void visitAst(Aast ast)
ast - The root node of the source AST about to be processed by the pattern engine
By convention, the worker should not modify this AST now or during the walk.default void leaveAst(Aast ast)
ast - The root node of the copy AST just processed by the pattern engine. This is
not the same AST instance passed to visitAst(Aast) at the beginning of the walk;
this AST may have been annotated and otherwise modified during the walk.