List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionTextContains.java
public Collection<SearchResult> filter(GWikiContext ctx, SearchQuery query) { List<SearchResult> ret = new ArrayList<SearchResult>(); SearchQuery sq = new SearchQuery(query); sq.setSearchExpression(text);/*ww w . ja v a 2 s . c om*/ if (query.getTextExtractor() == null) { for (SearchResult sr : query.getResults()) { SearchResult res = SearchUtils.findResult(ctx, sq, sr); if (res != null) { ret.add(res); } } } else { SearchTextExtractor tex = query.getTextExtractor(); for (SearchResult sr : query.getResults()) { String comp = tex.getRawText(ctx, query, sr); if (comp == null) { continue; } if (StringUtils.containsIgnoreCase(comp, text) == true) { ret.add(sr); } } } return ret; }
From source file:com.mirth.connect.connectors.tcp.StateAwareSocket.java
/** * The only (portable) way in Java to detect that the remote host has closed the connection is * to attempt to read from the connection and see if you get -1. We use the mark() and reset() * feature of BufferedInputStream to nondestructively peek into the stream to check for this. * Warning: since we've started consuming data, anyone reading from this socket must now use our * BIS and not create their own from getInputStream(). * //from w w w . j a v a 2s.c om * @return true if the remote end has closed its side of this socket */ @Override public boolean remoteSideHasClosed() throws IOException { if (isClosed()) { return true; } int oldTimeout; try { oldTimeout = getSoTimeout(); } catch (IOException e) { if (StringUtils.containsIgnoreCase(e.getMessage(), "Socket Closed")) { return true; } throw e; } setSoTimeout(100); getInputStream().mark(1); try { return bis.read() == -1; } catch (IOException e) { return false; } finally { try { bis.reset(); } catch (IOException e) { } try { setSoTimeout(oldTimeout); } catch (SocketException e) { } } }
From source file:com.thruzero.applications.faces.demo.beans.support.DemoStateBean.java
/** TODO-p1(george) HACK for iPhone Home Screen save. */ public String getFlipDataTransition() { String ua = FacesUtils.getRequestHeader("User-Agent"); if ((StringUtils.containsIgnoreCase(ua, "iPhone") || StringUtils.containsIgnoreCase(ua, "iPad")) && !StringUtils.containsIgnoreCase(ua, "Safari")) { return "fade"; } else {// w w w .j av a2 s . c o m return "flip"; } }
From source file:nc.noumea.mairie.annuairev2.saisie.viewmodel.ContainsSimpleListModel.java
@Override public boolean inSubModel(Object key, Object value) { String searchString = (String) key; if (StringUtils.isEmpty(searchString)) return true; try {// w ww .j a v a2s .c om return StringUtils.containsIgnoreCase(field.get(value).toString(), searchString); } catch (IllegalAccessException e) { LOGGER.error(e.toString(), e); return false; } }
From source file:com.gs.obevo.db.impl.platforms.mssql.MsSqlToH2SqlTranslator.java
@Override public String handleAnySqlPostTranslation(String string, Change change) { /*// w w w .ja v a 2 s .c om To make "ALTER TABLE some_Table ALTER COLUMN abcCol NOT NULL" into "ALTER TABLE some_Table ALTER COLUMN abcCol SET NOT NULL" */ //if this is "ALTER TABLE XYZ ALTER COLUMN ABC" statement Matcher alterTableAlterColumnMatcher = Pattern .compile("(?i)(alter\\s+table\\s+\\w+\\s+alter\\s+column\\s+\\w+\\s+)(.+)").matcher(string); if (alterTableAlterColumnMatcher.find()) { //if this is ALTER TABLE ALTER COLUMN NULL/NOT NULL in Sybase dialect (without "SET" keyword) if (!StringUtils.containsIgnoreCase(alterTableAlterColumnMatcher.group(2), "set") && StringUtils.containsIgnoreCase(alterTableAlterColumnMatcher.group(2), "null")) { Matcher nullOrNotNull = Pattern.compile("(?i)(NOT\\s+NULL|NULL)(.*)") .matcher(alterTableAlterColumnMatcher.group(2)); if (nullOrNotNull.matches()) { string = alterTableAlterColumnMatcher.group(1) + "SET " + nullOrNotNull.group(1) + nullOrNotNull.group(2); } } } return string; }
From source file:com.u2apple.rt.util.AndroidDeviceUtils.java
public static String getProductId(String brand, String model) { String productId = null;// www . java2 s. c om if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) { brand = brand.toLowerCase(); model = model.toLowerCase(); String modelWithoutBrand; if (StringUtils.containsIgnoreCase(model, brand)) { modelWithoutBrand = StringUtils.substringAfter(model, brand); } else { modelWithoutBrand = model; } //?model. if ("samsung".equalsIgnoreCase(brand) && modelWithoutBrand.contains("-")) { int index = modelWithoutBrand.indexOf("-"); //When "-" is the last char. if (index < modelWithoutBrand.length() - 1) { modelWithoutBrand = modelWithoutBrand.substring(index + 1); } } String formattedModel = formatModel(modelWithoutBrand); //?? if ("vivo".equalsIgnoreCase(brand)) { productId = "bbk-vivo" + formattedModel; } else { productId = brand + "-" + formattedModel; } } return productId; }
From source file:com.u2apple.tool.util.AndroidDeviceUtils.java
public static String buildProductId(String brand, String model) { String productId = null;//from w w w. j a v a 2s .co m if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) { brand = brand.toLowerCase(); model = model.toLowerCase(); String modelWithoutBrand; if (StringUtils.containsIgnoreCase(model, brand)) { modelWithoutBrand = StringUtils.substringAfter(model, brand); } else { modelWithoutBrand = model; } //?model. // if ("samsung".equalsIgnoreCase(brand) && modelWithoutBrand.contains("-")) { // int index = modelWithoutBrand.indexOf("-"); // //When "-" is the last char. // if (index < modelWithoutBrand.length() - 1) { // modelWithoutBrand = modelWithoutBrand.substring(index + 1); // } // } String formattedModel = formatModel(modelWithoutBrand); //?? // if ("vivo".equalsIgnoreCase(brand)) { // productId = "bbk-vivo" + formattedModel; // } else { productId = brand + "-" + formattedModel; // } } return productId; }
From source file:edu.ku.kuali.kra.institutionalproposal.proposallog.ProposalLogLookupableHelperServiceImpl.java
@Override public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { checkIsLookupForProposalCreation();//w w w.j av a 2s . c o m // List<ProposalLog> results = (List<ProposalLog>)super.getSearchResults(fieldValues); List<? extends BusinessObject> results = getSearchResultsHelper( org.kuali.rice.krad.lookup.LookupUtils.forceUppercase(getBusinessObjectClass(), fieldValues), false); String returnLocation = fieldValues.get("backLocation"); // BUKC-0039: Disable Proposal Log filtering due to an issue with obtaining proposal logs documents from MaintenanceDocumentBase // List<ProposalLog> searchList = filterForPermissions(results); if (StringUtils.containsIgnoreCase(returnLocation, "negotiationNegotiation")) { return cleanSearchResultsForNegotiationLookup(results); // searchResult } return results; // searchResult }
From source file:com.u2apple.tool.util.StaticMapFileUtils.java
private static boolean valueContains(List<Value> values1, List<Value> values2) { boolean contains = false; for (Value value1 : values1) { for (Value value2 : values2) { if (StringUtils.containsIgnoreCase(value1.getValue(), value2.getValue())) { contains = true;//from w w w. j a va2 s .c o m break; } } } return contains; }
From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java
@Test public void otherUtils() { // ignoreCase:contains/startWith/EndWith/indexOf/lastIndexOf assertThat(StringUtils.containsIgnoreCase("Aaabbb", "aaa")).isTrue(); assertThat(StringUtils.indexOfIgnoreCase("Aaabbb", "aaa")).isEqualTo(0); // 0//from w w w .j a va 2s.co m assertThat(StringUtils.leftPad("1", 3, '0')).isEqualTo("001"); assertThat(StringUtils.leftPad("12", 3, '0')).isEqualTo("012"); // ??? assertThat(StringUtils.abbreviate("abcdefg", 7)).isEqualTo("abcdefg"); assertThat(StringUtils.abbreviate("abcdefg", 6)).isEqualTo("abc..."); // ?/? assertThat(StringUtils.capitalize("abc")).isEqualTo("Abc"); assertThat(StringUtils.uncapitalize("Abc")).isEqualTo("abc"); }