props.getProperty(RESOURCE_NAME_REGEX) + "!/META-INF/MANIFEST.MF"); } catch (PatternSyntaxException e) { LOGGER.log(java.util.logging.Level.SEVERE, e.getLocalizedMessage(), e); throw e;
public static void addRegex(Collection list, String regex) { try { Pattern pattern = Pattern.compile(regex); list.add(pattern); } catch (PatternSyntaxException pse) { logger.warn("The regular expression " + regex + " is invalid: " + pse.getLocalizedMessage()); } }
private void updatePattern(EditingPanel panel) { try { result = Pattern.compile(panel.editorPane.getText()); panel.helpText.setText(null); panel.helpText.setToolTipText(null); panel.okButton.setEnabled(true); } catch (PatternSyntaxException ex) { panel.helpText.setText(ex.getLocalizedMessage()); panel.helpText.setToolTipText(ex.getLocalizedMessage()); panel.okButton.setEnabled(false); } }
public static FormValidation validateRegularExpression(final String value) { try { Pattern.compile(value); return FormValidation.ok(); } catch (PatternSyntaxException pse) { return FormValidation.error(pse, Messages.validator_regularExpression(pse.getLocalizedMessage())); } }
@Override public boolean validate() { boolean result = true; String customPatternMessage = null; String removePatternMessage = null; try { Pattern.compile(panel.customPatternRegExpTF.getText()); } catch (PatternSyntaxException e) { result = false; customPatternMessage = e.getLocalizedMessage(); } try { Pattern.compile(panel.removePatternRegExpTF.getText()); } catch (PatternSyntaxException e) { result = false; removePatternMessage = e.getLocalizedMessage(); } panel.customPatternWarningTextArea.setText(customPatternMessage); panel.removePatternWarningTextArea.setText(removePatternMessage); return result; }
/** * Creates a new instance of {@link JavaRegExp} for the given regular expression string. * * @param regExpString * a regular expression string * @exception InitializationException * if regular expression is not well formed */ public JavaRegExp(String regExpString) { try { this.re = Pattern.compile(regExpString); } catch (PatternSyntaxException pse) { throw new InitializationException(pse.getLocalizedMessage(), pse); } }
private boolean validateRegex() { try { Pattern.compile(fTestPluginPatternText.getText()); } catch (PatternSyntaxException e) { String locMessage = e.getLocalizedMessage(); int i = 0; while (i < locMessage.length() && "\n\r".indexOf(locMessage.charAt(i)) == -1) { //$NON-NLS-1$ i++; } setErrorMessage(locMessage.substring(0, i)); return false; } setErrorMessage(null); return true; }
/** * Performs on-the-fly validation on the regular expression. * * @param regexp * the regular expression * @return the validation result */ public FormValidation doCheckRegexp(@QueryParameter(required = true) final String regexp) { try { if (StringUtils.isBlank(regexp)) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_isEmpty()); } Pattern.compile(regexp); return FormValidation.ok(); } catch (PatternSyntaxException exception) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_invalid(exception.getLocalizedMessage())); } }
/** * Performs on-the-fly validation on the regular expression. * * @param regexp * the regular expression * @return the validation result */ public static FormValidation doCheckRegexp(final String regexp) { try { if (StringUtils.isBlank(regexp)) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_isEmpty()); } Pattern.compile(regexp); return FormValidation.ok(); } catch (PatternSyntaxException exception) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_invalid(exception.getLocalizedMessage())); } }
/** * Performs on-the-fly validation on the regular expression. * * @param regexp * the regular expression * @return the validation result */ public FormValidation doCheckRegexp(@QueryParameter(required = true) final String regexp) { try { if (StringUtils.isBlank(regexp)) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_isEmpty()); } Pattern.compile(regexp); return FormValidation.ok(); } catch (PatternSyntaxException exception) { return FormValidation.error(Messages.Warnings_GroovyParser_Error_Regexp_invalid(exception.getLocalizedMessage())); } }
private boolean validateRegex() { if (fIsRegExCheckbox.getSelection()) { try { Pattern.compile(fPattern.getText()); } catch (PatternSyntaxException e) { String locMessage= e.getLocalizedMessage(); int i= 0; while (i < locMessage.length() && "\n\r".indexOf(locMessage.charAt(i)) == -1) { //$NON-NLS-1$ i++; } statusMessage(true, locMessage.substring(0, i)); // only take first line return false; } statusMessage(false, ""); //$NON-NLS-1$ } else { statusMessage(false, SearchMessages.SearchPage_containingText_hint); } return true; }
@Override protected boolean validateFields() { try { Pattern.compile(getRegexTextField().getText(), Pattern.CASE_INSENSITIVE); } catch (PatternSyntaxException e) { JOptionPane.showMessageDialog( this, MessageFormat.format(TEXT_INVALID_REGEX_DIALOG, e.getLocalizedMessage()), TITLE_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } return true; }
private boolean validateRegex() { if (isRegExButton.getSelection()) { try { PatternUtils.createPattern(patternCombo.getText(), isCaseSensitiveButton.getSelection(), true); } catch (PatternSyntaxException e) { String locMessage = e.getLocalizedMessage(); int i = 0; while (i < locMessage.length() && "\n\r".indexOf(locMessage.charAt(i)) == -1) //$NON-NLS-1$ i++; statusMessage(true, locMessage.substring(0, i)); return false; } statusMessage(false, ""); //$NON-NLS-1$ } else { statusMessage(false, UIText.CommitSearchPage_ContainingTextHint); } return true; }
/** * Performs on-the-fly validation on threshold for high warnings. * * @param pattern * the pattern to check * * @return the validation result */ public FormValidation doCheckPattern(@QueryParameter final String pattern) { try { if (StringUtils.isBlank(pattern)) { return FormValidation.ok(Messages.pattern_blank()); } Pattern compiled = Pattern.compile(pattern); Ensure.that(compiled).isNotNull(); return FormValidation.ok(); } catch (PatternSyntaxException exception) { return FormValidation.error(Messages.pattern_error(exception.getLocalizedMessage())); } } }
private boolean validateRegex() { if (fIsRegExCheckbox.getSelection()) { try { PatternConstructor.createPattern(fPattern.getText(), fIsCaseSensitive, true); } catch (PatternSyntaxException e) { String locMessage= e.getLocalizedMessage(); int i= 0; while (i < locMessage.length() && "\n\r".indexOf(locMessage.charAt(i)) == -1) { //$NON-NLS-1$ i++; } statusMessage(true, locMessage.substring(0, i)); // only take first line return false; } statusMessage(false, ""); //$NON-NLS-1$ } else { statusMessage(false, SearchMessages.SearchPage_containingText_hint); } return true; }
final void updateOKStatus() { RefactoringStatus status= new RefactoringStatus(); if (fReplaceWithRegex != null && fReplaceWithRegex.getSelection()) { try { PatternConstructor.interpretReplaceEscapes(fReplaceWithRegex.getText(), fReplaceRefactoring.getQuery().getSearchString(), "\n"); //$NON-NLS-1$ } catch (PatternSyntaxException e) { String locMessage= e.getLocalizedMessage(); int i= 0; while (i < locMessage.length() && "\n\r".indexOf(locMessage.charAt(i)) == -1) { //$NON-NLS-1$ i++; } status.addError(locMessage.substring(0, i)); // only take first line } } setPageComplete(status); }
/** * Checks text value of JTextField if it is a valid regular expression. If not, focus is set to the text field and * an alert is shown. * * @param textfield * the text field with the regular expression * @return true if regular expression is valid, false otherwise */ private boolean checkRegExp(JTextField textfield) { try { Pattern.compile(textfield.getText()); } catch (PatternSyntaxException e) { textfield.setCaretPosition(e.getIndex()); JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), OStrings.getString("HTML_ERROR_CUSTOMREGEXP_TITLE"), JOptionPane.ERROR_MESSAGE); textfield.grabFocus(); return false; } return true; }
/** * Checks text value of JTextField if it is a valid regular expression. If not, focus is set to the text field and * an alert is shown. * * @param textfield * the text field with the regular expression * @return true if regular expression is valid, false otherwise */ private boolean checkRegExp(JTextField textfield) { try { Pattern.compile(textfield.getText()); } catch (PatternSyntaxException e) { textfield.setCaretPosition(e.getIndex()); JOptionPane.showMessageDialog(this, e.getLocalizedMessage(), OStrings.getString("HTML_ERROR_CUSTOMREGEXP_TITLE"), JOptionPane.ERROR_MESSAGE); textfield.grabFocus(); return false; } return true; }
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException { MavenProject project; try { project = (MavenProject) helper.evaluate("${project}"); if (project.getUrl() == null) { throw new EnforcerRuleException("The project URL is not defined"); } Matcher matcher = Pattern.compile(regex).matcher(project.getUrl()); if (!matcher.matches()) { throw new EnforcerRuleException( "The project URL " + project.getUrl() + " does not match the required regex: " + regex); } } catch (ExpressionEvaluationException e) { throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e); } catch (PatternSyntaxException e) { throw new EnforcerRuleException("Invalid regex \"" + regex + "\": " + e.getLocalizedMessage(), e); } }
/** * Replaces the current selection of the target with the user's * replace string. * * @return <code>true</code> if the operation was successful */ private boolean performReplaceSelection() { if (!validateTargetState()) return false; String replaceString= getReplaceString(); if (replaceString == null) replaceString= ""; //$NON-NLS-1$ boolean replaced; try { replaceSelection(replaceString, isRegExSearchAvailableAndChecked()); replaced= true; writeSelection(); } catch (PatternSyntaxException ex) { statusError(ex.getLocalizedMessage()); replaced= false; } catch (IllegalStateException ex) { replaced= false; } return replaced; }