Source:
<code>protected static List<Index> listIndexesInDatabase(SQLDatabase db) throws SQLException { String sqlIndexNames = String.format("SELECT DISTINCT index_name FROM %s", INDEX_METADATA_TABLE_NAME); Cursor cursorIndexNames = null; ArrayList<Index> indexes = new ArrayList<Index>(); try { cursorIndexNames = db.rawQuery(sqlIndexNames, new String[]{}); while (cursorIndexNames.moveToNext()) { String indexName = cursorIndexNames.getString(0); String sqlIndexes = String.format("SELECT index_type, field_name, index_settings FROM %s "+ "WHERE index_name = ?", INDEX_METADATA_TABLE_NAME); Cursor cursorIndexes = null; try { cursorIndexes = db.rawQuery(sqlIndexes, new String[]{indexName}); int i=0; IndexType indexType = null; String settings = null; ArrayList<FieldSort> fieldNames = new ArrayList<FieldSort>(); while (cursorIndexes.moveToNext()) { <START> if (i++ == 0) { <END> indexType = IndexType.enumValue(cursorIndexes.getString(0)); settings = cursorIndexes.getString(2); } fieldNames.add(new FieldSort(cursorIndexes.getString(1))); } Map<String, Object> settingsMap = JSONUtils.deserialize(settings.getBytes(Charset.forName("UTF-8"))); if (settingsMap.containsKey("tokenize") && settingsMap.get("tokenize") instanceof String) { indexes.add(new Index(fieldNames, indexName, indexType, (String)settingsMap.get("tokenize"))); } else { indexes.add(new Index(fieldNames, indexName, indexType)); } } finally { DatabaseUtils.closeCursorQuietly(cursorIndexes); } } } finally { DatabaseUtils.closeCursorQuietly(cursorIndexNames); } return indexes; }</code><technical_language>i determine iteration, a boolean a name firstIteration similar</technical_language>

Target:
protected static List<Index> listIndexesInDatabase(SQLDatabase db) throws SQLException { String sqlIndexNames = String.format("SELECT DISTINCT index_name FROM %s", INDEX_METADATA_TABLE_NAME); Cursor cursorIndexNames = null; ArrayList<Index> indexes = new ArrayList<Index>(); try { cursorIndexNames = db.rawQuery(sqlIndexNames, new String[]{}); while (cursorIndexNames.moveToNext()) { String indexName = cursorIndexNames.getString(0); String sqlIndexes = String.format("SELECT index_type, field_name, index_settings FROM %s "+ "WHERE index_name = ?", INDEX_METADATA_TABLE_NAME); Cursor cursorIndexes = null; try { cursorIndexes = db.rawQuery(sqlIndexes, new String[]{indexName}); IndexType indexType = null; String settings = null; ArrayList<FieldSort> fieldNames = new ArrayList<FieldSort>(); boolean first = true; while (cursorIndexes.moveToNext()) { if (first) { indexType = IndexType.enumValue(cursorIndexes.getString(0)); settings = cursorIndexes.getString(2); first = false; } fieldNames.add(new FieldSort(cursorIndexes.getString(1))); } Map<String, Object> settingsMap = JSONUtils.deserialize(settings.getBytes(Charset.forName("UTF-8"))); if (settingsMap.containsKey("tokenize") && settingsMap.get("tokenize") instanceof String) { indexes.add(new Index(fieldNames, indexName, indexType, (String)settingsMap.get("tokenize"))); } else { indexes.add(new Index(fieldNames, indexName, indexType)); } } finally { DatabaseUtils.closeCursorQuietly(cursorIndexes); } } } finally { DatabaseUtils.closeCursorQuietly(cursorIndexNames); } return indexes; }