@Override public JavaScriptInXhtmlAttributeEncoder append(char c, Appendable out) throws IOException { encodeJavaScriptInXhtmlAttribute(c, out); return this; }
@Override public void write(int c, Writer out) throws IOException { encodeJavaScriptInXhtmlAttribute((char)c, out); }
@Override public JavaScriptInXhtmlAttributeEncoder append(CharSequence csq, int start, int end, Appendable out) throws IOException { encodeJavaScriptInXhtmlAttribute(csq==null ? "null" : csq, start, end, out); return this; } }
@Override public JavaScriptInXhtmlAttributeEncoder append(CharSequence csq, Appendable out) throws IOException { encodeJavaScriptInXhtmlAttribute(csq==null ? "null" : csq, out); return this; }
@Override public void write(char[] cbuf, int off, int len, Writer out) throws IOException { encodeJavaScriptInXhtmlAttribute(cbuf, off, len, out); }
@Override public void write(char cbuf[], Writer out) throws IOException { encodeJavaScriptInXhtmlAttribute(cbuf, out); }
public static void encodeJavaScriptInXhtmlAttribute(char[] cbuf, Writer out) throws IOException { encodeJavaScriptInXhtmlAttribute(cbuf, 0, cbuf.length, out); }
public static void encodeJavaScriptInXhtmlAttribute(CharSequence S, Appendable out) throws IOException { if(S!=null) { encodeJavaScriptInXhtmlAttribute(S, 0, S.length(), out); } }
@Override public void write(String str, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeJavaScriptInXhtmlAttribute(str, out); }
@Override public void write(String str, int off, int len, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeJavaScriptInXhtmlAttribute(str, off, off+len, out); }
public static void encodeTextInJavaScriptInXhtmlAttribute(String text, Appendable out) throws IOException { StringBuilder javascript = new StringBuilder(text.length()); encodeTextInJavaScript(text, javascript); encodeJavaScriptInXhtmlAttribute(javascript, out); }
/** * Prints a JavaScript script that will preload the image at the provided URL. * * @param url This should be the URL-encoded URL, but with only a standalone ampersand (&) as parameter separator * (not &amp;) */ public static void writeHtmlImagePreloadJavaScript(String url, Appendable out) throws IOException { out.append("<script type='text/javascript'>\n" + " var img=new Image();\n" + " img.src=\""); // Escape for javascript StringBuilder javascript = new StringBuilder(url.length()); encodeTextInJavaScript(url, javascript); // Encode for XML attribute encodeJavaScriptInXhtmlAttribute(javascript, out); out.append("\";\n" + "</script>"); }
) { out.write(" onclick=\""); encodeJavaScriptInXhtmlAttribute("semanticcms_openfile_servlet.openFile(\"", out); NewEncodingUtils.encodeTextInJavaScriptInXhtmlAttribute(pageRef.getBook().getName(), out); encodeJavaScriptInXhtmlAttribute("\", \"", out); NewEncodingUtils.encodeTextInJavaScriptInXhtmlAttribute(pageRef.getPath(), out); encodeJavaScriptInXhtmlAttribute("\"); return false;", out); out.write('"');