public class NameConverterWorker extends AbstractPatternWorker implements MatchPhraseConstants
NameConverter
class.
An automatic name conversion reporting facility can be triggered from a
ruleset. This mode is disabled by default. It is enabled with the NameConverterWorker.Library.setReportMode(boolean)
user function. As this worker
converts names, a formatted history entry for each conversion is recorded.
At the end of processing (i.e., in a post-rule ruleset), a text report is
generated with NameConverterWorker.Library.generateReport(java.lang.String)
. The
report is written to a file which the caller specifies.
Modifier and Type | Class and Description |
---|---|
class |
NameConverterWorker.Library
Class whose instance is actually registered with the pattern engine's
symbol resolver as the primary library of name conversion user
functions.
|
Modifier and Type | Field and Description |
---|---|
private NameConverter |
defaultConverter |
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
history
History lists of name conversions, indexed by AST filename
|
private static java.lang.String |
RPT_FMT
Format specifier for the column report output.
|
private static java.util.Map<java.lang.String,java.lang.Long> |
TYPE_MAP
Map of conversion type literals, exposed by their constant names
|
resolver
ALL, CUSTOM, PRESERVE, STANDARD, TYPE_CLASS, TYPE_COLUMN, TYPE_CONSTANT, TYPE_DATABASE, TYPE_INDEX, TYPE_METHOD, TYPE_PROPERTY, TYPE_SIMPLE, TYPE_TABLE, TYPE_VARIABLE
Constructor and Description |
---|
NameConverterWorker()
Default constructor which defines the symbol libraries to be registered.
|
Modifier and Type | Method and Description |
---|---|
private void |
recordHistory(NameConverter converter,
java.lang.String result,
java.lang.String detail)
Helper method which records information about a name conversion.
|
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.
|
void |
visitAst(Aast ast)
Called whenever the pattern engine visits a new AST, this method
prepares the history report facility to receive entries for names
converted while processing the AST.
|
finish, getCopy, getLibrary, getSource, initialize, registerTree, setLibrary
private static final java.lang.String RPT_FMT
private static final java.util.Map<java.lang.String,java.lang.Long> TYPE_MAP
private NameConverter defaultConverter
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> history
public NameConverterWorker()
public java.lang.Object resolveConstant(java.lang.String constant)
Long
values, so that the conversion types can be
referenced by their NameConverter
constant names from within
within user expressions.resolveConstant
in interface PatternWorker
resolveConstant
in class AbstractPatternWorker
constant
- A string representing a conversion type constant to be
resolved.Long
initialized to the corresponding constant
value (values in NameConverter
class), or
null
if constant
was not recognized
as a placeholder for such a literal.public void visitAst(Aast ast)
If report mode is turned off, this method returns immediately.
visitAst
in interface PatternWorker
visitAst
in class AbstractPatternWorker
ast
- AST about to be processed by the pattern engine.private void recordHistory(NameConverter converter, java.lang.String result, java.lang.String detail)
converter
- Object which performed the name conversion.result
- The name resulting from the conversion.detail
- Additional notes.