mil.nga.geopackage.db.master.SQLiteMasterColumn Java Examples
The following examples show how to use
mil.nga.geopackage.db.master.SQLiteMasterColumn.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlterTableUtils.java From geopackage-android with MIT License | 5 votes |
/** * Get the expected index count * * @param db connection * @param tableName table name * @return index count */ private static int indexCount(GeoPackageCoreConnection db, String tableName) { SQLiteMasterQuery indexQuery = SQLiteMasterQuery.createAnd(); indexQuery.add(SQLiteMasterColumn.TBL_NAME, tableName); indexQuery.addIsNotNull(SQLiteMasterColumn.SQL); int count = SQLiteMaster.count(db, SQLiteMasterType.INDEX, indexQuery); return count; }
Example #2
Source File: CoreSQLUtils.java From geopackage-core-java with MIT License | 5 votes |
/** * Create a new name by replacing a case insensitive value with a new value. * If no replacement is done, create a new name in the form name_#, where # * is either 2 or one greater than an existing name number suffix. When a db * connection is provided, check for conflicting SQLite Master names and * increment # until an available name is found. * * @param db * optional connection, used for SQLite Master name conflict * detection * @param name * current name * @param replace * value to replace * @param replacement * replacement value * @return new name * @since 3.3.0 */ public static String createName(GeoPackageCoreConnection db, String name, String replace, String replacement) { // Attempt the replacement String newName = name.replaceAll("(?i)" + replace, replacement); // If no name change was made if (newName.equals(name)) { String baseName = newName; int count = 1; // Find any existing end number: name_# int index = baseName.lastIndexOf("_"); if (index >= 0 && index + 1 < baseName.length()) { String numberPart = baseName.substring(index + 1); if (NUMBER_PATTERN.matcher(numberPart).matches()) { baseName = baseName.substring(0, index); count = Integer.valueOf(numberPart); } } // Set the new name to name_2 or name_(#+1) newName = baseName + "_" + (++count); if (db != null) { // Check for conflicting SQLite Master table names while (SQLiteMaster.count(db, SQLiteMasterQuery .create(SQLiteMasterColumn.NAME, newName)) > 0) { newName = baseName + "_" + (++count); } } } return newName; }
Example #3
Source File: SQLExec.java From geopackage-java with MIT License | 5 votes |
/** * Build a SQLite Master table query * * @param tableName * true to include table name * @param type * SQLite Master type * @param name * name LIKE value * @return SQL */ private static String buildSqlMasterQuery(boolean tableName, SQLiteMasterType type, String name) { StringBuilder sql = new StringBuilder("SELECT "); sql.append(SQLiteMasterColumn.NAME.name().toLowerCase()); if (tableName) { sql.append(", "); sql.append(SQLiteMasterColumn.TBL_NAME.name().toLowerCase()); } sql.append(" FROM "); sql.append(SQLiteMaster.TABLE_NAME); sql.append(" WHERE "); sql.append(SQLiteMasterColumn.TYPE.name().toLowerCase()); sql.append(" = '"); sql.append(type.name().toLowerCase()); sql.append("' AND "); sql.append(SQLiteMasterColumn.NAME.name().toLowerCase()); sql.append(" NOT LIKE 'sqlite_%'"); if (name != null) { name = name.trim(); if (!name.isEmpty()) { sql.append(" AND "); sql.append(SQLiteMasterColumn.NAME.name().toLowerCase()); sql.append(" LIKE "); sql.append(CoreSQLUtils.quoteWrap(name)); } } sql.append(" ORDER BY "); sql.append(SQLiteMasterColumn.NAME.name().toLowerCase()); sql.append(";"); return sql.toString(); }
Example #4
Source File: AlterTableUtils.java From geopackage-java with MIT License | 3 votes |
/** * Get the expected index count * * @param db * connection * @param tableName * table name * @return index count */ private static int indexCount(GeoPackageCoreConnection db, String tableName) { SQLiteMasterQuery indexQuery = SQLiteMasterQuery.createAnd(); indexQuery.add(SQLiteMasterColumn.TBL_NAME, tableName); indexQuery.addIsNotNull(SQLiteMasterColumn.SQL); int count = SQLiteMaster.count(db, SQLiteMasterType.INDEX, indexQuery); return count; }