Implemented res.debug() method that appends debug messages to the response body.

This commit is contained in:
hns 2002-10-24 12:37:07 +00:00
parent afbdf485ba
commit 1a785e4031
2 changed files with 13 additions and 3 deletions

View file

@ -62,6 +62,10 @@ public class ResponseBean implements Serializable {
res.writeBinary (what); res.writeBinary (what);
} }
public void debug (String message) {
res.debug (message);
}
public String toString() { public String toString() {
return "[Response]"; return "[Response]";
} }

View file

@ -71,6 +71,9 @@ public final class ResponseTrans implements Externalizable {
private transient Object[] skinpath = null; private transient Object[] skinpath = null;
// hashmap for skin caching // hashmap for skin caching
private transient HashMap skincache; private transient HashMap skincache;
// buffer for debug messages - will be automatically appended to response
private transient StringBuffer debugBuffer;
static final long serialVersionUID = -8627370766119740844L; static final long serialVersionUID = -8627370766119740844L;
@ -208,9 +211,10 @@ public final class ResponseTrans implements Externalizable {
* that buffer exists and its length is larger than offset. str may be null, in which * that buffer exists and its length is larger than offset. str may be null, in which
* case nothing happens. * case nothing happens.
*/ */
public void insert (int offset, String str) { public void debug (String str) {
if (str != null) if (debugBuffer == null)
buffer.insert (offset, str); debugBuffer = new StringBuffer ();
debugBuffer.append ("<p><span style=\"background: yellow; color: black\">"+str+"</span></p>");
} }
/** /**
@ -308,6 +312,8 @@ public final class ResponseTrans implements Externalizable {
boolean error = false; boolean error = false;
if (response == null) { if (response == null) {
if (buffer != null) { if (buffer != null) {
if (debugBuffer != null)
buffer.append (debugBuffer);
try { try {
response = buffer.toString ().getBytes (charset); response = buffer.toString ().getBytes (charset);
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {