List of usage examples for org.apache.commons.lang StringUtils lastIndexOfIgnoreCase
public static int lastIndexOfIgnoreCase(String str, String searchStr)
Case in-sensitive find of the last index within a String.
From source file:adalid.commons.util.FilUtils.java
private static String workspaceFolderPath() { File dir = workspaceFolderFile(new File(USER_DIR)); if (dir != null) { return dir.getPath(); }/*from w w w .j av a2s .c om*/ String suffix = FILE_SEP + WORKSPACE_FOLDER_NAME; String search = suffix + FILE_SEP; // logger.trace("looking last occurrence of \"" + search + "\" within \"" + USER_DIR + "\""); int i = StringUtils.lastIndexOfIgnoreCase(USER_DIR, search); String base = i < 0 ? USER_HOME : USER_DIR.substring(0, i); return base + suffix; }
From source file:com.taobao.tdhs.jdbc.sqlparser.ParseSQL.java
private void parseSQLInsert() { // insert SQL logger.debug(sql);/*from w w w . j a v a2s . c om*/ int i = 0; int addr_values; String columns; String values; // insert if (sql.substring(0, 6).equalsIgnoreCase("insert")) { i = i + 6; } else { errmsg = "it is not a insert SQL"; return; } // ?into while (sql.substring(i, i + 1).equalsIgnoreCase(" ")) { i++; } if (!sql.substring(i, i + 4).equalsIgnoreCase("into")) { errmsg = "insert sql miss into,syntax error!"; return; } else { i = i + 4; } // ???? while (sql.substring(i, i + 1).equalsIgnoreCase(" ")) { i++; } while (!sql.substring(i, i + 1).equalsIgnoreCase(" ") && !sql.substring(i, i + 1).equalsIgnoreCase("(")) { tablename = tablename + sql.substring(i, i + 1); i++; } logger.debug(tablename); // (col1,col2)values(#col1#,#col2#) addr_values = StringUtils.indexOfIgnoreCase(sql, "values", i); if (addr_values < 0) { errmsg = "not find values key word."; logger.warn(errmsg); return; } // ??,???,? int kuohao_left = StringUtils.indexOfIgnoreCase(sql, "(", i); int kuohao_right = StringUtils.indexOfIgnoreCase(sql, ")", i); if (kuohao_left >= i && kuohao_right > kuohao_left && kuohao_right < addr_values) { columns = sql.substring(kuohao_left + 1, kuohao_right); } else { errmsg = "between tablename and values key word,you must write columns clearly."; logger.warn(errmsg); return; } // values?sysdate(),?? if (StringUtils.indexOfIgnoreCase(sql, "sysdate()", addr_values) > 0) { errmsg = "use sysdate() function,this not allowed,you should use now() replace it."; logger.warn(errmsg); return; } kuohao_left = StringUtils.indexOfIgnoreCase(sql, "(", addr_values); kuohao_right = StringUtils.lastIndexOfIgnoreCase(sql, ")"); values = sql.substring(kuohao_left + 1, kuohao_right); // ??value?,?map<String,String>? String[] array_columns = columns.split(","); String[] array_values = dealInsertValues(values); if (array_columns.length != array_values.length) { errmsg = "insert sql columns is not map with values."; return; } List<Entry<String, String>> entries = new ArrayList<Entry<String, String>>(array_columns.length); for (int j = 0; j < array_columns.length; j++) { entries.add(new Entry<String, String>(array_columns[j], array_values[j])); } this.insertEntries = entries; }