public List<DeveloperDatabaseTableRecord> getDatabaseTableContent( DeveloperObjectFactory developerObjectFactory, DeveloperDatabaseTable developerDatabaseTable) { /** Will get the records for the given table */ List<DeveloperDatabaseTableRecord> returnedRecords = new ArrayList<DeveloperDatabaseTableRecord>(); /** I load the passed table name from the SQLite database. */ DatabaseTable selectedTable = database.getTable(developerDatabaseTable.getName()); try { selectedTable.loadToMemory(); List<DatabaseTableRecord> records = selectedTable.getRecords(); for (DatabaseTableRecord row : records) { List<String> developerRow = new ArrayList<String>(); /** for each row in the table list */ for (DatabaseRecord field : row.getValues()) { /** I get each row and save them into a List<String> */ developerRow.add(field.getValue()); } /** I create the Developer Database record */ returnedRecords.add( developerObjectFactory.getNewDeveloperDatabaseTableRecord(developerRow)); } /** return the list of DeveloperRecords for the passed table. */ } catch (CantLoadTableToMemoryException cantLoadTableToMemory) { /** if there was an error, I will returned an empty list. */ database.closeDatabase(); return returnedRecords; } catch (Exception e) { database.closeDatabase(); return returnedRecords; } database.closeDatabase(); return returnedRecords; }
public final List<DeveloperDatabaseTableRecord> getDatabaseTableContent( final DeveloperObjectFactory developerObjectFactory, final DeveloperDatabaseTable developerDatabaseTable) { final List<DeveloperDatabaseTableRecord> returnedRecords = new ArrayList<>(); final DatabaseTable selectedTable = database.getTable(developerDatabaseTable.getName()); try { selectedTable.loadToMemory(); final List<DatabaseTableRecord> records = selectedTable.getRecords(); for (final DatabaseTableRecord row : records) { final List<String> developerRow = new ArrayList<>(); for (DatabaseRecord field : row.getValues()) developerRow.add(field.getValue()); returnedRecords.add( developerObjectFactory.getNewDeveloperDatabaseTableRecord(developerRow)); } } catch (CantLoadTableToMemoryException cantLoadTableToMemory) { return returnedRecords; } catch (Exception e) { return returnedRecords; } return returnedRecords; }