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:tds.itemrenderer.processing.ITSDocumentParser.java
/** * // www . ja va 2 s .c o m * @param option * @return */ private ITSOption readOption(final T document, final Option option) { // right now we are on <option> ITSOption itsOption = new ITSOption(); String name = option.getName().trim(); if (StringUtils.containsIgnoreCase(document.getFormat(), "SI")) { // e.g., <name>OptionNR</name> itsOption.setKey(name.replaceAll("\\u00a0", " ").split(" ")[1]); } else { // e.g., <name>OptionA</name> itsOption.setKey(name.substring(name.length() - 1)); } itsOption.setValue(option.getVal()); itsOption.setSound(option.getSound()); itsOption.setFeedback(option.getFeedback()); itsOption.setTts(option.getTts()); return itsOption; }
From source file:ubc.pavlab.gotrack.beans.EnrichmentView.java
private void filter(boolean idBypass, boolean nameBypass, boolean aspectBypass) { log.info("Filter: ID: " + filterId + " Name: " + filterName + " Aspects: " + filterAspect); Map<Edition, Map<GeneOntologyTerm, Double>> filteredData = new HashMap<>(); boolean emptyChart = true; for (Entry<Edition, Map<GeneOntologyTerm, Double>> editionEntry : enrichmentData.entrySet()) { Edition ed = editionEntry.getKey(); Map<GeneOntologyTerm, Double> termsInEdition = new HashMap<>(); filteredData.put(ed, termsInEdition); for (Entry<GeneOntologyTerm, Double> termsEntry : editionEntry.getValue().entrySet()) { GeneOntologyTerm term = termsEntry.getKey(); Double pvalue = termsEntry.getValue(); if ((aspectBypass || filterAspect.contains(term.getAspect())) && (idBypass || term.getGoId().equals(filterId)) && (nameBypass || StringUtils.containsIgnoreCase(term.getName(), filterName))) { termsInEdition.put(term, pvalue); emptyChart = false;/*from w w w . ja v a 2s . co m*/ } } } if (!emptyChart) { enrichmentChart = createChart(filteredData, "Filtered Enrichment Stability", "Date", "p-value"); chartEmpty = false; log.info("Chart filtered"); } else { chartEmpty = true; log.info("Chart Empty"); enrichmentChart = null; } }
From source file:ubc.pavlab.gotrack.beans.TrackView.java
private void filter(GraphTypeKey gtk, boolean idBypass, boolean nameBypass, boolean filterBypass) { log.info("Filter: " + gtk + ", ID: " + filterId + " Name: " + filterName + " Aspects: " + filterAspect); GoChart<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> goChart = goChartMap.get(gtk); Map<String, Map<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>>> data = new HashMap<>(); for (Entry<String, LinkedHashMap<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>>> seriesEntry : goChart .getSeries().entrySet()) {//www.j a va 2 s . co m Map<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> editionMap = new HashMap<>(); data.put(seriesEntry.getKey(), editionMap); for (Entry<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> editionEntry : seriesEntry.getValue() .entrySet()) { Map<GeneOntologyTerm, Set<EvidenceReference>> termMap = new HashMap<>(); editionMap.put(editionEntry.getKey(), termMap); for (Entry<GeneOntologyTerm, Set<EvidenceReference>> termEntry : editionEntry.getValue() .entrySet()) { if ((filterBypass || filterAspect.contains(termEntry.getKey().getAspect())) && (idBypass || termEntry.getKey().getGoId().equals(filterId)) && (nameBypass || StringUtils.containsIgnoreCase(termEntry.getKey().getName(), filterName))) { termMap.put(termEntry.getKey(), termEntry.getValue()); } } } } GoChart<Edition, Map<GeneOntologyTerm, Set<EvidenceReference>>> newChart = new GoChart<>( "Filtered " + goChart.getTitle(), goChart.getxLabel(), goChart.getyLabel(), data); // Base Chart currentChart = createChart(newChart); currentGoChart = newChart; }
From source file:ubic.gemma.core.search.SearchServiceImpl.java
/** * @return results, if the settings.termUri is populated. This includes gene uris. *//* w w w .j av a 2 s. co m*/ private Map<Class<?>, List<SearchResult>> ontologyUriSearch(SearchSettings settings) { Map<Class<?>, List<SearchResult>> results = new HashMap<>(); // 1st check to see if the query is a URI (from an ontology). // Do this by seeing if we can find it in the loaded ontologies. // Escape with general utilities because might not be doing a lucene backed search. (just a hibernate one). String termUri = settings.getTermUri(); if (StringUtils.isBlank(termUri)) { termUri = settings.getQuery(); } if (!termUri.startsWith("http://")) { return results; } OntologyTerm matchingTerm; String uriString; uriString = StringEscapeUtils.escapeJava(StringUtils.strip(termUri)); if (StringUtils.containsIgnoreCase(uriString, SearchServiceImpl.NCBI_GENE)) { // Perhaps is a valid gene URL. Want to search for the gene in gemma. // 1st get objects tagged with the given gene identifier Collection<Class<?>> classesToFilterOn = new HashSet<>(); classesToFilterOn.add(ExpressionExperiment.class); Collection<Characteristic> foundCharacteristics = characteristicService.findByUri(classesToFilterOn, uriString); Map<Characteristic, Object> parentMap = characteristicService.getParents(classesToFilterOn, foundCharacteristics); Collection<SearchResult> characteristicOwnerResults = this .filterCharacteristicOwnersByClass(classesToFilterOn, parentMap); if (!characteristicOwnerResults.isEmpty()) { results.put(ExpressionExperiment.class, new ArrayList<SearchResult>()); results.get(ExpressionExperiment.class).addAll(characteristicOwnerResults); } if (settings.getSearchGenes()) { // Get the gene String ncbiAccessionFromUri = StringUtils.substringAfterLast(uriString, "/"); Gene g = null; try { g = geneService.findByNCBIId(Integer.parseInt(ncbiAccessionFromUri)); } catch (NumberFormatException e) { // ok } if (g != null) { results.put(Gene.class, new ArrayList<SearchResult>()); results.get(Gene.class).add(new SearchResult(g)); } } return results; } /* * Not searching for a gene. */ Collection<SearchResult> matchingResults; Collection<Class<?>> classesToSearch = new HashSet<>(); if (settings.getSearchExperiments()) { classesToSearch.add(ExpressionExperiment.class); // not sure ... classesToSearch.add(BioMaterial.class); classesToSearch.add(FactorValue.class); } // this doesn't seem to be implemented yet, LiteratureEvidence and GenericEvidence aren't handled in the // fillValueObjects method downstream /* * if ( settings.getSearchPhenotypes() ) { classesToSearch.add( PhenotypeAssociation.class ); } */ matchingTerm = this.ontologyService.getTerm(uriString); if (matchingTerm == null || matchingTerm.getUri() == null) { /* * Maybe the ontology isn't loaded. Look anyway. */ Map<Characteristic, Object> parentMap = characteristicService.getParents(classesToSearch, characteristicService.findByUri(classesToSearch, uriString)); matchingResults = this.filterCharacteristicOwnersByClass(classesToSearch, parentMap); } else { SearchServiceImpl.log.info("Found ontology term: " + matchingTerm); // Was a URI from a loaded ontology soo get the children. Collection<OntologyTerm> terms2Search4 = matchingTerm.getChildren(true); terms2Search4.add(matchingTerm); matchingResults = this.databaseCharacteristicExactUriSearchForOwners(classesToSearch, terms2Search4); } for (SearchResult searchR : matchingResults) { if (results.containsKey(searchR.getResultClass())) { results.get(searchR.getResultClass()).add(searchR); } else { List<SearchResult> rs = new ArrayList<>(); rs.add(searchR); results.put(searchR.getResultClass(), rs); } } return results; }
From source file:uk.ac.ebi.utils.string.StringSearchUtils.java
/** * Tells if the string contains one of the matches. *//*from w w w. jav a2 s. c o m*/ public static boolean containsOneOfIgnoreCase(String target, String... matches) { if (target == null) throw new IllegalArgumentException("StringSearchUtils.containsOneOfIgnoreCase(): target is null!"); if (matches == null || matches.length == 0) throw new IllegalArgumentException("StringSearchUtils.containsOneOfIgnoreCase(): no match to check!"); for (String match : matches) if (StringUtils.containsIgnoreCase(target, match)) return true; return false; }
From source file:uk.gov.gchq.koryphe.impl.predicate.StringContains.java
@Override public boolean test(final String input) { if (null == input || null == value) { return false; }//w ww. j a v a2s.c om if (ignoreCase) { return StringUtils.containsIgnoreCase(input, value); } return input.contains(value); }
From source file:views.variablesnoutil.java
private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed // TODO add your handling code here: String codigoFuente = txtFuente.getText(); String variables = txtVariables.getText(); String noVariables = txtNoVariables.getText(); boolean encontrado = false; String palabra;/* w ww . j a v a2 s . c o m*/ StringTokenizer st = new StringTokenizer(variables, " "); String Mvariables[] = new String[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { palabra = st.nextToken(); encontrado = StringUtils.containsIgnoreCase(codigoFuente, palabra); if (encontrado) { } else { Mvariables[i] = palabra; txtNoVariables.append(Mvariables[i] + "\n"); i++; } } }