List of usage examples for java.util.regex PatternSyntaxException toString
public String toString()
From source file:edu.umd.cs.findbugs.util.Strings.java
/** * Initialize regular expressions used in unescaping. This method will be * invoked automatically the first time a string is unescaped. *//*from ww w .j a va 2 s .co m*/ public static boolean initializeUnescapePattern() { if (paternIsInitialized == true) { return true; } synchronized (unescapeInitLockObject) { if (paternIsInitialized == true) { return true; } try { unescapePattern = Pattern.compile(unicodeUnescapeMatchExpression); } catch (PatternSyntaxException pse) { /* * the pattern is compiled from a final string, so this * exception should never be thrown */ System.err.println("Imposible error: " + "static final regular expression pattern " + "failed to compile. Exception: " + pse.toString()); return false; } paternIsInitialized = true; } return true; }
From source file:org.sonews.daemon.command.ListCommand.java
private void printGroupInfo(NNTPConnection conn, String pattern) throws IOException, StorageBackendException { final List<Group> groups = Group.getAll(); if (groups != null) { conn.println("215 list of newsgroups follows"); for (Group g : groups) { try { Matcher matcher = pattern == null ? null : Pattern.compile(pattern).matcher(g.getName()); if (!g.isDeleted() && (matcher == null || matcher.find())) { String writeable = g.isWriteable() ? " y" : " n"; // Indeed first the higher article number then the lower conn.println(g.getName() + " " + g.getLastArticleNumber() + " " + g.getFirstArticleNumber() + writeable); }// w w w .j a va 2 s . c om } catch (PatternSyntaxException ex) { Log.get().info(ex.toString()); } } conn.println("."); } else { conn.println("500 server backend malfunction"); } }
From source file:de.saly.elasticsearch.river.imap.IMAPRiver.java
public void once() throws MessagingException, IOException { mailDestination.startup();/*from w w w. j av a 2 s . co m*/ logger.debug("once() start"); final MailFlowJob mfj = new MailFlowJob(); try { mfj.setPattern(folderPattern == null ? null : Pattern.compile(folderPattern)); } catch (final PatternSyntaxException e) { logger.error("folderpattern is invalid due to {}", e, e.toString()); } mfj.setMailSource(mailSource); mfj.execute(); logger.debug("once() end"); }
From source file:de.saly.elasticsearch.river.imap.IMAPRiver.java
@Override public void start() { logger.info("Start IMAPRiver ..."); try {/* ww w. ja v a 2 s . c o m*/ mailDestination.startup(); sched = StdSchedulerFactory.getDefaultScheduler(); if (sched.isShutdown()) { logger.error("Scheduler already down"); } if (sched.isStarted()) { logger.error("Scheduler already started"); } final JobDataMap jdm = new JobDataMap(); jdm.put("mailSource", mailSource); try { if (folderPattern != null) { jdm.put("pattern", Pattern.compile(folderPattern)); } } catch (final PatternSyntaxException e) { logger.error("folderpattern is invalid due to {}", e, e.toString()); } final JobDetail job = newJob(MailFlowJob.class) .withIdentity(riverName + "-" + props.hashCode(), "group1").usingJobData(jdm).build(); Trigger trigger = null; if (StringUtils.isEmpty(schedule)) { logger.info("Trigger interval is every {} seconds", interval.seconds()); trigger = newTrigger().withIdentity("intervaltrigger", "group1").startNow() .withSchedule( simpleSchedule().withIntervalInSeconds((int) interval.seconds()).repeatForever()) .build(); } else { logger.info("Trigger follows cron pattern {}", schedule); trigger = newTrigger().withIdentity("crontrigger", "group1").withSchedule(cronSchedule(schedule)) .build(); } sched.scheduleJob(job, trigger); sched.start(); logger.info("IMAPRiver started"); } catch (final Exception e) { logger.error("Unable to start IMAPRiver due to " + e, e); } }
From source file:de.saly.elasticsearch.importer.imap.impl.IMAPImporter.java
public void once() throws MessagingException, IOException { for (int i = 0; i < mailSources.size(); i++) { MailSource mailSource = mailSources.get(i); mailSource.getMailDestination().startup(); logger.debug("once() start"); final MailFlowJob mfj = new MailFlowJob(); try {//from w w w .ja v a 2s . c o m mfj.setPattern(folderPattern == null ? null : Pattern.compile(folderPattern)); } catch (final PatternSyntaxException e) { logger.error("folderpattern is invalid due to {}", e, e.toString()); } mfj.setMailSource(mailSource); mfj.execute(); logger.debug("once() end"); } }
From source file:com.streamsets.pipeline.stage.origin.logtail.FileTailSource.java
private boolean validatePatternIsValidRegex(FileInfo fileInfo, List<ConfigIssue> issues) { try {//w ww .ja v a 2 s.com Pattern.compile(fileInfo.patternForToken); } catch (PatternSyntaxException ex) { issues.add(getContext().createConfigIssue(Groups.FILES.name(), FILE_TAIL_CONF_PREFIX + "fileInfos", Errors.TAIL_09, fileInfo.fileFullPath, fileInfo.patternForToken, ex.toString())); return false; } return true; }
From source file:org.apache.nutch.indexer.replace.FieldReplacer.java
/** * Create a FieldReplacer for a field.// w w w . jav a2 s . c o m * * Any pattern exceptions are caught within this constructor and the object is * marked inValid. The error will be logged. This prevents this caller from * attempting invalid replacements. * * @param fieldName * the name of the source field to operate on. Required. * @param toFieldName * the name of the target field. Required. * @param pattern * the pattern the field must match. Required. * @param replacement * the replacement string * @param flags * the Pattern flags value, or null if no flags are needed */ public FieldReplacer(String fieldName, String toFieldName, String pattern, String replacement, Integer flags) { this.isValid = true; // Must have a non-empty field name and pattern. if (fieldName == null || fieldName.trim().length() == 0) { LOG.error("Empty fieldName provided, FieldReplacer marked invalid."); this.isValid = false; } if (pattern == null || pattern.trim().length() == 0) { LOG.error("Empty pattern for field " + fieldName + "provided, FieldReplacer marked invalid."); this.isValid = false; } if (replacement == null) { this.replacement = ""; } else { this.replacement = replacement; } this.fieldName = fieldName.trim(); this.toFieldName = toFieldName.trim(); if (this.isValid) { LOG.info("Compiling pattern " + pattern + " for field " + fieldName); Pattern myPattern = null; try { if (flags != null) { myPattern = Pattern.compile(pattern, flags); } else { myPattern = Pattern.compile(pattern); } } catch (PatternSyntaxException e) { LOG.error("Pattern " + pattern + " for field " + fieldName + " failed to compile: " + e.toString()); this.isValid = false; } this.pattern = myPattern; } else { this.pattern = null; } }