List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(String str, String searchStr)
Checks if String contains a search String irrespective of case, handling null
.
From source file:com.tesora.dve.sql.util.ProxyConnectionResource.java
@Override public ExceptionClassification classifyException(Throwable t) { if (t.getMessage() == null) return null; String msg = t.getMessage().trim(); if (StringUtils.containsIgnoreCase(msg, "No such Table:") || StringUtils.containsIgnoreCase(msg, "No such Column:")) return ExceptionClassification.DNE; if (StringUtils.containsIgnoreCase(msg, "No value found for required") && StringUtils.endsWithIgnoreCase(msg, "and no default specified")) return ExceptionClassification.DNE; if (StringUtils.containsIgnoreCase(msg, "Unsupported statement kind for planning:") && StringUtils.endsWithIgnoreCase(msg, "RollbackTransactionStatement")) return ExceptionClassification.DNE; if (StringUtils.containsIgnoreCase(msg, "Data Truncation:")) return ExceptionClassification.OUT_OF_RANGE; if (StringUtils.containsIgnoreCase(msg, "Unable to parse") || StringUtils.containsIgnoreCase(msg, "Unable to build plan") || StringUtils.containsIgnoreCase(msg, "Parsing FAILED:")) return ExceptionClassification.SYNTAX; if (StringUtils.containsIgnoreCase(msg, "Duplicate entry")) return ExceptionClassification.DUPLICATE; if (StringUtils.containsIgnoreCase(msg, "option not supported")) return ExceptionClassification.UNSUPPORTED_OPERATION; return null;// ww w . j a v a 2 s . c o m }
From source file:hydrograph.ui.expression.editor.composites.AvailableFieldsComposite.java
private void addListnersToSearchTextBox() { searchTextBox.addModifyListener(new ModifyListener() { @Override// w w w.jav a2 s .c o m public void modifyText(ModifyEvent e) { if (!StringUtils.equals(Constants.DEFAULT_SEARCH_TEXT, searchTextBox.getText())) { table.removeAll(); for (String field : inputFields) { if (StringUtils.containsIgnoreCase(field, searchTextBox.getText())) { TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(0, field); tableItem.setText(1, fieldMap.get(field).getSimpleName()); } } if (table.getItemCount() == 0 && StringUtils.isNotBlank(searchTextBox.getText())) { new TableItem(table, SWT.NONE) .setText(Messages.CANNOT_SEARCH_INPUT_STRING + searchTextBox.getText()); } } } }); }
From source file:gov.nih.nci.cabig.caaers.web.filters.CsrfPreventionFilter.java
private boolean isAllowedURI(String url) { for (String allowed : this.allowURIs) { if (StringUtils.containsIgnoreCase(url, allowed)) { return true; }/*from ww w. ja v a 2s .c o m*/ } return false; }
From source file:com.alibaba.otter.manager.web.webx.valve.AuthContextValve.java
protected boolean isAPI(TurbineRunData rundata) { String requestUrl = rundata.getRequest().getRequestURI(); return StringUtils.containsIgnoreCase(requestUrl, "/api/"); }
From source file:com.bstek.dorado.view.resolver.HtmlViewResolver.java
@Override public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception { if (touchUserAgentArray != null) { String userAgent = request.getHeader("user-agent"); for (String mobile : touchUserAgentArray) { if (StringUtils.containsIgnoreCase(userAgent, mobile)) { Context context = Context.getCurrent(); context.setAttribute("com.bstek.dorado.view.resolver.HtmlViewResolver.isTouch", true); break; }//from w ww.ja v a2 s . c o m } } String uri = getRelativeRequestURI(request); if (!PathUtils.isSafePath(uri)) { throw new PageAccessDeniedException("[" + request.getRequestURI() + "] Request forbidden."); } if (shouldAutoLoadDataConfigResources) { if (System.currentTimeMillis() - lastValidateTimestamp > MIN_DATA_CONFIG_VALIDATE_SECONDS * ONE_SECOND) { lastValidateTimestamp = System.currentTimeMillis(); ((ReloadableDataConfigManagerSupport) dataConfigManager).validateAndReloadConfigs(); if (dataConfigManager instanceof ConfigurableDataConfigManager) { ((ConfigurableDataConfigManager) dataConfigManager).recalcConfigLocations(); } } } String viewName = extractViewName(uri); if (listeners != null) { synchronized (listeners) { for (ViewResolverListener listener : listeners) { listener.beforeResolveView(viewName); } } } DoradoContext context = DoradoContext.getCurrent(); ViewConfig viewConfig = null; try { viewConfig = viewConfigManager.getViewConfig(viewName); } catch (FileNotFoundException e) { throw new PageNotFoundException(e); } View view = viewConfig.getView(); ViewCacheMode cacheMode = ViewCacheMode.none; ViewCache cache = view.getCache(); if (cache != null && cache.getMode() != null) { cacheMode = cache.getMode(); } if (ViewCacheMode.clientSide.equals(cacheMode)) { long maxAge = cache.getMaxAge(); if (maxAge <= 0) { maxAge = Configure.getLong("view.clientSideCache.defaultMaxAge", 300); } response.addHeader(HttpConstants.CACHE_CONTROL, HttpConstants.MAX_AGE + maxAge); } else { response.addHeader(HttpConstants.CACHE_CONTROL, HttpConstants.NO_CACHE); response.addHeader("Pragma", "no-cache"); response.addHeader("Expires", "0"); } String pageTemplate = view.getPageTemplate(); String pageUri = view.getPageUri(); if (StringUtils.isNotEmpty(pageTemplate) && StringUtils.isNotEmpty(pageUri)) { throw new IllegalArgumentException( "Can not set [view.pageTemplate] and [view.pageUri] at the same time."); } if (StringUtils.isNotEmpty(pageUri)) { ServletContext servletContext = context.getServletContext(); RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher(pageUri); request.setAttribute(View.class.getName(), view); requestDispatcher.include(request, response); } else { org.apache.velocity.context.Context velocityContext = velocityHelper.getContext(view, request, response); Template template = getPageTemplate(pageTemplate); PrintWriter writer = getWriter(request, response); try { template.merge(velocityContext, writer); } finally { writer.flush(); writer.close(); } } if (listeners != null) { synchronized (listeners) { for (ViewResolverListener listener : listeners) { listener.afterResolveView(viewName, view); } } } }
From source file:net.navasoft.madcoin.backend.services.security.ProviderDataAccess.java
/** * Define mapper.//from w ww . j a v a 2 s.com * * @param username * the username * @return the row mapper * @since 31/08/2014, 07:23:59 PM */ private RowMapper<User> defineMapper(String username) { if (!username.contains("@") && (!StringUtils.containsIgnoreCase(username, ".org") || !StringUtils.containsIgnoreCase(username, ".net") || !StringUtils.containsIgnoreCase(username, ".gov") || !StringUtils.endsWithIgnoreCase(username, ".com"))) { return nameMapper; } else { return mailMapper; } }
From source file:com.tesora.dve.common.PEFileUtils.java
private static Properties encrypt(Properties props) throws PEException { // we are going to iterate over all properties looking for any that // contain the string "password" for (String key : props.stringPropertyNames()) { if (StringUtils.containsIgnoreCase(key, "password")) { String value = props.getProperty(key); if (!StringUtils.isBlank(value)) { props.setProperty(key, PECryptoUtils.encrypt(value)); }// w ww. j av a2 s . c o m } } return props; }
From source file:crawl.SphinxWrapper.java
private static boolean containsAnyKeyword(String content, List<String> keywords, boolean caseSensitive) { if ((keywords == null) || keywords.isEmpty()) { return true; }//from ww w . j av a 2s . c o m // implied else: test the keywords if (caseSensitive) { for (String kw : keywords) { if (StringUtils.contains(content, kw)) { return true; } } } else { // case-insensitive for (String kw : keywords) { if (StringUtils.containsIgnoreCase(content, kw)) { return true; } } } return false; }
From source file:io.github.mywarp.mywarp.command.InformativeCommands.java
@Command(aliases = { "list", "alist" }, desc = "list.description", help = "list.help") @Require("mywarp.cmd.list") @Billable(FeeType.LIST)/*ww w. j ava2s. c o m*/ public void list(final Actor actor, @OptArg("1") int page, @Switch('c') final String creator, @Switch('n') final String name, @Switch('r') @Range(min = 1, max = Integer.MAX_VALUE) final Integer radius, @Switch('w') final String world) throws IllegalCommandSenderException { // build the listing predicate Predicate<Warp> filter = authorizationResolver.isViewable(actor); if (creator != null) { filter = filter.and(input -> { Optional<String> creatorName = playerNameResolver.getByUniqueId(input.getCreator()); return creatorName.isPresent() && StringUtils.containsIgnoreCase(creatorName.get(), creator); }); } if (name != null) { filter = filter.and(input -> StringUtils.containsIgnoreCase(input.getName(), name)); } if (radius != null) { if (!(actor instanceof LocalEntity)) { throw new IllegalCommandSenderException(actor); } LocalEntity entity = (LocalEntity) actor; final UUID worldId = entity.getWorld().getUniqueId(); final int squaredRadius = radius * radius; final Vector3d position = entity.getPosition(); filter = filter.and(input -> input.getWorldIdentifier().equals(worldId) && input.getPosition().distanceSquared(position) <= squaredRadius); } if (world != null) { filter = filter.and(input -> { Optional<LocalWorld> worldOptional = game.getWorld(input.getWorldIdentifier()); return worldOptional.isPresent() && StringUtils.containsIgnoreCase(worldOptional.get().getName(), world); }); } //query the warps //noinspection RedundantTypeArguments final List<Warp> warps = Ordering.natural().sortedCopy(warpManager.getAll(filter)); Function<Warp, Message> mapping = input -> { // 'name' (world) by player Message.Builder builder = Message.builder(); builder.append("'"); builder.append(input); builder.append("' ("); builder.append(CommandUtil.toWorldName(input.getWorldIdentifier(), game)); builder.append(") "); builder.append(msg.getString("list.by")); builder.append(" "); if (actor instanceof LocalPlayer && input.isCreator(((LocalPlayer) actor).getUniqueId())) { builder.append(msg.getString("list.you")); } else { builder.append(CommandUtil.toName(input.getCreator(), playerNameResolver)); } return builder.build(); }; // display StringPaginator.of(msg.getString("list.heading"), warps).withMapping(mapping::apply).paginate() .display(actor, page); }
From source file:me.taylorkelly.mywarp.bukkit.commands.InformativeCommands.java
/** * Lists viewable Warps.//w w w. j av a 2s . c o m * * @param actor the Actor * @param page the page to display * @param creator the optional creator * @param name the optional name * @param radius the optional radius * @param world the optional world * @throws IllegalCommandSenderException if the {@code r} flag is used by an Actor that is not an Entity */ @Command(aliases = { "list", "alist" }, desc = "list.description", help = "list.help") @Require("mywarp.cmd.list") @Billable(FeeType.LIST) public void list(final Actor actor, @Optional("1") int page, @Switch('c') final String creator, @Switch('n') final String name, @Switch('r') @Range(min = 1, max = Integer.MAX_VALUE) final Integer radius, @Switch('w') final String world) throws IllegalCommandSenderException { // build the listing predicate List<Predicate<Warp>> predicates = new ArrayList<Predicate<Warp>>(); predicates.add(WarpUtils.isViewable(actor)); if (creator != null) { predicates.add(new Predicate<Warp>() { @Override public boolean apply(Warp input) { com.google.common.base.Optional<String> creatorName = input.getCreator().getName(); return creatorName.isPresent() && StringUtils.containsIgnoreCase(creatorName.get(), creator); } }); } if (name != null) { predicates.add(new Predicate<Warp>() { @Override public boolean apply(Warp input) { return StringUtils.containsIgnoreCase(input.getName(), name); } }); } if (radius != null) { if (!(actor instanceof LocalEntity)) { throw new IllegalCommandSenderException(actor); } LocalEntity entity = (LocalEntity) actor; final UUID worldId = entity.getWorld().getUniqueId(); final int squaredRadius = radius * radius; final Vector3 position = entity.getPosition(); predicates.add(new Predicate<Warp>() { @Override public boolean apply(Warp input) { return input.getWorldIdentifier().equals(worldId) && input.getPosition().distanceSquared(position) <= squaredRadius; } }); } if (world != null) { predicates.add(new Predicate<Warp>() { @Override public boolean apply(Warp input) { return StringUtils.containsIgnoreCase(input.getWorld().getName(), world); } }); } //query the warps List<Warp> warps = Ordering.natural().sortedCopy(warpManager.filter(Predicates.<Warp>and(predicates))); Function<Warp, String> mapping = new Function<Warp, String>() { @Override public String apply(Warp input) { // 'name' by player StringBuilder first = new StringBuilder(); //first.append(ChatColor.WHITE); //first.append("'"); first.append(ChatColor.GREEN); first.append(input.getName()); //first.append(ChatColor.WHITE); //first.append("' "); //first.append(MESSAGES.getString("list.by")); //first.append(" "); //first.append(ChatColor.ITALIC); //if (actor instanceof LocalPlayer && input.isCreator((LocalPlayer) actor)) { // first.append(MESSAGES.getString("list.you")); //} else { // Profile creator = input.getCreator(); // first.append(creator.getName().or(creator.getUniqueId().toString())); //} // @(x, y, z) StringBuilder last = new StringBuilder(); last.append(ChatColor.RESET); last.append(input.getWorld().getName()); last.append("@("); last.append(input.getPosition().getFloorX()); last.append(", "); last.append(input.getPosition().getFloorY()); last.append(", "); last.append(input.getPosition().getFloorZ()); last.append(")"); return FormattingUtils.twoColumnAlign(first.toString(), last.toString()); } }; // display StringPaginator.of(MESSAGES.getString("list.heading"), warps).withMapping(mapping).paginate().display(actor, page); }