mil.nga.geopackage.db.GeoPackageCoreConnection Java Examples
The following examples show how to use
mil.nga.geopackage.db.GeoPackageCoreConnection.
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: UserTableReader.java From geopackage-core-java with MIT License | 5 votes |
/** * Read the table * * @param db * connection * @return table */ public TTable readTable(GeoPackageCoreConnection db) { List<TColumn> columnList = new ArrayList<TColumn>(); TableInfo tableInfo = TableInfo.info(db, tableName); if (tableInfo == null) { throw new GeoPackageException("Table does not exist: " + tableName); } TableConstraints constraints = SQLiteMaster.queryForConstraints(db, tableName); for (TableColumn tableColumn : tableInfo.getColumns()) { if (tableColumn.getDataType() == null) { throw new GeoPackageException("Unsupported column data type " + tableColumn.getType()); } TColumn column = createColumn(tableColumn); ColumnConstraints columnConstraints = constraints .getColumnConstraints(column.getName()); if (columnConstraints != null && columnConstraints.hasConstraints()) { column.clearConstraints(); column.addConstraints(columnConstraints); } columnList.add(column); } TTable table = createTable(tableName, columnList); table.addConstraints(constraints.getTableConstraints()); return table; }
Example #3
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 5 votes |
/** * Query for the table constraints * * @param db * connection * @param tableName * table name * @return SQL constraints */ public static TableConstraints queryForConstraints( GeoPackageCoreConnection db, String tableName) { TableConstraints constraints = new TableConstraints(); SQLiteMaster tableMaster = SQLiteMaster.queryByType(db, SQLiteMasterType.TABLE, tableName); for (int i = 0; i < tableMaster.count(); i++) { constraints.addConstraints(tableMaster.getConstraints(i)); } return constraints; }
Example #4
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public GeoPackageCoreConnection getDatabase() { return database; }
Example #5
Source File: TableInfo.java From geopackage-core-java with MIT License | 4 votes |
/** * Query for the table_info of the table name * * @param db * connection * @param tableName * table name * @return table info or null if no table */ public static TableInfo info(GeoPackageCoreConnection db, String tableName) { String sql = "PRAGMA table_info(" + CoreSQLUtils.quoteWrap(tableName) + ")"; List<List<Object>> results = db.queryResults(sql, null); List<TableColumn> tableColumns = new ArrayList<>(); for (List<Object> column : results) { int index = ((Number) column.get(CID_INDEX)).intValue(); String name = (String) column.get(NAME_INDEX); String type = (String) column.get(TYPE_INDEX); boolean notNull = ((Number) column.get(NOT_NULL_INDEX)) .intValue() == 1; String defaultValueString = (String) column.get(DFLT_VALUE_INDEX); boolean primaryKey = ((Number) column.get(PK_INDEX)) .intValue() == 1; // If the type has a max limit on it, pull it off Long max = null; if (type != null && type.endsWith(")")) { int maxStart = type.indexOf("("); if (maxStart > -1) { String maxString = type.substring(maxStart + 1, type.length() - 1); if (!maxString.isEmpty()) { try { max = Long.valueOf(maxString); type = type.substring(0, maxStart); } catch (NumberFormatException e) { logger.log(Level.WARNING, "Failed to parse type max from type: " + type, e); } } } } GeoPackageDataType dataType = getDataType(type); Object defaultValue = getDefaultValue(defaultValueString, dataType); TableColumn tableColumn = new TableColumn(index, name, type, dataType, max, notNull, defaultValueString, defaultValue, primaryKey); tableColumns.add(tableColumn); } TableInfo tableInfo = null; if (!tableColumns.isEmpty()) { tableInfo = new TableInfo(tableName, tableColumns); } return tableInfo; }
Example #6
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 3 votes |
/** * Constructor * * @param name * name * @param path * path * @param database * database * @param tableCreator * table creator * @param writable * true if writable */ protected GeoPackageCoreImpl(String name, String path, GeoPackageCoreConnection database, GeoPackageTableCreator tableCreator, boolean writable) { this.name = name; this.path = path; this.database = database; this.tableCreator = tableCreator; this.writable = writable; }
Example #7
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; }
Example #8
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 3 votes |
/** * Count the sqlite_master table * * @param db * connection * @param types * result types * @param tableName * table name * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType[] types, String tableName) { SQLiteMasterQuery query = null; if (tableName != null) { query = SQLiteMasterQuery.create(SQLiteMasterColumn.TBL_NAME, tableName); } return count(db, types, query); }
Example #9
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 3 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @param types * result types * @param tableName * table name * @return SQLiteMaster result */ public static SQLiteMaster query(GeoPackageCoreConnection db, Collection<SQLiteMasterColumn> columns, Collection<SQLiteMasterType> types, String tableName) { return query(db, columns.toArray(new SQLiteMasterColumn[0]), types.toArray(new SQLiteMasterType[0]), tableName); }
Example #10
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 3 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @param type * result type * @param tableName * table name * @return SQLiteMaster result */ public static SQLiteMaster query(GeoPackageCoreConnection db, Collection<SQLiteMasterColumn> columns, SQLiteMasterType type, String tableName) { return query(db, columns.toArray(new SQLiteMasterColumn[0]), type, tableName); }
Example #11
Source File: UserCoreDao.java From geopackage-core-java with MIT License | 3 votes |
/** * Constructor * * @param database * database name * @param db * GeoPackage connection * @param userDb * user connection * @param table * table */ protected UserCoreDao(String database, GeoPackageCoreConnection db, UserCoreConnection<TColumn, TTable, TRow, TResult> userDb, TTable table) { this.database = database; this.db = db; this.userDb = userDb; this.table = table; }
Example #12
Source File: UserCustomTableReader.java From geopackage-core-java with MIT License | 3 votes |
/** * Read the table * * @param connection * GeoPackage connection * @param tableName * table name * @return table */ public static UserCustomTable readTable(GeoPackageCoreConnection connection, String tableName) { UserCustomTableReader tableReader = new UserCustomTableReader( tableName); UserCustomTable customTable = tableReader.readTable(connection); return customTable; }
Example #13
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @param type * result type * @return SQLiteMaster result */ public static SQLiteMaster query(GeoPackageCoreConnection db, SQLiteMasterColumn[] columns, SQLiteMasterType type) { return query(db, columns, types(type)); }
Example #14
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param type * result type * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType type) { return count(db, types(type)); }
Example #15
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param type * result type * @param tableName * table name * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType type, String tableName) { return count(db, types(type), tableName); }
Example #16
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @param type * result type * @param tableName * table name * @return SQLiteMaster result */ public static SQLiteMaster query(GeoPackageCoreConnection db, SQLiteMasterColumn[] columns, SQLiteMasterType type, String tableName) { return query(db, columns, types(type), tableName); }
Example #17
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param types * result types * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType[] types) { return count(db, types, SQLiteMasterQuery.create()); }
Example #18
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @param types * result types * @return SQLiteMaster result */ public static SQLiteMaster query(GeoPackageCoreConnection db, SQLiteMasterColumn[] columns, SQLiteMasterType[] types) { return query(db, columns, types, SQLiteMasterQuery.create()); }
Example #19
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @return count */ public static int count(GeoPackageCoreConnection db) { return count(db, types(), SQLiteMasterQuery.create()); }
Example #20
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param query * query * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterQuery query) { return count(db, types(), query); }
Example #21
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param type * result type * @param query * query * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType type, SQLiteMasterQuery query) { return count(db, types(type), query); }
Example #22
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param types * result types * @param query * query * @return count */ public static int count(GeoPackageCoreConnection db, SQLiteMasterType[] types, SQLiteMasterQuery query) { return query(db, null, types, query).count(); }
Example #23
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master views on the table * * @param db * connection * @param tableName * table name * @return SQLiteMaster result */ public static SQLiteMaster queryViewsOnTable(GeoPackageCoreConnection db, String tableName) { return queryViewsOnTable(db, SQLiteMasterColumn.values(), tableName); }
Example #24
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master views on the table * * @param db * connection * @param columns * result columns * @param tableName * table name * @return SQLiteMaster result */ public static SQLiteMaster queryViewsOnTable(GeoPackageCoreConnection db, SQLiteMasterColumn[] columns, String tableName) { return query(db, columns, SQLiteMasterType.VIEW, SQLiteMasterQuery.createTableViewQuery(tableName)); }
Example #25
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master views on the table * * @param db * connection * @param tableName * table name * @return count */ public static int countViewsOnTable(GeoPackageCoreConnection db, String tableName) { return count(db, SQLiteMasterType.VIEW, SQLiteMasterQuery.createTableViewQuery(tableName)); }
Example #26
Source File: UserCoreDao.java From geopackage-core-java with MIT License | 2 votes |
/** * Get the database connection * * @return database connection */ public GeoPackageCoreConnection getDb() { return db; }
Example #27
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Get the SQLite database * * @return connection */ public GeoPackageCoreConnection getDatabase();
Example #28
Source File: ContentsDao.java From geopackage-core-java with MIT License | 2 votes |
/** * Set the database * * @param db * database connection */ public void setDatabase(GeoPackageCoreConnection db) { this.db = db; }
Example #29
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Count the sqlite_master table * * @param db * connection * @param types * result types * @param tableName * table name * @return count */ public static int countByType(GeoPackageCoreConnection db, Collection<SQLiteMasterType> types, String tableName) { return count(db, types.toArray(new SQLiteMasterType[0]), tableName); }
Example #30
Source File: SQLiteMaster.java From geopackage-core-java with MIT License | 2 votes |
/** * Query the sqlite_master table * * @param db * connection * @param columns * result columns * @return SQLiteMaster result */ public static SQLiteMaster queryForColumns(GeoPackageCoreConnection db, Collection<SQLiteMasterColumn> columns) { return queryForColumns(db, columns, null); }