@Override public void write(int c, Writer out) throws IOException { encodeJavaScriptInXhtml((char)c, out); }
public static void encodeJavaScriptInXhtml(char ch, Appendable out) throws IOException { String escaped = getEscapedCharacter(ch); if(escaped!=null) out.append(escaped); else out.append(ch); }
public static void encodeJavaScriptInXhtml(char[] cbuf, int start, int len, Writer out) throws IOException { int end = start+len; int toPrint = 0; for (int c = start; c < end; c++) { String escaped = getEscapedCharacter(cbuf[c]); if(escaped!=null) { if(toPrint>0) { out.write(cbuf, c-toPrint, toPrint); toPrint=0; } out.write(escaped); } else { toPrint++; } } if(toPrint>0) out.write(cbuf, end-toPrint, toPrint); }
@Override public JavaScriptInXhtmlEncoder append(CharSequence csq, Appendable out) throws IOException { encodeJavaScriptInXhtml(csq==null ? "null" : csq, out); return this; }
public static void encodeJavaScriptInXhtml(CharSequence S, int start, int end, Appendable out) throws IOException { if(S!=null) { int toPrint = 0; for (int c = start; c < end; c++) { String escaped = getEscapedCharacter(S.charAt(c)); if(escaped!=null) { if(toPrint>0) { out.append(S, c-toPrint, c); toPrint=0; } out.append(escaped); } else { toPrint++; } } if(toPrint>0) out.append(S, end-toPrint, end); } } // </editor-fold>
@Override public JavaScriptInXhtmlEncoder append(char c, Appendable out) throws IOException { encodeJavaScriptInXhtml(c, out); return this; }
@Override public JavaScriptInXhtmlEncoder append(CharSequence csq, int start, int end, Appendable out) throws IOException { encodeJavaScriptInXhtml(csq==null ? "null" : csq, start, end, out); return this; }
@Override public void write(char cbuf[], Writer out) throws IOException { encodeJavaScriptInXhtml(cbuf, out); }
@Override public void write(char[] cbuf, int off, int len, Writer out) throws IOException { encodeJavaScriptInXhtml(cbuf, off, len, out); }
public static void encodeJavaScriptInXhtml(char[] cbuf, Writer out) throws IOException { encodeJavaScriptInXhtml(cbuf, 0, cbuf.length, out); }
public static void encodeJavaScriptInXhtml(CharSequence S, Appendable out) throws IOException { if(S!=null) { encodeJavaScriptInXhtml(S, 0, S.length(), out); } }
@Override public void write(String str, int off, int len, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeJavaScriptInXhtml(str, off, off+len, out); }
@Override public void write(String str, Writer out) throws IOException { if(str==null) throw new IllegalArgumentException("str is null"); encodeJavaScriptInXhtml(str, out); }
public static void encodeTextInJavaScriptInXhtml(String text, Appendable out) throws IOException { StringBuilder javascript = new StringBuilder(text.length()); encodeTextInJavaScript(text, javascript); encodeJavaScriptInXhtml(javascript, out); }
scriptOut.append(Long.toString(date.getTime())); scriptOut.append(", \""); encodeJavaScriptInXhtml(timeString, scriptOut); scriptOut.append("\");\n");
scriptOut.append(Long.toString(date.getTime())); scriptOut.append(", \""); encodeJavaScriptInXhtml(dateString, scriptOut); scriptOut.append("\");\n");
scriptOut.append(Long.toString(date.getTime())); scriptOut.append(", \""); encodeJavaScriptInXhtml(dateTimeString, scriptOut); scriptOut.append("\");\n");