/** * Render an origin to an HTML block * * @param location * origin location * @return a string representing an HTML block containing a link to the * origin */ public static String formatAsBlock(final Location location) { return format(location, false); }
private static String formatNonEmptyLocation(final Location location, final boolean asSpan) { final String path = location.getPath(); final URI uri = checkPathHasProtocol(path) ? convertPathWithProtocolToUri(path) : convertPathWithoutProtocolToUri(path); final StringBuilder builder = new StringBuilder(); builder.append(asSpan ? "<span" : "<p"); builder.append(" class=\"origin\">"); if (uri != null) { builder.append("<a href=\""); builder.append(uri); builder.append("\">"); builder.append(path); builder.append("</a>"); } else { builder.append(path); } builder.append(":"); final int line = location.getLine(); builder.append(line); builder.append(asSpan ? "</span>" : "</p>"); return builder.toString(); }
private static URI convertPathWithoutProtocolToUri(final String path) { final Path realPath = Paths.get(unWindowsify(path)); if (realPath.isAbsolute()) { return realPath.toUri(); } return null; }
private void renderOrigin(final String indentation) { final String origin = OriginLinkFormatter.formatAsBlock(this.item.getLocation()); if (!origin.isEmpty()) { this.stream.print(indentation); this.stream.print(" "); this.stream.println(origin); } }
private void renderLinkOrigin(final TracedLink link) { final String origin = OriginLinkFormatter .formatAsSpan(link.getOtherLinkEnd().getLocation()); if (!origin.isEmpty()) { this.stream.print(" "); this.stream.print(origin); } }
private static String format(final Location location, final boolean asSpan) { if ((location != null) && !location.getPath().isEmpty()) { return formatNonEmptyLocation(location, asSpan); } else { return ""; } }
private static String formatNonEmptyLocation(final Location location, final boolean asSpan) { final String path = location.getPath(); final URI uri = checkPathHasProtocol(path) ? convertPathWithProtocolToUri(path) : convertPathWithoutProtocolToUri(path); final StringBuilder builder = new StringBuilder(); builder.append(asSpan ? "<span" : "<p"); builder.append(" class=\"origin\">"); if (uri != null) { builder.append("<a href=\""); builder.append(uri); builder.append("\">"); builder.append(path); builder.append("</a>"); } else { builder.append(path); } builder.append(":"); final int line = location.getLine(); builder.append(line); builder.append(asSpan ? "</span>" : "</p>"); return builder.toString(); }
private static URI convertPathWithoutProtocolToUri(final String path) { final Path realPath = Paths.get(unWindowsify(path)); if (realPath.isAbsolute()) { return realPath.toUri(); } return null; }
private void renderOrigin(final String indentation) { final String origin = OriginLinkFormatter.formatAsBlock(this.item.getLocation()); if (!origin.isEmpty()) { this.stream.print(indentation); this.stream.print(" "); this.stream.println(origin); } }
private void renderLinkOrigin(final TracedLink link) { final String origin = OriginLinkFormatter .formatAsSpan(link.getOtherLinkEnd().getLocation()); if (!origin.isEmpty()) { this.stream.print(" "); this.stream.print(origin); } }
private static String format(final Location location, final boolean asSpan) { if ((location != null) && !location.getPath().isEmpty()) { return formatNonEmptyLocation(location, asSpan); } else { return ""; } }
/** * Render an origin to an HTML span * * @param location * origin location * @return a string representing an HTML span containing a link to the * origin */ public static String formatAsSpan(final Location location) { return format(location, true); }
/** * Render an origin to an HTML span * * @param location * origin location * @return a string representing an HTML span containing a link to the * origin */ public static String formatAsSpan(final Location location) { return format(location, true); }
/** * Render an origin to an HTML block * * @param location * origin location * @return a string representing an HTML block containing a link to the * origin */ public static String formatAsBlock(final Location location) { return format(location, false); }