@Test public void testLinkify_noLink() throws Exception { links = new ArrayList<>(); final String expected = mockString; assertThat(linkify(links, mockString)).isEqualTo(expected); }
public static String linkify(List<Link> links, String text) { int addedChars = 0; for (Link link : links) { StringBuilder stringBuilder = new StringBuilder(text); int start = link.getStart(); int end = link.getEnd(); String href = link.getHref(); String openTag = String.format(aherf, href); stringBuilder.insert(addedChars + start, openTag); addedChars += openTag.length(); stringBuilder.insert(addedChars + end, closeTag); addedChars += closeTag.length(); text = stringBuilder.toString(); } return text; }
Linky { public static String linkify(List<Link> links, String text) { int addedChars = 0; for (Link link : links) { StringBuilder stringBuilder = new StringBuilder(text); int start = link.getStart(); int end = link.getEnd(); String href = link.getHref(); String openTag = String.format(aherf, href); stringBuilder.insert(addedChars + start, openTag); addedChars += openTag.length(); stringBuilder.insert(addedChars + end, closeTag); addedChars += closeTag.length(); text = stringBuilder.toString(); } return text; } }
Linky { public static String linkify(List<Link> links, String text) { int addedChars = 0; for (Link link : links) { StringBuilder stringBuilder = new StringBuilder(text); int start = link.getStart(); int end = link.getEnd(); String href = link.getHref(); String openTag = String.format(aherf, href); stringBuilder.insert(addedChars + start, openTag); addedChars += openTag.length(); stringBuilder.insert(addedChars + end, closeTag); addedChars += closeTag.length(); text = stringBuilder.toString(); } return text; }  }
Linky { public static String linkify(List<Link> links, String text) { int addedChars = 0; for (Link link : links) { StringBuilder stringBuilder = new StringBuilder(text); int start = link.getStart(); int end = link.getEnd(); String href = link.getHref(); String openTag = String.format(aherf, href); stringBuilder.insert(addedChars + start, openTag); addedChars += openTag.length(); stringBuilder.insert(addedChars + end, closeTag); addedChars += closeTag.length(); text = stringBuilder.toString(); } return text; }  static String linkify(List<Link> links, String text); static boolean hasLinks(List<Link> links); }
Linky { public static String linkify(List<Link> links, String text) { int addedChars = 0; for (Link link : links) { StringBuilder stringBuilder = new StringBuilder(text); int start = link.getStart(); int end = link.getEnd(); String href = link.getHref(); String openTag = String.format(aherf, href); stringBuilder.insert(addedChars + start, openTag); addedChars += openTag.length(); stringBuilder.insert(addedChars + end, closeTag); addedChars += closeTag.length(); text = stringBuilder.toString(); } return text; }  static String linkify(List<Link> links, String text); static boolean hasLinks(List<Link> links);  }