public static Pattern createPattern(String pattern,boolean isRegex,boolean isStringMatcher,boolean isCaseSensitive,boolean isWholeWord) throws PatternSyntaxException {
  if (isRegex) {
    pattern=substituteLinebreak(pattern);
    Assert.isTrue(!isWholeWord,"isWholeWord unsupported together with isRegex");
  }
 else {
    int len=pattern.length();
    StringBuffer buffer=new StringBuffer(len + 10);
    if (isWholeWord && len > 0 && isWordChar(pattern.charAt(0))) {
      buffer.append("\\b");
    }
    appendAsRegEx(isStringMatcher,pattern,buffer);
    if (isWholeWord && len > 0 && isWordChar(pattern.charAt(len - 1))) {
      buffer.append("\\b");
    }
    pattern=buffer.toString();
  }
  int regexOptions=Pattern.MULTILINE;
  if (!isCaseSensitive) {
    regexOptions|=Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE;
  }
  return Pattern.compile(pattern,regexOptions);
}

public static Pattern createPattern ( String pattern , boolean isRegex , boolean isStringMatcher , boolean isCaseSensitive , boolean isWholeWord ) throws PatternSyntaxException { if ( isRegex ) { pattern = substituteLinebreak ( pattern ) ; Assert . isTrue ( ! isWholeWord , "isWholeWord unsupported together with isRegex" ) ; } else { int len = pattern . length ( ) ; StringBuffer buffer = new StringBuffer ( len + 10 ) ; if ( isWholeWord && len > 0 && isWordChar ( pattern . charAt ( 0 ) ) ) { buffer . append ( "\\b" ) ; } appendAsRegEx ( isStringMatcher , pattern , buffer ) ; if ( isWholeWord && len > 0 && isWordChar ( pattern . charAt ( len - 1 ) ) ) { buffer . append ( "\\b" ) ; } pattern = buffer . toString ( ) ; } int regexOptions = Pattern . MULTILINE ; if ( ! isCaseSensitive ) { regexOptions |= Pattern . CASE_INSENSITIVE | Pattern . UNICODE_CASE ; } return Pattern . compile ( pattern , regexOptions ) ; }
creates a pattern element from the pattern string which is either a reg - ex expression or in our old ' stringmatcher ' format .
