Java Code Examples for java.util.regex.PatternSyntaxException#getDescription()

The following examples show how to use java.util.regex.PatternSyntaxException#getDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompileCommandsJsonParserOptionPage.java    From cmake4eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
  // normally should be handled by LanguageSettingsProviderTab
  final String text = pattern.getText();
  try {
    Pattern.compile(text);
  } catch (PatternSyntaxException ex) {
    // BUG in CDT: core exceptions thrown here are not visible to users. CDT-WTF
    // IStatus status = new Status(IStatus.ERROR, Plugin.PLUGIN_ID,
    // IStatus.OK,
    // "invalid suffix pattern in CMAKE_EXPORT_COMPILE_COMMANDS Parser", ex);
    // throw new CoreException(status);

    throw new PatternSyntaxException(
        "Invalid suffix pattern in CMAKE_EXPORT_COMPILE_COMMANDS Parser:\n" + ex.getDescription(), ex.getPattern(),
        ex.getIndex());
  }
}
 
Example 2
Source File: FilterEditorActivity.java    From NekoSMS with GNU General Public License v3.0 6 votes vote down vote up
private String validatePatternString(SmsFilterPatternData patternData, int fieldNameId) {
    if (patternData.getMode() != SmsFilterMode.REGEX) {
        return null;
    }
    String pattern = patternData.getPattern();
    try {
        // We don't need the actual compiled pattern, this
        // is just to make sure the syntax is valid
        Pattern.compile(pattern);
    } catch (PatternSyntaxException e) {
        String description = e.getDescription();
        if (description == null) {
            description = getString(R.string.invalid_pattern_reason_unknown);
        }
        return getString(R.string.format_invalid_pattern_message, getString(fieldNameId), description);
    }
    return null;
}
 
Example 3
Source File: Bucket4JBaseConfiguration.java    From bucket4j-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
private void throwExceptionOnInvalidFilterUrl(FilterConfiguration<R> filterConfig) {
	try {
		Pattern.compile(filterConfig.getUrl());
		if(filterConfig.getUrl().equals("/*")) {
			throw new PatternSyntaxException(filterConfig.getUrl(), "/*", 0);
		}
	} catch( PatternSyntaxException exception) {
		throw new FilterURLInvalidException(filterConfig.getUrl(), exception.getDescription());
	}
}