@Test public void testLinkifyPattern() { String text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " + "sed do eiusmod tempor incididunt as per 12345698 ut labore et dolore magna " + "aliqua. bug3333fff Ut enim ad minim veniam, quis nostrud exercitation " + "ullamco laboris nisi ut aliquip ex ea introduced in 9791216541 commodo consequat. " + "Duis aute irure dolor in reprehenderit in voluptate velit " + "esse cillum dolore eu fixes 132469187 fugiat nulla pariatur. Excepteur sint " + "occaecat bug6478abc cupidatat non proident, sunt in culpa qui officia " + "deserunt mollit anim id est laborum."; String expected = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " + "sed do eiusmod tempor incididunt as per " + "<a href=\"http: + "aliqua. bug3333fff Ut enim ad minim veniam, quis nostrud exercitation " + "ullamco laboris nisi ut aliquip ex ea introduced in " + "<a href=\"http: + "Duis aute irure dolor in reprehenderit in voluptate velit " + "esse cillum dolore eu fixes " + "<a href=\"http: + "occaecat bug6478abc cupidatat non proident, sunt in culpa qui officia " + "deserunt mollit anim id est laborum."; String expected2 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " + "sed do eiusmod tempor incididunt as per 12345698 ut labore et dolore magna " + "aliqua. " + "<a href=\"http: + "ullamco laboris nisi ut aliquip ex ea introduced in 9791216541 commodo consequat. " + "Duis aute irure dolor in reprehenderit in voluptate velit " + "esse cillum dolore eu fixes 132469187 fugiat nulla pariatur. Excepteur sint " + "occaecat " + "<a href=\"http: + "deserunt mollit anim id est laborum."; assertEquals(expected, Util.linkifyPattern(text, Pattern.compile("\\b([0-9]{8,})\\b"), "$1", "http: assertEquals(expected2, Util.linkifyPattern(text, Pattern.compile("\\b(bug([0-9]{4})\\w{3})\\b"), "$1", "http: }
public static String linkifyPattern(String text, Pattern pattern, String name, String url) { try { String buildLink = buildLink(name, url, true); return pattern.matcher(text).replaceAll(buildLink); } catch (URISyntaxException | MalformedURLException ex) { LOGGER.log(Level.WARNING, "The given URL ''{0}'' is not valid", url); return text; } }
Util { public static String linkifyPattern(String text, Pattern pattern, String name, String url) { try { String buildLink = buildLink(name, url, true); return pattern.matcher(text).replaceAll(buildLink); } catch (URISyntaxException | MalformedURLException ex) { LOGGER.log(Level.WARNING, "The given URL ''{0}'' is not valid", url); return text; } } }
Util { public static String linkifyPattern(String text, Pattern pattern, String name, String url) { try { String buildLink = buildLink(name, url, true); return pattern.matcher(text).replaceAll(buildLink); } catch (URISyntaxException | MalformedURLException ex) { LOGGER.log(Level.WARNING, "The given URL ''{0}'' is not valid", url); return text; } } private  Util(); }
Util { public static String linkifyPattern(String text, Pattern pattern, String name, String url) { try { String buildLink = buildLink(name, url, true); return pattern.matcher(text).replaceAll(buildLink); } catch (URISyntaxException | MalformedURLException ex) { LOGGER.log(Level.WARNING, "The given URL ''{0}'' is not valid", url); return text; } } private  Util(); static String prehtmlize(String s); static String prehtmlize(CharSequence q); static void qurlencode(String str, Appendable dest); static String htmlize(String s); static String htmlize(CharSequence q); static void htmlize(CharSequence q, Appendable dest, boolean pre); static void htmlize(CharSequence q, Appendable dest); static void htmlize(char[] cs, int length, Appendable dest); static String breadcrumbPath(String urlPrefix, String path); static String breadcrumbPath(String urlPrefix, String path, char sep); static String breadcrumbPath(String urlPrefix, String path,
            char sep, String urlPostfix, boolean compact); static String breadcrumbPath(String urlPrefix, String path,
            char sep, String urlPostfix, boolean compact, boolean isDir); static String getCanonicalPath(String path, char sep); static String getEmail(String author); static String readableSize(long num); static String readableCount(long count); static String encode(String s); static void encode(String s, Appendable dest); static String encodeURL(String urlStr); static void readableLine(int num, Writer out, Annotation annotation,
            String userPageLink, String userPageSuffix, String project); static void readableLine(int num, Writer out, Annotation annotation, String userPageLink,
            String userPageSuffix, String project, boolean skipNewline); static String path2uid(String path, String date); static String uid2url(String uid); static String fixPathIfWindows(String path); static void writeHAD(Writer out, String ctxE, String entry,
            boolean is_dir); static String URIEncode(String q); static void URIEncode(String str, Appendable dest); static void appendQuery(StringBuilder buf, String key,
            String value); static String URIEncodePath(String path); static String formQuoteEscape(String q); static String[] diffline(StringBuilder line1, StringBuilder line2); @SuppressWarnings("boxing") static void dumpConfiguration(Appendable out); static void dump(Writer out, Reader in); static boolean dump(Writer out, File dir, String filename,
            boolean compressed); static boolean dump(Writer out, File file, boolean compressed); static boolean dumpXref(Writer out, File file, boolean compressed,
            String contextPath); static void dumpXref(Writer out, Reader in, String contextPath); static String jsStringLiteral(String str); static String stripPathPrefix(String prefix, String fullPath); static String createSlider(int offset, int limit, int size); static String createSlider(int offset, int limit, long size, HttpServletRequest request); static boolean isHttpUri(String string); static String redactUrl(String path); static String linkify(String url); static String linkify(String url, boolean newTab); static String buildLink(String name, Map<String, String> attrs); static String buildLink(String name, String url); static String buildLink(String name, String url, boolean newTab); static String linkifyPattern(String text, Pattern pattern, String name, String url); static String completeUrl(String url, HttpServletRequest req); static Map<String, List<String>> getQueryParams(final URL url); }
Util { public static String linkifyPattern(String text, Pattern pattern, String name, String url) { try { String buildLink = buildLink(name, url, true); return pattern.matcher(text).replaceAll(buildLink); } catch (URISyntaxException | MalformedURLException ex) { LOGGER.log(Level.WARNING, "The given URL ''{0}'' is not valid", url); return text; } } private  Util(); static String prehtmlize(String s); static String prehtmlize(CharSequence q); static void qurlencode(String str, Appendable dest); static String htmlize(String s); static String htmlize(CharSequence q); static void htmlize(CharSequence q, Appendable dest, boolean pre); static void htmlize(CharSequence q, Appendable dest); static void htmlize(char[] cs, int length, Appendable dest); static String breadcrumbPath(String urlPrefix, String path); static String breadcrumbPath(String urlPrefix, String path, char sep); static String breadcrumbPath(String urlPrefix, String path,
            char sep, String urlPostfix, boolean compact); static String breadcrumbPath(String urlPrefix, String path,
            char sep, String urlPostfix, boolean compact, boolean isDir); static String getCanonicalPath(String path, char sep); static String getEmail(String author); static String readableSize(long num); static String readableCount(long count); static String encode(String s); static void encode(String s, Appendable dest); static String encodeURL(String urlStr); static void readableLine(int num, Writer out, Annotation annotation,
            String userPageLink, String userPageSuffix, String project); static void readableLine(int num, Writer out, Annotation annotation, String userPageLink,
            String userPageSuffix, String project, boolean skipNewline); static String path2uid(String path, String date); static String uid2url(String uid); static String fixPathIfWindows(String path); static void writeHAD(Writer out, String ctxE, String entry,
            boolean is_dir); static String URIEncode(String q); static void URIEncode(String str, Appendable dest); static void appendQuery(StringBuilder buf, String key,
            String value); static String URIEncodePath(String path); static String formQuoteEscape(String q); static String[] diffline(StringBuilder line1, StringBuilder line2); @SuppressWarnings("boxing") static void dumpConfiguration(Appendable out); static void dump(Writer out, Reader in); static boolean dump(Writer out, File dir, String filename,
            boolean compressed); static boolean dump(Writer out, File file, boolean compressed); static boolean dumpXref(Writer out, File file, boolean compressed,
            String contextPath); static void dumpXref(Writer out, Reader in, String contextPath); static String jsStringLiteral(String str); static String stripPathPrefix(String prefix, String fullPath); static String createSlider(int offset, int limit, int size); static String createSlider(int offset, int limit, long size, HttpServletRequest request); static boolean isHttpUri(String string); static String redactUrl(String path); static String linkify(String url); static String linkify(String url, boolean newTab); static String buildLink(String name, Map<String, String> attrs); static String buildLink(String name, String url); static String buildLink(String name, String url, boolean newTab); static String linkifyPattern(String text, Pattern pattern, String name, String url); static String completeUrl(String url, HttpServletRequest req); static Map<String, List<String>> getQueryParams(final URL url);  }