private static String htmlEscapeInternal(String text) { return escapeHtmlInternal(coerceToInterchangeValid(text)); }
private SafeHtmlBuilder setAttribute(@CompileTimeConstant final String name, String value) { if (value == null) { throw new NullPointerException("setAttribute requires a non-null value."); } attributes.put(name, coerceToInterchangeValid(value)); return this; } }
@CheckReturnValue public SafeHtml build() { StringBuilder sb = new StringBuilder("<" + elementName); for (Map.Entry<String, String> entry : attributes.entrySet()) { sb.append(" " + entry.getKey() + "=\"" + escapeHtmlInternal(entry.getValue()) + "\""); } boolean isVoid = VOID_ELEMENTS.contains(elementName); if (isVoid && useSlashOnVoid) { sb.append("/"); } sb.append(">"); if (!isVoid) { for (SafeHtml content : contents) { sb.append(content.getSafeHtmlString()); } sb.append("</" + elementName + ">"); } return SafeHtmls.create(sb.toString()); }