public class CoreSQLUtils extends Object
| Constructor and Description |
|---|
CoreSQLUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addColumn(GeoPackageCoreConnection db,
String tableName,
UserColumn column)
Create SQL for adding a column
|
static String[] |
buildColumnsAs(String[] columns,
String[] columnsAs)
Build the "columns as" query values for the provided columns and "columns
as" values for use in select statements.
|
static String |
columnDefaultValue(Object defaultValue,
GeoPackageDataType dataType)
Get the column default value as a string
|
static String |
columnDefaultValue(UserColumn column)
Get the column default value as a string
|
static String |
columnDefinition(UserColumn column)
Create the column definition SQL in the format:
column_type[(max)] [NOT NULL] [PRIMARY KEY AUTOINCREMENT]
|
static String |
columnSQL(UserColumn column)
Create the column SQL in the format:
"column_name" column_type[(max)] [NOT NULL] [PRIMARY KEY AUTOINCREMENT]
|
static String |
createName(GeoPackageCoreConnection db,
String name,
String replace,
String replacement)
Create a new name by replacing a case insensitive value with a new value.
|
static String |
createName(String name,
String replace,
String replacement)
Create a new name by replacing a case insensitive value with a new value.
|
static <TColumn extends UserColumn> |
createTableSQL(UserTable<TColumn> table)
Create the user defined table SQL
|
static void |
dropTable(GeoPackageCoreConnection db,
String tableName)
Drop the table if it exists
|
static String |
dropTableSQL(String tableName)
Create the drop table if exists SQL
|
static void |
dropView(GeoPackageCoreConnection db,
String viewName)
Drop the view if it exists
|
static String |
dropViewSQL(String viewName)
Create the drop view if exists SQL
|
static List<List<Object>> |
foreignKeyCheck(GeoPackageCoreConnection db)
Perform a foreign key check
|
static List<List<Object>> |
foreignKeyCheck(GeoPackageCoreConnection db,
String tableName)
Perform a foreign key check
|
static String |
foreignKeyCheckSQL()
Create the foreign key check SQL
|
static String |
foreignKeyCheckSQL(String tableName)
Create the foreign key check SQL
|
static boolean |
foreignKeys(GeoPackageCoreConnection db)
Query for the foreign keys value
|
static boolean |
foreignKeys(GeoPackageCoreConnection db,
boolean on)
Change the foreign keys state
|
static String |
foreignKeysSQL(boolean on)
Create the foreign keys SQL
|
static String |
integrityCheckSQL()
Create the integrity check SQL
|
static String |
modifySQL(GeoPackageCoreConnection db,
String name,
String sql,
TableMapping tableMapping)
Modify the SQL with a name change and the table mapping modifications
|
static String |
modifySQL(String name,
String sql,
TableMapping tableMapping)
Modify the SQL with a name change and the table mapping modifications
|
static String |
modifySQL(String sql,
TableMapping tableMapping)
Modify the SQL with table mapping modifications
|
static String |
quickCheckSQL()
Create the quick check SQL
|
static String |
quoteUnwrap(String name)
Remove double quotes from the name
|
static String |
quoteWrap(String name)
Wrap the name in double quotes
|
static String[] |
quoteWrap(String[] names)
Wrap the names in double quotes
|
static String |
replaceName(String sql,
String name,
String replacement)
Replace the name (table, column, etc) in the SQL with the replacement.
|
static String |
tempTableName(GeoPackageCoreConnection db,
String prefix,
String baseName)
Get an available temporary table name.
|
static void |
transferTableContent(GeoPackageCoreConnection db,
String tableName,
String columnName,
Object newColumnValue,
Object currentColumnValue)
Transfer table content to itself with new rows containing a new column
value.
|
static void |
transferTableContent(GeoPackageCoreConnection db,
String tableName,
String columnName,
Object newColumnValue,
Object currentColumnValue,
String idColumnName)
Transfer table content to itself with new rows containing a new column
value.
|
static void |
transferTableContent(GeoPackageCoreConnection db,
TableMapping tableMapping)
Transfer table content from one table to another
|
static String |
transferTableContentSQL(TableMapping tableMapping)
Create insert SQL to transfer table content from one table to another
|
static void |
vacuum(GeoPackageCoreConnection db)
Rebuild the GeoPackage, repacking it into a minimal amount of disk space
|
public static String quoteWrap(String name)
name - namepublic static String[] quoteWrap(String[] names)
names - namespublic static String quoteUnwrap(String name)
name - namepublic static String[] buildColumnsAs(String[] columns, String[] columnsAs)
columns - columns arraycolumnsAs - columns as valuespublic static <TColumn extends UserColumn> String createTableSQL(UserTable<TColumn> table)
TColumn - column typetable - user tablepublic static String columnSQL(UserColumn column)
column - user columnpublic static String columnDefinition(UserColumn column)
column - user columnpublic static String columnDefaultValue(UserColumn column)
column - user columnpublic static String columnDefaultValue(Object defaultValue, GeoPackageDataType dataType)
defaultValue - default valuedataType - data typepublic static void addColumn(GeoPackageCoreConnection db, String tableName, UserColumn column)
db - connectiontableName - table namecolumn - user columnpublic static boolean foreignKeys(GeoPackageCoreConnection db)
db - connectionpublic static boolean foreignKeys(GeoPackageCoreConnection db, boolean on)
db - connectionon - true to turn on, false to turn offpublic static String foreignKeysSQL(boolean on)
on - true to turn on, false to turn offpublic static List<List<Object>> foreignKeyCheck(GeoPackageCoreConnection db)
db - connectionpublic static List<List<Object>> foreignKeyCheck(GeoPackageCoreConnection db, String tableName)
db - connectiontableName - table namepublic static String foreignKeyCheckSQL()
public static String foreignKeyCheckSQL(String tableName)
tableName - table namepublic static String integrityCheckSQL()
public static String quickCheckSQL()
public static void dropTable(GeoPackageCoreConnection db, String tableName)
db - connectiontableName - table namepublic static String dropTableSQL(String tableName)
tableName - table namepublic static void dropView(GeoPackageCoreConnection db, String viewName)
db - connectionviewName - view namepublic static String dropViewSQL(String viewName)
viewName - view namepublic static void transferTableContent(GeoPackageCoreConnection db, TableMapping tableMapping)
db - connectiontableMapping - table mappingpublic static String transferTableContentSQL(TableMapping tableMapping)
tableMapping - table mappingpublic static void transferTableContent(GeoPackageCoreConnection db, String tableName, String columnName, Object newColumnValue, Object currentColumnValue)
db - connectiontableName - table namecolumnName - column namenewColumnValue - new column value for new rowscurrentColumnValue - column value for rows to insert as new rowspublic static void transferTableContent(GeoPackageCoreConnection db, String tableName, String columnName, Object newColumnValue, Object currentColumnValue, String idColumnName)
db - connectiontableName - table namecolumnName - column namenewColumnValue - new column value for new rowscurrentColumnValue - column value for rows to insert as new rowsidColumnName - id column namepublic static String tempTableName(GeoPackageCoreConnection db, String prefix, String baseName)
db - connectionprefix - name prefixbaseName - base namepublic static String modifySQL(String name, String sql, TableMapping tableMapping)
name - statement namesql - SQL statementtableMapping - table mappingpublic static String modifySQL(GeoPackageCoreConnection db, String name, String sql, TableMapping tableMapping)
db - optional connection, used for SQLite Master name conflict
detectionname - statement namesql - SQL statementtableMapping - table mappingpublic static String modifySQL(String sql, TableMapping tableMapping)
sql - SQL statementtableMapping - table mappingpublic static String replaceName(String sql, String name, String replacement)
sql - SQL statementname - namereplacement - replacement valuepublic static String createName(String name, String replace, String replacement)
name - current namereplace - value to replacereplacement - replacement valuepublic static String createName(GeoPackageCoreConnection db, String name, String replace, String replacement)
db - optional connection, used for SQLite Master name conflict
detectionname - current namereplace - value to replacereplacement - replacement valuepublic static void vacuum(GeoPackageCoreConnection db)
db - connectionCopyright © 2020 National Geospatial-Intelligence Agency. All rights reserved.