/** * Creates an indexed cursor for the primary key cursor of the given table. * @param table the table over which this cursor will traverse */ public static IndexCursor createPrimaryKeyCursor(Table table) throws IOException { return createCursor(table.getPrimaryKeyIndex()); }
/** * Convenience method for finding a specific row (as defined by the cursor) * where the index entries match the given values. See {@link * IndexCursor#findRowByEntry(Object...)} for details on the entryValues. * * @param index the index to search * @param entryValues the column values for the index's columns. * @return the matching row or {@code null} if a match could not be found. */ public static Row findRowByEntry(Index index, Object... entryValues) throws IOException { return createCursor(index).findRowByEntry(entryValues); }
/** * Convenience method for finding a specific row in a table which matches a * given row "pattern". See {@link Cursor#findFirstRow(Map)} for details on * the rowPattern. * <p> * Warning, this method <i>always</i> starts searching from the beginning of * the Table (you cannot use it to find successive matches). * * @param table the table to search * @param rowPattern pattern to be used to find the row * @return the matching row or {@code null} if a match could not be found. */ public static Row findRow(Table table, Map<String,?> rowPattern) throws IOException { Cursor cursor = createCursor(table); if(cursor.findFirstRow(rowPattern)) { return cursor.getCurrentRow(); } return null; }
/** * Convenience method for finding a specific row in an indexed table which * matches a given row "pattern". See {@link Cursor#findFirstRow(Map)} for * details on the rowPattern. * <p> * Warning, this method <i>always</i> starts searching from the beginning of * the Table (you cannot use it to find successive matches). * * @param index index to assist the search * @param rowPattern pattern to be used to find the row * @return the matching row or {@code null} if a match could not be found. */ public static Row findRow(Index index, Map<String,?> rowPattern) throws IOException { Cursor cursor = createCursor(index); if(cursor.findFirstRow(rowPattern)) { return cursor.getCurrentRow(); } return null; }
/** * Copy a table in this database into a new delimited text file. <br> * Equivalent to: {@code exportWriter(Cursor.createCursor(db.getTable(tableName)), out, header, delim, quote, filter);} * * @param db * Database the table to export belongs to * @param tableName * Name of the table to export * @param out * Writer to export to * @param header * If <code>true</code> the first line contains the column names * @param delim * The column delimiter, <code>null</code> for default (comma) * @param quote * The quote character * @param filter * valid export filter * * @see #exportWriter(Cursor,BufferedWriter,boolean,String,char,ExportFilter) * @see Builder */ public static void exportWriter(Database db, String tableName, BufferedWriter out, boolean header, String delim, char quote, ExportFilter filter) throws IOException { exportWriter(CursorBuilder.createCursor(db.getTable(tableName)), out, header, delim, quote, filter); }
/** * Convenience method for finding a specific row in a table which matches a * given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for * details on the pattern. * <p> * Note, a {@code null} result value is ambiguous in that it could imply no * match or a matching row with {@code null} for the desired value. If * distinguishing this situation is important, you will need to use a Cursor * directly instead of this convenience method. * * @param index index to assist the search * @param column column whose value should be returned * @param columnPattern column being matched by the valuePattern * @param valuePattern value from the columnPattern which will match the * desired row * @return the matching row or {@code null} if a match could not be found. */ public static Object findValue(Index index, Column column, Column columnPattern, Object valuePattern) throws IOException { Cursor cursor = createCursor(index); if(cursor.findFirstRow(columnPattern, valuePattern)) { return cursor.getCurrentRowValue(column); } return null; } }
/** * Convenience method for finding a specific row in a table which matches a * given row "pattern". See {@link Cursor#findFirstRow(Column,Object)} for * details on the pattern. * <p> * Note, a {@code null} result value is ambiguous in that it could imply no * match or a matching row with {@code null} for the desired value. If * distinguishing this situation is important, you will need to use a Cursor * directly instead of this convenience method. * * @param table the table to search * @param column column whose value should be returned * @param columnPattern column being matched by the valuePattern * @param valuePattern value from the columnPattern which will match the * desired row * @return the matching row or {@code null} if a match could not be found. */ public static Object findValue(Table table, Column column, Column columnPattern, Object valuePattern) throws IOException { Cursor cursor = createCursor(table); if(cursor.findFirstRow(columnPattern, valuePattern)) { return cursor.getCurrentRowValue(column); } return null; }
/** * Creates a new Joiner based on the given index which backs a foreign-key * relationship. The table of the given index will be the "from" table and * the table on the other end of the relationship will be the "to" table. * * @param fromIndex the index backing one side of a foreign-key relationship */ public static Joiner create(Index fromIndex) throws IOException { Index toIndex = fromIndex.getReferencedIndex(); IndexCursor toCursor = CursorBuilder.createCursor(toIndex); // text lookups are always case-insensitive toCursor.setColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE); return new Joiner(fromIndex, toCursor); }
public JackcessDenseObjectMatrix2D(File file, String tablename) throws IOException { super(0, 0); database = DatabaseBuilder.open(file); VerifyUtil.verifyNotNull(database, "database could not be opened"); table = database.getTable(tablename); VerifyUtil.verifyNotNull(table, "table not found in database"); columns = table.getColumns(); cursor = CursorBuilder.createCursor(table); for (int i = 0; i < columns.size(); i++) { setColumnLabel(i, columns.get(i).getName()); } setLabel(tablename); }
Database db = conn.getDbIO(); Table tbl = db.getSystemTable("MSysRelationships"); IndexCursor crsr = CursorBuilder.createCursor(tbl.getIndex("szRelationship")); Row r = crsr.findRowByEntry(relationshipName); if (r != null) { crsr = CursorBuilder.createCursor(tbl.getIndex("ParentIdName")); Map<String, Object> rowPattern = new HashMap<String, Object>(); rowPattern.put("Name", "Relationships"); tbl.deleteRow(r); tbl = db.getSystemTable("MSysACEs"); crsr = CursorBuilder.createCursor(tbl.getIndex("ObjectId")); r = crsr.findRowByEntry(relationshipId); while (r != null) {
IndexCursor cursor = CursorBuilder.createCursor( complexColumns.getPrimaryKeyIndex()); if(!cursor.findFirstRowByEntry(complexTypeId)) {