public class ConversionData
extends java.lang.Object
Currently, this supports creating maps
, sets
, and also maps which
have as values another map
or a set
.
The associated tables for the db-backed collections are created on first access, and their name follow this rules:
__work
suffix__map
or __set
suffix_work
suffixChanges to these collections will be logged in the work tables, and if the collection already exists in the database, will be restored from the work table. This allows to 'restore history' during incremental conversion, by clearing from the work table all changes belonging to the files currently being converted.
Modifier and Type | Field and Description |
---|---|
private static DBHelper |
helper
The helper for SQL access to the database.
|
Constructor and Description |
---|
ConversionData() |
Modifier and Type | Method and Description |
---|---|
static java.util.Set<java.lang.String> |
clean(java.lang.String file)
Clean all records about this file, from the incremental conversion database.
|
static void |
cleanAll()
Clean all tables from the database.
|
static void |
compact(java.lang.String name,
java.lang.String file)
Compact the elements of this collection, to reduce the memory footprint.
|
static java.lang.String |
computeFileHash(java.lang.String file)
Compute the MD5 hash for the specified file.
|
static void |
connect()
Connect to the database.
|
static boolean |
connected()
Check if the database is connected.
|
static java.util.Map<?,?> |
createMap(java.lang.Class<?> keyClass,
java.lang.Class<?> valueClass,
java.lang.String name)
Create a new db-backed map, with the specified key and value class.
|
static java.util.Map<?,?> |
createMapToMap(java.lang.Class<?> keyClass,
java.lang.Class<?> key2Class,
java.lang.Class<?> valueClass,
java.lang.String name)
Create a new db-backed map, which has as values another map.
|
static java.util.Map<?,?> |
createMapToSet(java.lang.Class<?> keyClass,
java.lang.Class<?> valueClass,
java.lang.String name)
Create a new db-backed map, which has as values another set.
|
static java.util.Set<?> |
createSet(java.lang.Class<?> keyClass,
java.lang.String name)
Create a new db-backed set with the specified key class and name.
|
static void |
disconnect()
Disconnect the database.
|
static java.lang.String |
findClassFilename(java.lang.String qname)
Find the associated file name for the specified qualified class name of a legacy class.
|
static java.lang.String |
findClassQName(java.lang.String filename)
Find the associated qualified class name for this file, defining a legacy class.
|
static java.util.Set<java.lang.String> |
getClassesInPackage(java.lang.String pack)
Get the simple java class names for all classes in this package (builtin or converted code).
|
static java.lang.Object[] |
getConvertedClassName(java.lang.String filename)
Get the converted Java package and simple class name, for this file defining a legacy class.
|
static java.lang.String |
getConvertedSimpleClassName(java.lang.String qname)
Get the converted simple class name for the specified fully-qualified 4GL class name.
|
static int |
getTempIdx(long astId)
Get the temp-idx value for the specified AST, in the
ooVarTempIdx__work table. |
(package private) static boolean |
inPersist()
Check if we are currently persisting the db-backed collections.
|
static java.util.List<java.lang.String> |
listLegacyClasses()
List all legacy builtin classes which are registered in the database.
|
static java.util.List<java.lang.String> |
listWithServicesFiles()
Get all program files which are marked 'with_services'.
|
static boolean |
mustConvertFile(java.lang.String file)
Check if this file must be converted.
|
static int |
nextSequenceValue(java.lang.String name)
Get the next value for the specified sequence.
|
static void |
saveClass(ClassDefinition clsDef)
Save the specified class definition details into the
class_definitions table. |
static void |
saveFileHash(java.lang.String file)
Compute and save the MD5 hash for this file.
|
static void |
setConvertedClassName(java.lang.String filename,
java.lang.String jpkgname,
java.lang.String jclassname)
Update the
class_definitions table with the converted Java class simple name
and package. |
static void |
withServicesFile(java.lang.String file)
Mark this file 'with_services'.
|
private static final DBHelper helper
public static java.util.Set<java.lang.String> clean(java.lang.String file)
This will clear all work tables which have records for this file AST ID, and all
records from the CLASS_DEFINITIONS
table.
file
- The file to clear.public static void cleanAll()
public static void disconnect()
This will persist all db-backed collection.
public static void connect()
This will create the class_definitions
and file_signature
tables,
if they do not already exist.
public static boolean connected()
public static int getTempIdx(long astId)
ooVarTempIdx__work
table.astId
- The temp index value.public static java.lang.String computeFileHash(java.lang.String file)
file
- The file name.public static void saveFileHash(java.lang.String file)
file
- The file name.public static boolean mustConvertFile(java.lang.String file)
A file must be converted if the file is new, or itself or any of its include files
(from reading the associated .pphints
has changed.
file
- The file name.true
if this file has changed and must be converted.public static int nextSequenceValue(java.lang.String name)
name
- The sequence name.public static void withServicesFile(java.lang.String file)
file
- The file name.public static java.util.List<java.lang.String> listWithServicesFiles()
public static java.util.Set<java.lang.String> getClassesInPackage(java.lang.String pack)
pack
- The package name.public static void setConvertedClassName(java.lang.String filename, java.lang.String jpkgname, java.lang.String jclassname)
class_definitions
table with the converted Java class simple name
and package.filename
- The converted class file name.jpkgname
- The converted Java package name.jclassname
- The converted simple Java class name.public static java.util.List<java.lang.String> listLegacyClasses()
public static java.lang.String findClassQName(java.lang.String filename)
filename
- The file name.null if it does not exist.
public static java.lang.String findClassFilename(java.lang.String qname)
qname
- The qualified class name.null if it does not exist.
public static java.lang.Object[] getConvertedClassName(java.lang.String filename)
filename
- The file name.null
if it does
not exist.public static java.lang.String getConvertedSimpleClassName(java.lang.String qname)
qname
- The qualified class name.null
if it was not found.public static void saveClass(ClassDefinition clsDef)
class_definitions
table.clsDef
- The legacy class details.public static java.util.Set<?> createSet(java.lang.Class<?> keyClass, java.lang.String name)
keyClass
- The key class.name
- The collection name.H2Set
.public static java.util.Map<?,?> createMapToMap(java.lang.Class<?> keyClass, java.lang.Class<?> key2Class, java.lang.Class<?> valueClass, java.lang.String name)
keyClass
- The key class.key2Class
- The child's map key class.valueClass
- The child's map value class.name
- The collection name.H2MapToMap
.public static java.util.Map<?,?> createMapToSet(java.lang.Class<?> keyClass, java.lang.Class<?> valueClass, java.lang.String name)
keyClass
- The key class.valueClass
- The child's set key class.name
- The collection name.H2MapToSet
.public static java.util.Map<?,?> createMap(java.lang.Class<?> keyClass, java.lang.Class<?> valueClass, java.lang.String name)
keyClass
- The key class.valueClass
- The child's map value class.name
- The collection name.H2Map
.public static void compact(java.lang.String name, java.lang.String file)
name
- The collection name.file
- The AST file which has finished processing.static boolean inPersist()