Source:
<code>public String convertSmartSql(SQLiteDatabase db, String smartSql) { Log.i("SmartSqlHelper.convertSmartSql", "smart sql = " + smartSql); String smartSqlLowerCase = smartSql.toLowerCase(Locale.getDefault()); <START> if (smartSqlLowerCase.contains("insert") || smartSqlLowerCase.contains("update") || smartSqlLowerCase.contains("delete")) { <END> throw new SmartSqlException("Only SELECT are supported"); } Pattern pattern = Pattern.compile("\\{([^}]+)\\}"); StringBuffer sql = new StringBuffer(); Matcher matcher = pattern.matcher(smartSql); while (matcher.find()) { String fullMatch = matcher.group(); String match = matcher.group(1); int position = matcher.start(); String[] parts = match.split(":"); String soupName = parts[0]; String soupTableName = getSoupTableNameForSmartSql(db, soupName, position); boolean tableQualified = smartSql.charAt(position-1) == '.'; String tableQualifier = tableQualified ? "" : soupTableName + "."; if (parts.length == 1) { matcher.appendReplacement(sql, soupTableName); } else if (parts.length == 2) { String path = parts[1]; if (path.equals(SOUP)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.SOUP_COL); } else if (path.equals(SmartStore.SOUP_ENTRY_ID)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.ID_COL); } else if (path.equals(SmartStore.SOUP_LAST_MODIFIED_DATE)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.LAST_MODIFIED_COL); } else { String columnName = getColumnNameForPathForSmartSql(db, soupName, path, position); matcher.appendReplacement(sql, columnName); } } else if (parts.length > 2) { reportSmartSqlError("Invalid soup/path reference " + fullMatch, position); } } matcher.appendTail(sql); Log.i("SmartSqlHelper.convertSmartSql", "sql = " + sql); return sql.toString(); }</code><technical_language>startsWith()</technical_language>

Target:
public String convertSmartSql(SQLiteDatabase db, String smartSql) { Log.i("SmartSqlHelper.convertSmartSql", "smart sql = " + smartSql); String smartSqlLowerCase = smartSql.toLowerCase(Locale.getDefault()).trim(); if (smartSqlLowerCase.startsWith("insert") || smartSqlLowerCase.startsWith("update") || smartSqlLowerCase.startsWith("delete")) { throw new SmartSqlException("Only SELECT are supported"); } Pattern pattern = Pattern.compile("\\{([^}]+)\\}"); StringBuffer sql = new StringBuffer(); Matcher matcher = pattern.matcher(smartSql); while (matcher.find()) { String fullMatch = matcher.group(); String match = matcher.group(1); int position = matcher.start(); String[] parts = match.split(":"); String soupName = parts[0]; String soupTableName = getSoupTableNameForSmartSql(db, soupName, position); boolean tableQualified = smartSql.charAt(position-1) == '.'; String tableQualifier = tableQualified ? "" : soupTableName + "."; if (parts.length == 1) { matcher.appendReplacement(sql, soupTableName); } else if (parts.length == 2) { String path = parts[1]; if (path.equals(SOUP)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.SOUP_COL); } else if (path.equals(SmartStore.SOUP_ENTRY_ID)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.ID_COL); } else if (path.equals(SmartStore.SOUP_LAST_MODIFIED_DATE)) { matcher.appendReplacement(sql, tableQualifier + SmartStore.LAST_MODIFIED_COL); } else { String columnName = getColumnNameForPathForSmartSql(db, soupName, path, position); matcher.appendReplacement(sql, columnName); } } else if (parts.length > 2) { reportSmartSqlError("Invalid soup/path reference " + fullMatch, position); } } matcher.appendTail(sql); Log.i("SmartSqlHelper.convertSmartSql", "sql = " + sql); return sql.toString(); }