Java Code Examples for org.apache.commons.lang.StringUtils#indexOfIgnoreCase()
The following examples show how to use
org.apache.commons.lang.StringUtils#indexOfIgnoreCase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SftpFileSystemWindows.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * cut user groups from output whoami * * @param commandOutput output from whoami * @return list of user groups */ private List<String> getUserGroups( String commandOutput ) { List<String> result = new ArrayList<>(); int startIndex = 0; int endIndex; while ( true ) { startIndex = StringUtils.indexOfIgnoreCase( commandOutput, GROUP_NAME, startIndex ); if ( startIndex < 0 ) { return result; } startIndex += GROUP_NAME.length(); endIndex = StringUtils.indexOfIgnoreCase( commandOutput, RN_DELIMITER, startIndex ); if ( endIndex < 0 ) { return result; } result.add( commandOutput.substring( startIndex, endIndex ).toUpperCase().trim() ); } }
Example 2
Source File: FreemarkerParseFactory.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 除去无效字段,去掉注释 不然批量处理可能报错 去除无效的等于 */ private static String getSqlText(String sql) { // 将注释替换成"" sql = p.matcher(sql).replaceAll(""); sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ") .replaceAll("\\s{1,}", " ").trim(); // 去掉 最后是 where这样的问题 if (sql.endsWith("where") || sql.endsWith("where ")) { sql = sql.substring(0, sql.lastIndexOf("where")); } // 去掉where and 这样的问题 int index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, "where and", index)) != -1) { sql = sql.substring(0, index + 5) + sql.substring(index + 9, sql.length()); } // 去掉 , where 这样的问题 index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, ", where", index)) != -1) { sql = sql.substring(0, index) + sql.substring(index + 1, sql.length()); } // 去掉 最后是 ,这样的问题 if (sql.endsWith(",") || sql.endsWith(", ")) { sql = sql.substring(0, sql.lastIndexOf(",")); } return sql; }
Example 3
Source File: FreemarkerParseFactory.java From teaching with Apache License 2.0 | 5 votes |
/** * 除去无效字段,去掉注释 不然批量处理可能报错 去除无效的等于 */ private static String getSqlText(String sql) { // 将注释替换成"" sql = p.matcher(sql).replaceAll(""); sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ") .replaceAll("\\s{1,}", " ").trim(); // 去掉 最后是 where这样的问题 if (sql.endsWith("where") || sql.endsWith("where ")) { sql = sql.substring(0, sql.lastIndexOf("where")); } // 去掉where and 这样的问题 int index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, "where and", index)) != -1) { sql = sql.substring(0, index + 5) + sql.substring(index + 9, sql.length()); } // 去掉 , where 这样的问题 index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, ", where", index)) != -1) { sql = sql.substring(0, index) + sql.substring(index + 1, sql.length()); } // 去掉 最后是 ,这样的问题 if (sql.endsWith(",") || sql.endsWith(", ")) { sql = sql.substring(0, sql.lastIndexOf(",")); } return sql; }
Example 4
Source File: FreemarkerParseFactory.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 除去无效字段,去掉注释 不然批量处理可能报错 去除无效的等于 */ private static String getSqlText(String sql) { // 将注释替换成"" sql = p.matcher(sql).replaceAll(""); sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ") .replaceAll("\\s{1,}", " ").trim(); // 去掉 最后是 where这样的问题 if (sql.endsWith("where") || sql.endsWith("where ")) { sql = sql.substring(0, sql.lastIndexOf("where")); } // 去掉where and 这样的问题 int index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, "where and", index)) != -1) { sql = sql.substring(0, index + 5) + sql.substring(index + 9, sql.length()); } // 去掉 , where 这样的问题 index = 0; while ((index = StringUtils.indexOfIgnoreCase(sql, ", where", index)) != -1) { sql = sql.substring(0, index) + sql.substring(index + 1, sql.length()); } // 去掉 最后是 ,这样的问题 if (sql.endsWith(",") || sql.endsWith(", ")) { sql = sql.substring(0, sql.lastIndexOf(",")); } return sql; }
Example 5
Source File: CommentContainsPatternChecker.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean isLetterAround(String line, String pattern) { int start = StringUtils.indexOfIgnoreCase(line, pattern); int end = start + pattern.length(); boolean pre = start > 0 && Character.isLetter(line.charAt(start - 1)); boolean post = end < line.length() - 1 && Character.isLetter(line.charAt(end)); return pre || post; }
Example 6
Source File: CommentContainsPatternChecker.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean isLetterAround(String line, String pattern) { int start = StringUtils.indexOfIgnoreCase(line, pattern); int end = start + pattern.length(); boolean pre = start > 0 && Character.isLetter(line.charAt(start - 1)); boolean post = end < line.length() - 1 && Character.isLetter(line.charAt(end)); return pre || post; }
Example 7
Source File: SelectQuery.java From r2rml-parser with Apache License 2.0 | 5 votes |
public ArrayList<SelectTable> createSelectTables(String q) { ArrayList<SelectTable> results = new ArrayList<SelectTable>(); int start = q.toUpperCase().indexOf("FROM") + 4; ArrayList<String> tables = new ArrayList<String>(); //split in spaces String tokens[] = q.substring(start).split("\\s+"); //if there are aliases if (StringUtils.containsIgnoreCase(q.substring(start), " AS ")) { for (int i = 0; i < tokens.length; i++) { if ("AS".equalsIgnoreCase(tokens[i])) { if (tokens[i+1].endsWith(",")) { tokens[i+1] = tokens[i+1].substring(0, tokens[i+1].indexOf(",")); } tables.add(tokens[i-1] + " " + tokens[i] + " " + tokens[i+1]); } } } else { //otherwise, split in commas int end = StringUtils.indexOfIgnoreCase(q, "WHERE"); if (end == -1) end = q.length(); tables = new ArrayList<String>(Arrays.asList(q.substring(start, end).split(","))); } for (String table : tables) { SelectTable selectTable = new SelectTable(); selectTable.setName(table.trim()); selectTable.setAlias(createAlias(selectTable.getName()).trim()); log.info("Adding table with: name '" + selectTable.getName() + "', alias '" + selectTable.getAlias() + "'"); results.add(selectTable); } return results; }