List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:StringUtilsExampleV1.java
public static void main(String args[]) { System.err.println(StringUtils.contains("Dorothy", "oro")); }
From source file:eu.annocultor.analyzers.SolrPropertyHitsAnalyzer.java
/** * @param args/* w w w . j av a2s .c om*/ */ public static void main(String[] args) throws Exception { String solrUrl = args[0]; SolrServer solr = new CommonsHttpSolrServer(solrUrl); String prefixOne = args[1]; String prefixTwo = args[2]; long prefixOneCount = 0; long prefixTwoCount = 0; long totalPassedCount = 0; for (File logLocation : FileUtils.listFiles(new File(args[3]), null, true)) { System.out.println("Parsing " + logLocation); for (String line : FileUtils.readLines(logLocation)) { if (StringUtils.contains(line, "FULL_RESULT_HMTL")) { line = StringUtils.substringAfter(line, "europeana_uri="); String solrDocumentId = StringUtils.substringBefore(line, ","); String query = extractQuery(line); if (StringUtils.startsWith(solrDocumentId, "http://") && isLongEnoughToCount(query)) { SolrQuery solrQuery = new SolrQuery("europeana_uri:\"" + solrDocumentId + "\""); QueryResponse response = solr.query(solrQuery); SolrDocumentList sourceDocs = response.getResults(); if (sourceDocs.isEmpty()) { System.out.println("Could not find object " + solrDocumentId); } else { SolrDocument document = sourceDocs.get(0); if (hasWord(document, prefixOne, query)) { prefixOneCount++; } else { if (hasWord(document, prefixTwo, query)) { prefixTwoCount++; } } } } totalPassedCount++; } } System.out.println(prefixOne + " : " + prefixOneCount + " " + prefixTwo + " : " + prefixTwoCount + " of total passed entries " + totalPassedCount); } }
From source file:com.rslakra.java.string.TestApacheStringUtils.java
public static void main(String args[]) { System.err.println(StringUtils.abbreviate("Take time off working", 0, 10)); System.err.println(StringUtils.capitalize("vanderLust")); System.err.println(StringUtils.center("MTV", 7, '=')); System.err.println(StringUtils.chomp("temperature", "ure")); System.err.println(StringUtils.chop("Dane")); System.err.println(StringUtils.contains("Dorothy", "oro")); System.err.println(StringUtils.containsNone("r u m t", new char[] { 'r', 'o' })); System.err.println(StringUtils.containsOnly("r u m t", new char[] { 'r', 'o' })); System.err.println(StringUtils.countMatches("arthur", "r")); System.err.println(StringUtils.deleteWhitespace("f f f f")); System.err.println(StringUtils.difference("govern", "government")); System.err.println(StringUtils.getLevenshteinDistance("govern", "government")); }
From source file:com.intuit.tank.util.ComponentUtil.java
/** * extracs the string after the last occurence of the seperator character ':' * //from ww w .ja v a 2 s.c o m * @param clientId * @return */ public static String extractId(String clientId) { if (StringUtils.contains(clientId, ':')) { clientId = StringUtils.substringAfterLast(clientId, ":"); } return clientId; }
From source file:bazaar4idea.command.BzrErrorUtil.java
static boolean isAbort(BzrAbstractResult result) { String line = getLastErrorLine(result); return StringUtils.isNotBlank(line) && StringUtils.contains(line, "abort:"); }
From source file:com.mmj.app.web.tools.PicTools.java
/** * ??/* www . ja v a 2 s .c o m*/ * * @param url * @param picSize * @return */ public static String processURL(String url, String suffix) { if (StringUtils.isEmpty(url)) { return StringUtils.EMPTY; } if (StringUtils.isEmpty(suffix)) { return url; } String pefix = url; if (StringUtils.contains(url, "=")) { pefix = StringUtils.substringBeforeLast(url, "="); } else if (StringUtils.contains(url, "=C")) { pefix = StringUtils.substringBeforeLast(url, "=C"); } else { pefix = StringUtils.substringBeforeLast(url, DOT); } String dotStr = StringUtils.substringAfterLast(url, DOT); return pefix + suffix + DOT + dotStr; }
From source file:bazaar4idea.command.BzrErrorUtil.java
static boolean isAuthorizationRequiredAbort(BzrAbstractResult result) { String line = getLastErrorLine(result); return StringUtils.isNotBlank(line) && (StringUtils.contains(line, "authorization required") || StringUtils.contains(line, "authorization failed")); }
From source file:com.ewcms.publication.uri.RuleParse.java
/** * ?uri??/* w w w .j a v a2 s . c om*/ * * @param patter * uri * @return key:?? value:? */ private static Map<String, String> parseVariables(String patter) { Map<String, String> variables = new HashMap<String, String>(); if (!StringUtils.contains(patter, VARIABLE_START)) { return variables; } String[] tokens = StringUtils.splitByWholeSeparator(patter, VARIABLE_START); for (String token : tokens) { logger.debug("Token with ${{}", token); if (!StringUtils.contains(token, "}")) { logger.warn("\"{}\" is not closed", token); continue; } String value = StringUtils.split(token, VARIABLE_END)[0]; if (StringUtils.isBlank(value)) { logger.warn("Variable's nam is null"); continue; } logger.debug("variable is {}", value); String[] s = StringUtils.splitByWholeSeparator(value, VARIABLE_FORMAT); if (s.length == 1) { variables.put(s[0], null); } else { variables.put(s[0], s[1]); } } return variables; }
From source file:com.iwave.ext.linux.command.powerpath.PowermtCheckRegistrationCommand.java
@Override protected void processOutput() throws CommandException { String stdout = getOutput().getStdout(); if (StringUtils.contains(stdout, EXPIRED)) { throw new PowerPathException("PowerPath license has expired.", getOutput()); }/*from www .j a va 2s . c o m*/ super.processOutput(); }
From source file:com.hangum.tadpole.commons.sql.util.PartQueryUtil.java
/** * ? DBMS? SELECT ? ?./*from w ww . j a va2 s .c o m*/ * * @return */ public static String makeSelect(UserDBDAO userDB, String originalQuery, int startResultPos, int endResultPos) { String requestQuery = ""; if (DBDefine.MYSQL_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { if (!StringUtils.contains(originalQuery.toLowerCase(), "limit ")) { requestQuery = String.format(MySQLDMLTemplate.TMP_GET_PARTDATA, originalQuery, startResultPos, endResultPos); } else { requestQuery = originalQuery; } } else if (DBDefine.ORACLE_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { if (!StringUtils.contains(originalQuery.toLowerCase(), "where")) { requestQuery = String.format(OracleDMLTemplate.TMP_GET_PARTDATA, originalQuery, startResultPos, endResultPos); } else { requestQuery = originalQuery; } } else if (DBDefine.SQLite_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { if (!StringUtils.contains(originalQuery.toLowerCase(), "limit ")) { requestQuery = String.format(SQLiteDMLTemplate.TMP_GET_PARTDATA, originalQuery, startResultPos, endResultPos); } else { requestQuery = originalQuery; } } else if (DBDefine.CUBRID_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { // //https://github.com/hangum/TadpoleForDBTools/issues/12 ? ? ? ? ? ? . if (!StringUtils.contains(originalQuery.toLowerCase(), "limit ")) { requestQuery = String.format(CubridDMLTemplate.TMP_GET_PARTDATA, originalQuery, startResultPos, endResultPos); } else { requestQuery = originalQuery; } } else if (DBDefine.POSTGRE_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { // ? limit . if (!StringUtils.contains(originalQuery.toLowerCase(), "limit ")) { requestQuery = String.format(PostgreDMLTemplate.TMP_GET_PARTDATA, originalQuery, endResultPos, startResultPos); } else { requestQuery = originalQuery; } // } else if(DBDefine.MSSQL_DEFAULT == DBDefine.getDBDefine(userDB.getTypes())) { // if(!StringUtils.contains(originalQuery.toLowerCase(), "where")) { // requestQuery = String.format(MSSQLDMLTemplate.TMP_GET_PARTDATA, originalQuery, startResultPos, endResultPos); // } else { // requestQuery = originalQuery; // } // ? ? dbms ? . } else { requestQuery = originalQuery; } return requestQuery; }