In my quest to make every else feel better about their development
environments, here is my Beautiful Discovered Code Fragment of the Day.
Actual code, actual live project, developers unnamed to protect the
boneheaded.
From export_generator.jsp (JavaDocs are for the weak), I present the
following:
<%!
public static class Escaper extends FilterWriter {
public Escaper(Writer writer) {
super(writer);
}
public void write(char[] cbuf, int off, int len) throws
IOException {
super.write(cbuf, off, len);
}
public void write(String str, int off, int len) throws IOException {
for (int i = off, maxI = off + len; i < maxI; i++) {
this.write(str.charAt(i));
}
}
public void write(int c) throws IOException {
if (c > 0x7F) {
super.write(' ');
} else if (c == '&') {
super.write('&');
super.write('a');
super.write('m');
super.write('p');
super.write(';');
} else {
super.write(c);
}
}
}
public static final char DOUBLE_QUOTE = '"'; // "
%>
Thank you. (I left on the dandy DOUBLE_QUOTE definition, complete with
Java comments (go ahead, I dare ANYBODY to tell me that THAT is a useful
comment) for your extended plasure.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]