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:org.pepstock.jem.util.filters.predicates.ResourcePredicate.java
/** * Checks properties values of resource/*from www .j a v a2 s .co m*/ * @param tokenValue filter of resource property * @param resource resources to check * @return true if matches */ private boolean checkProperties(String tokenValue, Resource resource) { int count = 0; String value = null; // scans all resource properties // to create a string to check if contains a string for (ResourceProperty property : resource.getProperties().values()) { // if is starting point // doesn't add any previous value if (count == 0) { // it builds the string without property NOT visible value = property.getName() + " = " + (property.isVisible() ? property.getValue() : ResourceProperty.MASK_FOR_NO_VISIBLE_PROPERTY); } else { // it builds the string without property NOT visible adding previous value value = value + ", " + property.getName() + " = " + (property.isVisible() ? property.getValue() : ResourceProperty.MASK_FOR_NO_VISIBLE_PROPERTY); } // increments count count++; } // here checks if the filter value is in the string built // with resource properties return StringUtils.containsIgnoreCase(value, tokenValue); }
From source file:org.pepstock.jem.util.filters.predicates.RolePredicate.java
@SuppressWarnings("rawtypes") @Override//w w w. ja v a 2 s . com public boolean apply(MapEntry entry) { // casts the object to a Role Role role = (Role) entry.getValue(); boolean includeThis = true; // gets all tokens of filter FilterToken[] tokens = getFilter().toTokenArray(); // scans all tokens for (int i = 0; i < tokens.length && includeThis; i++) { FilterToken token = tokens[i]; // gets name and value // remember that filters are built: // -[name] [value] String tokenName = token.getName(); String tokenValue = token.getValue(); // gets the filter field for roles by name RoleFilterFields field = RoleFilterFields.getByName(tokenName); // if field is not present, // used NAME as default if (field == null) { field = RoleFilterFields.NAME; } // based on name of field, it will check // different attributes // all matches are in AND switch (field) { case NAME: // checks name of ROLE includeThis &= checkName(tokenValue, role.getName()); break; case REMOVABLE: // checks removable attribute of ROLE includeThis &= StringUtils.containsIgnoreCase(String.valueOf(role.isRemovable()), tokenValue); break; case PERMISSIONS: // skipped permission isEmpty check includeThis &= StringUtils.containsIgnoreCase(role.getPermissions().toString(), tokenValue); break; case USERS: // skipped users isEmpty check includeThis &= StringUtils.containsIgnoreCase(role.getUsers().toString(), tokenValue); break; case MODIFIED: // checks modified time of ROLE includeThis &= checkTime(tokenValue, role.getLastModified()); break; case MODIFIED_BY: // checks who changed the role includeThis &= StringUtils.containsIgnoreCase(role.getUser(), tokenValue); break; default: // otherwise it uses a wrong filter name throw new JemRuntimeException("Unrecognized Role filter field: " + field); } } return includeThis; }
From source file:org.pircbotx.hooks.CoreHooks.java
@Override public void onGenericMessage(GenericMessageEvent event) throws Exception { Configuration config = event.getBot().getConfiguration(); UserHostmask hostmask = event.getUserHostmask(); //There must be a passwork and on success text //The hostmask must contain "nickserv" //The message must contain the on success text if (config.getNickservOnSuccess() != null && StringUtils.containsIgnoreCase(hostmask.getHostmask(), config.getNickservNick()) && StringUtils.containsIgnoreCase(event.getMessage(), config.getNickservOnSuccess())) { log.info("Successfully identified to nickserv"); Utils.setNickServIdentified(event.getBot()); if (config.isNickservDelayJoin()) { for (Map.Entry<String, String> channelEntry : config.getAutoJoinChannels().entrySet()) event.getBot().sendIRC().joinChannel(channelEntry.getKey(), channelEntry.getValue()); }//from w ww. j a va2 s . co m } }
From source file:org.rm3l.ddwrt.tiles.status.bandwidth.BandwidthMonitoringTile.java
@NotNull private Collection<String> getIfaces() throws Exception { //TODO TESTS: Real ifaces for DD-WRT Routers //noinspection PointlessBooleanExpression,ConstantConditions if (DDWRTCompanionConstants.TEST_MODE && (this.mRouter == null || !StringUtils.containsIgnoreCase(this.mRouter.getName(), "ddwrt"))) { //FIXME TEST MODE return Sets.newTreeSet(Arrays.asList("wlan0", "lan1", "eth2")); }//from w ww .j av a 2 s .co m final Set<String> ifacesConsidered = Sets.newHashSet(); final NVRAMInfo nvramInfo = SSHUtils.getNVRamInfoFromRouter(mRouter, mGlobalPreferences, NVRAMInfo.LAN_IFNAME, NVRAMInfo.WAN_IFNAME, NVRAMInfo.LANDEVS); if (nvramInfo == null) { return ifacesConsidered; } final String lanIfname = nvramInfo.getProperty(NVRAMInfo.LAN_IFNAME); if (lanIfname != null) { ifacesConsidered.add(lanIfname); } final String wanIfname = nvramInfo.getProperty(NVRAMInfo.WAN_IFNAME); if (wanIfname != null) { ifacesConsidered.add(wanIfname); } final String landevs = nvramInfo.getProperty(NVRAMInfo.LANDEVS); if (landevs != null) { final List<String> splitToList = Splitter.on(" ").omitEmptyStrings().trimResults().splitToList(landevs); if (splitToList != null && !splitToList.isEmpty()) { for (final String landev : splitToList) { if (landev == null) { continue; } ifacesConsidered.add(landev); } } } return ifacesConsidered; }
From source file:org.robovm.store.viewcontrollers.StringTableViewController.java
public StringTableViewController() { searchBar = new UISearchBar(); searchBar.setDelegate(new UISearchBarDelegateAdapter() { @Override//from www .j a v a 2 s.c o m public void didChange(UISearchBar searchBar, String searchText) { filteredItems.clear(); for (String item : items) { if (StringUtils.containsIgnoreCase(item, searchBar.getText())) { filteredItems.add(item); } } getTableView().reloadData(); } }); searchBar.sizeToFit(); getTableView().setTableHeaderView(searchBar); }
From source file:org.roda.core.plugins.orchestrate.JobsTest.java
@Test public void testJobExecutingPluginThatFailsDuringExecuteInParallel() throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, AlreadyExistsException { JobsHelper.setBlockSize(1);//ww w .j av a2s.co m ModelService modelService = RodaCoreFactory.getModelService(); String aip1 = modelService.createAIP(null, "misc", new Permissions(), RodaConstants.ADMIN).getId(); String aip2 = modelService.createAIP(null, "misc", new Permissions(), RodaConstants.ADMIN).getId(); Map<String, String> parameters = new HashMap<>(); Job job; JobStats jobStats; // 1) don't fail at all parameters.put(aip1, "false"); parameters.put(aip2, "false"); job = TestsHelper.executeJob(PluginThatFailsDuringExecuteMethod.class, parameters, PluginType.MISC, SelectedItemsList.create(AIP.class, aip1, aip2), JOB_STATE.COMPLETED); Assert.assertNotNull(job.getStateDetails()); Assert.assertEquals(job.getStateDetails(), ""); jobStats = job.getJobStats(); assertJobStats(jobStats, 100, 0, 2, 0, 2, 0); // 2) fail in one (order doesn't matter as orchestration is asynchronous) parameters.put(aip1, "false"); parameters.put(aip2, "true"); job = TestsHelper.executeJob(PluginThatFailsDuringExecuteMethod.class, parameters, PluginType.MISC, SelectedItemsList.create(AIP.class, aip1, aip2), JOB_STATE.FAILED_TO_COMPLETE); Assert.assertNotNull(job.getStateDetails()); Assert.assertTrue(StringUtils.containsIgnoreCase(job.getStateDetails(), "exception")); jobStats = job.getJobStats(); assertJobStats(jobStats, 100, 0, 2, 1, 1, 0); // 3) fail in both parameters.put(aip1, "true"); parameters.put(aip2, "true"); job = TestsHelper.executeJob(PluginThatFailsDuringExecuteMethod.class, parameters, PluginType.MISC, SelectedItemsList.create(AIP.class, aip1, aip2), JOB_STATE.FAILED_TO_COMPLETE); Assert.assertNotNull(job.getStateDetails()); Assert.assertTrue(StringUtils.containsIgnoreCase(job.getStateDetails(), "exception")); jobStats = job.getJobStats(); assertJobStats(jobStats, 100, 0, 2, 2, 0, 0); }
From source file:org.sakaiproject.assignment.impl.AssignmentServiceImpl.java
private List<User> getSearchedUsers(String searchString, List<User> userList, boolean retain) { List<User> rv = new ArrayList<>(); if (StringUtils.isNotBlank(searchString)) { searchString = searchString.toLowerCase(); for (User u : userList) { // search on user sortname, eid, email String[] fields = { u.getSortName(), u.getEid(), u.getEmail() }; List<String> l = Arrays.asList(fields); for (String s : l) { if (StringUtils.containsIgnoreCase(s, searchString)) { rv.add(u);/* w ww. jav a 2 s. c om*/ break; } } } } else if (retain) { // retain the original list rv = userList; } return rv; }
From source file:org.sigmah.server.servlet.filter.CacheFilter.java
/** * Returns if the given {@code seq} contains any of the given {@code searchSeqs}.<br/> * The search is case insensitive./* w w w .j a va2 s. c o m*/ * * <pre> * containsAny(null, null) -> false * containsAny(*, null) -> false * containsAny(null, *) -> false * containsAny("abc", "a") -> true * containsAny("abc", "abcd", "efg") -> false * containsAny("abc", "aB") -> true * containsAny("abc", "aBk") -> false * containsAny("abc", "aBk", "abC") -> true * </pre> * * @param seq * The sequence. * @param searchSeqs * The search sequence(s). * @return {@code true} if the given {@code seq} contains any of the given {@code searchSeqs}, {@code false} * otherwise. */ private static boolean containsAny(final String seq, final String... searchSeqs) { if (seq == null || searchSeqs == null) { return false; } for (final String searchSeq : searchSeqs) { if (StringUtils.containsIgnoreCase(seq, searchSeq)) { return true; } } return false; }
From source file:org.sigmah.server.servlet.FilterTest.java
private static boolean containsAny(final String seq, final String... searchSeqs) { if (seq == null || searchSeqs == null) { return false; }/* ww w .j a v a 2s . c om*/ for (final String searchSeq : searchSeqs) { if (StringUtils.containsIgnoreCase(seq, searchSeq)) { return true; } } return false; }
From source file:org.squashtest.tm.web.internal.exceptionresolver.ExceptionResolverUtils.java
public static boolean clientAcceptsMIME(HttpServletRequest request, MimeType type) { Enumeration<String> e = request.getHeaders(RequestHeaders.ACCEPT); while (e.hasMoreElements()) { String header = e.nextElement(); if (StringUtils.containsIgnoreCase(StringUtils.trimToEmpty(header), type.requestHeaderValue())) { return true; }//from w ww. jav a 2 s.c om } return false; }