abstract class DynamicConversionHelper
extends java.lang.Object
DynamicQueryHelper
and
DynamicValidationHelper
.Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.lang.Integer> |
wrapperToTokenType
Map of P2J wrappers to their associated token type.
|
Constructor and Description |
---|
DynamicConversionHelper() |
Modifier and Type | Method and Description |
---|---|
private static DataModelAst |
buildDataModelClass(Buffer buf,
RecordBuffer rbuf,
java.lang.String p2oFile)
Create a
data model object AST for the specified buffer. |
private static DataModelAst |
buildIndex(Buffer buf,
RecordBuffer rbuf,
P2JIndex index,
java.lang.String idxName,
java.util.Map<java.lang.String,DataModelAst> propMap,
java.lang.String p2oFile)
Build a
index for the specified buffer. |
private static DataModelAst |
buildIndexComponent(P2JIndexComponent comp,
DataModelAst propAst,
java.lang.String p2oFile)
Build an
index component associated with the given property AST. |
private static DataModelAst |
buildProperty(Buffer buf,
java.lang.reflect.Field field,
int extent,
java.lang.String p2oFile)
Create a
property AST for the specified DMO java field. |
private static DataModelAst |
buildRootDataModel(java.lang.String schema,
java.lang.String p2oFile)
Build the
root AST and associated with the given schema. |
private static ProgressAst |
buildRootSchema(java.lang.String schema)
Build the root
ProgressAst node for the schema dictionary AST. |
private static ProgressAst |
buildTempTable(DataModelAst p2o,
RecordBuffer rbuf,
integer order)
Build a temp-table definition to be loaded in the
SchemaDictionary . |
private static DataModelAst |
createDataModelAst(int type,
java.lang.String text,
java.lang.String p2oFile)
Create a
DataModelAst with the given token type and text. |
private static ProgressAst |
createProgressAst(int type,
java.lang.String text)
Create a
ProgressAst with the given token type and text. |
private static ProgressAst |
getSibling(ProgressAst progAst)
Obtain the other operand of a binary operator node.
|
(package private) static java.lang.Object |
injectVariable(ProgressAst[] litAsts,
java.lang.String varName,
ProgressAst progAst)
Injects a new variable in place of a literal or field reference.
|
(package private) static java.lang.Object |
injectVariable(ProgressAst litAst,
java.lang.String varName,
ProgressAst progAst)
Injects a new variable in place of a literal or field reference.
|
(package private) static int |
locateBuffer(java.util.List<Buffer> buffers,
java.lang.String name)
Locate a
Buffer with the given name , from the specified list of buffers,
and return its position. |
(package private) static void |
prepareTempTable(SchemaDictionary dict,
java.lang.StringBuilder pcode,
java.lang.String p2oFile,
java.util.List<Buffer> buffers)
Process the definitions of the temp-tables (associated with the temporary buffers in the
given list) to create the associated dictionary and p2o ASTs.
|
(package private) static void |
prepareTree(AnnotatedAst root,
java.util.List<Buffer> buffers,
java.lang.String fileName,
java.lang.String javaClassName)
Prepare the query AST by placing the appropriate annotations with the converted java names
for the external program and also by created bogus
ProgressParserTokenTypes.DEFINE_TEMP_TABLE nodes (which would be created from a
DEFINE TEMP-TABLE tt. statement, with no fields); the later is needed to allow
proper conversion of the default buffer name. |
private static final java.util.Map<java.lang.String,java.lang.Integer> wrapperToTokenType
private static DataModelAst createDataModelAst(int type, java.lang.String text, java.lang.String p2oFile)
DataModelAst
with the given token type and text.type
- The node's token type.text
- The node's text.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.DataModelAst
instance setup as noted above.private static DataModelAst buildIndexComponent(P2JIndexComponent comp, DataModelAst propAst, java.lang.String p2oFile)
index component
associated with the given property AST.comp
- The index componentpropAst
- The associated property AST
.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.private static ProgressAst getSibling(ProgressAst progAst)
null
.progAst
- The node to search for sibling.null
is
returned. In case of ternary operator, the result is irrelevant.private static ProgressAst buildRootSchema(java.lang.String schema)
ProgressAst
node for the schema dictionary AST.schema
- The schema name.private static DataModelAst buildRootDataModel(java.lang.String schema, java.lang.String p2oFile)
root
AST and associated with the given schema.schema
- The schema name.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.private static DataModelAst buildDataModelClass(Buffer buf, RecordBuffer rbuf, java.lang.String p2oFile) throws PersistenceException
data model object
AST for the specified buffer.buf
- The buffer instance.rbuf
- The RecordBuffer
instance for the buffer.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.DataModelAst
buffer definition.PersistenceException
- In case of problems during preparation of the temp-table schema and p2o ASTs.private static DataModelAst buildProperty(Buffer buf, java.lang.reflect.Field field, int extent, java.lang.String p2oFile)
property
AST for the specified DMO java field.buf
- The Buffer
instance to which the property belongs.field
- The java field defining this property at the DMO.extent
- The legacy extent of this property.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.DataModelAst
property definition.private static DataModelAst buildIndex(Buffer buf, RecordBuffer rbuf, P2JIndex index, java.lang.String idxName, java.util.Map<java.lang.String,DataModelAst> propMap, java.lang.String p2oFile)
index
for the specified buffer.buf
- The Buffer
instance to which the index belongs.rbuf
- The RecordBuffer
instance.index
- The index definition.idxName
- The index name.propMap
- A map with the property
ASTs by their legacy name.p2oFile
- The name of the DataModelAst
tree with the
temp-table objects.index
definition.private static ProgressAst buildTempTable(DataModelAst p2o, RecordBuffer rbuf, integer order)
SchemaDictionary
. Use the given
data model object
AST as the source.p2o
- The data model object AST.rbuf
- The record buffer instance.order
- The order of this temp-table AST.private static ProgressAst createProgressAst(int type, java.lang.String text)
ProgressAst
with the given token type and text.type
- The node's token type.text
- The node's text.ProgressAst
instance setup as noted above.static java.lang.Object injectVariable(ProgressAst litAst, java.lang.String varName, ProgressAst progAst)
progAst
tree:
varName
variable of
the type requiredpost-parse-fixup.xml
was run against it.BaseDataType
that will be returned. This will be used to initialize the
variable just created.litAst
- The AST of a literal or field references to be replaced by a variable.varName
- The name of the variable to be created.progAst
- The root of the procedure. It is only needed to inject the definition of the new
variable.BaseDataType
of the literal replaced by the new variable. If
a field reference is replaced, then unknown value of proper BaseDataType
is
returned.static java.lang.Object injectVariable(ProgressAst[] litAsts, java.lang.String varName, ProgressAst progAst)
progAst
tree:
varName
variable of
the type requiredpost-parse-fixup.xml
was run against it.BaseDataType
that will be returned. This will be used to initialize the
variable just created.litAsts
- The list of ASTs of literals or field references to be replaced by a variable. All
ASTs are replaced with the same variable.varName
- The name of the variable to be created.progAst
- The root of the procedure. It is only needed to inject the definition of the new
variable.BaseDataType
of the literal replaced by the new variable. If
a field reference is replaced, then unknown value of proper BaseDataType
is
returned.static void prepareTempTable(SchemaDictionary dict, java.lang.StringBuilder pcode, java.lang.String p2oFile, java.util.List<Buffer> buffers) throws PersistenceException
Also, it appends to the progress code string any needed 4GL code (like DEFINE BUFFER statements for explicit buffers, to refer back the originating table.
dict
- The schema dictionary where the temp-tables will be loaded.pcode
- Append any new progress code here.p2oFile
- The name of the DataModelAst
tree with the temp-table objects for the
query or validation statement.buffers
- The buffers used by the query or validation statement.PersistenceException
- In case of problems during preparation of the temp-table schema and p2o ASTs.static void prepareTree(AnnotatedAst root, java.util.List<Buffer> buffers, java.lang.String fileName, java.lang.String javaClassName)
ProgressParserTokenTypes.DEFINE_TEMP_TABLE
nodes (which would be created from a
DEFINE TEMP-TABLE tt.
statement, with no fields); the later is needed to allow
proper conversion of the default buffer name.root
- The root AST of the converted progress code.buffers
- The buffers used by the query or validation statement.fileName
- The file name of the class containing the converted code.javaClassName
- The name of the generated java class.static int locateBuffer(java.util.List<Buffer> buffers, java.lang.String name)
Buffer
with the given name
, from the specified list of buffers,
and return its position.buffers
- List of buffers to be searched.name
- The buffer name.