List of usage examples for java.util.regex Pattern CASE_INSENSITIVE
int CASE_INSENSITIVE
To view the source code for java.util.regex Pattern CASE_INSENSITIVE.
Click Source Link
From source file:io.acme.solution.api.validation.UserProfileValidator.java
private void rejectIfNotEmail(final UserProfile profile, final Errors errors) { Pattern validEMailPattern = Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE); if (!validEMailPattern.matcher(profile.getEmail()).matches()) { errors.rejectValue(UserProfile.FIELD_EMAIL, MessageKeys.UserProfile.INVALID_EMAIL); }/* w w w. jav a 2 s. c o m*/ }
From source file:com.krawler.spring.crm.common.globalSearchDAOImpl.java
public KwlReturnObject globalQuickSearch(HashMap<String, Object> requestParams) throws ServiceException { List ll = null;/* w ww .j a v a 2 s. c o m*/ int dl = 0; String keyword = ""; String type = ""; String companyid = ""; String Hql = ""; try { if (requestParams.containsKey("type") && requestParams.get("type") != null) { type = requestParams.get("type").toString(); } if (requestParams.containsKey("keyword") && requestParams.get("keyword") != null) { keyword = StringEscapeUtils.escapeJavaScript(requestParams.get("keyword").toString()); } if (requestParams.containsKey("companyid") && requestParams.get("companyid") != null) { companyid = requestParams.get("companyid").toString(); } Pattern p = Pattern.compile("(?i)tag:['?(\\s*\\w+)'?]*", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(keyword); boolean tagQuery = m.matches(); ArrayList filter_params = new ArrayList(); if (!tagQuery) { String MyQuery = keyword; String MyQuery1 = keyword; if (keyword.length() > 2) { MyQuery = keyword + "%"; MyQuery1 = "% " + MyQuery; } if (type.equals("user")) { Hql = "select u from User u where u.deleteflag = 0 and u.company.companyID= ? and ( u.firstName like ? or u.lastName like ?) "; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and u.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("cam")) { Hql = "select c from CrmCampaign c where c.deleteflag = 0 and c.company.companyID= ? and ( c.campaignname like ? or c.campaignname like ?) and c.isarchive=false and c.validflag=1"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and c.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("acc")) { Hql = "select distinct c from accountOwners ao inner join ao.account c left join c.crmProducts as p where c.deleteflag = 0 and c.company.companyID= ? and ( c.accountname like ? or c.accountname like ?) and c.isarchive=false and c.validflag=1"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and ao.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("opp")) { Hql = "select distinct c from opportunityOwners oo inner join oo.opportunity c left join c.crmProducts as p where c.deleteflag = 0 and c.company.companyID= ? and ( c.oppname like ? or c.oppname like ?) and c.isarchive=false and c.validflag=1"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and oo.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("lea")) { Hql = "select distinct c from LeadOwners lo inner join lo.leadid c left join c.crmProducts as p where c.deleteflag = 0 and c.company.companyID= ? and ( c.lastname like ? or c.lastname like ?) and c.isarchive=false and c.validflag=1 and c.isconverted= 0"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and lo.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("con")) { Hql = "select distinct c from contactOwners co inner join co.contact c where c.deleteflag = 0 and c.company.companyID= ? and ( c.firstname like ? or c.firstname like ? or c.lastname like ? or c.lastname like ?) and c.isarchive=false and c.validflag=1 "; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and co.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("cas")) { Hql = "select c from CrmCase c where c.deleteflag = 0 and c.company.companyID= ? and ( c.subject like ? or c.subject like ? ) and c.isarchive=false and c.validflag=1"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and c.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("pro")) { Hql = "select c from CrmProduct c where c.deleteflag = 0 and c.company.companyID= ? and ( c.productname like ? or c.productname like ?) and c.isarchive=false and c.validflag=1"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and c.usersByUserid.userID in (" + requestParams.get("usersList").toString() + ") "; } } else if (type.equals("docs")) { Hql = "select c from com.krawler.common.admin.Docs c where c.company.companyID=? and c.deleteflag=0 and ( c.docname like ? or c.docname like ?)"; filter_params.add(companyid); filter_params.add(MyQuery); filter_params.add(MyQuery1); if (requestParams.containsKey("usersList") && requestParams.get("usersList") != null) { Hql += " and c.userid.userID in (" + requestParams.get("usersList").toString() + ") "; } } } ll = executeQuery(Hql, filter_params.toArray()); dl = ll.size(); } catch (Exception e) { logger.warn(e.getMessage(), e); throw ServiceException.FAILURE("globalSearchDAOImpl.globalQuickSearch", e); } return new KwlReturnObject(true, KWLErrorMsgs.S01, "", ll, dl); }
From source file:me.ryandowling.allmightybot.listeners.LinkListener.java
@Override public void onMessage(MessageEvent event) throws Exception { super.onMessage(event); if (!this.bot.getSettings().shouldTimeoutLinks() || event.getUser() == event.getBot().getUserBot() || bot.isModerator(event.getUser().getNick()) || PermitCommand.hasPermit(event.getUser().getNick()) || !LINK_PATTERN.matcher(event.getMessage()).find()) { return;//w ww.ja v a2 s .co m } boolean containsDomain = false; // Loop through the list of domains in the domains list (read from the jar) to see if it contains it Pattern domainPattern; for (String domain : domains) { domainPattern = Pattern.compile(".*\\." + domain + " ?\\b", Pattern.CASE_INSENSITIVE); if (domainPattern.matcher(event.getMessage()).find()) { containsDomain = true; break; } } if (!containsDomain) { return; } boolean matched = false; for (String regex : this.bot.getAllowedLinks()) { Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); if (pattern.matcher(event.getMessage()).find()) { matched = true; break; } } if (!matched) { if (!warnings.containsKey(event.getUser().getNick())) { warnings.put(event.getUser().getNick(), 1); event.getChannel().send().message(App.INSTANCE.getLangValue("linkTimeoutMessageWarning1")); event.getChannel().send().message(".timeout " + event.getUser().getNick() + " " + 1); } else { int timeoutLength; if (warnings.get(event.getUser().getNick()) == 1) { warnings.put(event.getUser().getNick(), 2); timeoutLength = App.INSTANCE.getSettings().getLinkTimeoutLength1(); } else { timeoutLength = App.INSTANCE.getSettings().getLinkTimeoutLength2(); } event.getChannel().send() .message(Utils.replaceVariablesInString( App.INSTANCE.getLangValue("linkTimeoutMessageWarning2"), Utils.timeConversion(timeoutLength))); event.getChannel().send().message(".timeout " + event.getUser().getNick() + " " + timeoutLength); } } }
From source file:org.seedstack.monitoring.batch.internal.rest.job.JobResource.java
/** * Retrieves the list of jobs./*from www. j a v a 2 s . c om*/ * * @param pageIndex the page index * @param pageSize the page size * @return the response */ @GET @Produces(MediaType.APPLICATION_JSON) @RequiresPermissions("seed:monitoring:batch:read") public Response jobs(@DefaultValue("1") @QueryParam("pageIndex") int pageIndex, @DefaultValue("20") @QueryParam("pageSize") int pageSize, @QueryParam("searchedJob") String searchedJob) { Collection<String> names; int totalItems = jobService.countJobs(); if (searchedJob != null) { names = Collections2.filter(jobService.listJobs(0, totalItems), Predicates.contains(Pattern.compile(searchedJob, Pattern.CASE_INSENSITIVE))); totalItems = names.size(); } else { int startJob = (pageIndex - 1) * pageSize; names = jobService.listJobs(startJob, pageSize); } ArrayList<JobInfo> jobs = new ArrayList<JobInfo>(); for (String name : names) { int count; try { count = jobService.countJobExecutionsForJob(name); } catch (NoSuchJobException e) { return Response.status(Response.Status.BAD_REQUEST).entity("There is no such jobs ") .type(MediaType.TEXT_PLAIN).build(); } boolean launchable = jobService.isLaunchable(name); boolean incrementable = jobService.isIncrementable(name); JobInfo jobsInfo = new JobInfo(name, count, null, launchable, incrementable); jobs.add(jobsInfo); } JobRepresentation jobRepresentation = new JobRepresentation(pageIndex, pageSize, totalItems, jobs); return Response.ok(jobRepresentation).build(); }
From source file:com.streamreduce.core.dao.UserDAO.java
public User findUserForUsername(Account account, String username) { return ds.createQuery(entityClazz).field("username") .equal(Pattern.compile("^\\Q" + username + "\\E$", Pattern.CASE_INSENSITIVE)).field("account") .equal(account).get();// w w w. ja v a 2 s . c o m }
From source file:com.michellemay.matchers.MatchersFactory.java
private Matcher createMacher(MatcherConfig matcherConfig) { if (StringUtils.isBlank(matcherConfig.name)) { throw new IllegalArgumentException("Blank matcher name!"); }//from w w w.j a v a 2 s. com if (matcherConfig.urlpart == null) { throw new IllegalArgumentException("Matcher must apply to an urlpart!"); } Optional<Mapping> mapping = Optional.empty(); if (matcherConfig.mapping != null) { if (StringUtils.isBlank(matcherConfig.mapping) || !mappingsFactory.getMappings().containsKey(matcherConfig.mapping)) { throw new IllegalStateException("Mapping '" + matcherConfig.mapping + "' does not exists!"); } mapping = Optional.of(mappingsFactory.getMappings().get(matcherConfig.mapping)); } if (matcherConfig.patterns == null || matcherConfig.patterns.isEmpty()) { throw new IllegalArgumentException("Matcher must have non-empty patterns list!"); } int flags = matcherConfig.casesensitive ? 0 : Pattern.CASE_INSENSITIVE; ArrayList<Pattern> patterns = Lists.newArrayList(); matcherConfig.patterns.forEach((patternStr) -> { // Must contain a capturing group named 'lang'. ex: (?<lang>\w+) if (!patternStr.contains("(?<lang>")) { throw new IllegalArgumentException( "Matcher pattern '" + patternStr + "' must have a capturing group named 'lang'!"); } patterns.add(Pattern.compile(patternStr, flags)); }); return createMatcher(matcherConfig.name, matcherConfig.urlpart).withPatterns(patterns) .withCaseSensitive(matcherConfig.casesensitive).withMapping(mapping) .withPatternOrder(matcherConfig.patternorder); }
From source file:net.sf.jabref.logic.groups.KeywordGroup.java
private void compilePattern() throws ParseException { try {/*w ww . j ava2 s.c om*/ pattern = caseSensitive ? Pattern.compile("\\b" + searchExpression + "\\b") : Pattern.compile("\\b" + searchExpression + "\\b", Pattern.CASE_INSENSITIVE); } catch (PatternSyntaxException exception) { throw new ParseException( Localization.lang("Syntax error in regular-expression pattern", searchExpression)); } }
From source file:com.jaeksoft.searchlib.crawler.web.database.UrlFilterItem.java
private void compilePattern() { if (pattern == null || pattern.length() == 0) { compiledPattern = null;//from w w w .j av a 2 s .c om return; } compiledPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); }
From source file:net.longfalcon.newsj.Nfo.java
/** * only returns one NFO. dunno about releases with two nfos. * @param release/*ww w .j a v a 2s. c o m*/ * @return */ @Transactional(readOnly = true, propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED) public ReleaseNfo determineReleaseNfo(Release release) { Pattern nfoPattern = Pattern.compile(".*\\.nfo[ \"\\)\\]\\-]?.*", Pattern.CASE_INSENSITIVE); List<Binary> binaryList = binaryDAO.findBinariesByReleaseId(release.getId()); for (Binary binary : binaryList) { Matcher matcher = nfoPattern.matcher(binary.getName()); if (matcher.matches()) { ReleaseNfo releaseNfo = new ReleaseNfo(); releaseNfo.setBinary(binary); releaseNfo.setRelease(release); return releaseNfo; } } return null; }
From source file:com.norconex.importer.handler.transformer.impl.ReplaceTransformer.java
@Override protected void transformStringContent(String reference, StringBuilder content, ImporterMetadata metadata, boolean parsed, boolean partialContent) { String text = content.toString(); content.setLength(0);/*from ww w . java 2s. c o m*/ Pattern pattern = null; for (String from : replacements.keySet()) { String to = replacements.get(from); if (caseSensitive) { pattern = Pattern.compile(from); } else { pattern = Pattern.compile(from, Pattern.CASE_INSENSITIVE); } text = pattern.matcher(text).replaceAll(to); } content.append(text); }