* @throws PatternException when something went wrong.
*/
protected REProgram preparePattern(String pattern)
throws PatternException {
if (pattern == null) {
throw new PatternException("null passed as a pattern", null);
}
if (pattern.length() == 0) {
pattern = "^$";
if (getLogger().isWarnEnabled()) {
getLogger().warn("The empty pattern string was rewritten to '^$'" +
" to match for empty strings. If you intended" +
" to match all strings, please change your" + " pattern to '.*'");
}
}
try {
RECompiler compiler = new RECompiler();
REProgram program = compiler.compile(pattern);
return program;
} catch (RESyntaxException rse) {
getLogger().debug("Failed to compile the pattern '" + pattern + "'", rse);
throw new PatternException(rse.getMessage(), rse);
}
}