@Test public void testEscaping() throws IOException { HtmlEscaper html = new HtmlEscaper(); assertEquals("Čolek", html.escape("Čolek")); assertEquals("&lt;strong&gt;Čolek&lt;/strong&gt;", html.escape("<strong>Čolek</strong>")); assertEquals("&lt;a&gt;&amp;link&quot;&#39;&lt;/a&gt;", html.escape("<a>&link\"'</a>")); }
String escape(CharSequence value) { if (Objects.requireNonNull(value).length() == 0) { return value.toString(); } for (int i = 0; i < value.length(); i++) { String replacement = replacementFor(value.charAt(i)); if (replacement != null) { return doEscape(value, i, new StringBuilder(value.subSequence(0, i)).append(replacement)); } } return value.toString(); }
HtmlEscaper implements ResultMapper { String escape(CharSequence value) { if (Objects.requireNonNull(value).length() == 0) { return value.toString(); } for (int i = 0; i < value.length(); i++) { String replacement = replacementFor(value.charAt(i)); if (replacement != null) { return doEscape(value, i, new StringBuilder(value.subSequence(0, i)).append(replacement)); } } return value.toString(); } }
HtmlEscaper implements ResultMapper { String escape(CharSequence value) { if (Objects.requireNonNull(value).length() == 0) { return value.toString(); } for (int i = 0; i < value.length(); i++) { String replacement = replacementFor(value.charAt(i)); if (replacement != null) { return doEscape(value, i, new StringBuilder(value.subSequence(0, i)).append(replacement)); } } return value.toString(); }  }
HtmlEscaper implements ResultMapper { String escape(CharSequence value) { if (Objects.requireNonNull(value).length() == 0) { return value.toString(); } for (int i = 0; i < value.length(); i++) { String replacement = replacementFor(value.charAt(i)); if (replacement != null) { return doEscape(value, i, new StringBuilder(value.subSequence(0, i)).append(replacement)); } } return value.toString(); }  @Override boolean appliesTo(Origin origin, Object result); @Override String map(Object result, Expression expression); }
HtmlEscaper implements ResultMapper { String escape(CharSequence value) { if (Objects.requireNonNull(value).length() == 0) { return value.toString(); } for (int i = 0; i < value.length(); i++) { String replacement = replacementFor(value.charAt(i)); if (replacement != null) { return doEscape(value, i, new StringBuilder(value.subSequence(0, i)).append(replacement)); } } return value.toString(); }  @Override boolean appliesTo(Origin origin, Object result); @Override String map(Object result, Expression expression);  }