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);
}
public void debug (String message) {
res.debug (message);
}
public String toString() {
return "[Response]";
}

View file

@ -72,6 +72,9 @@ public final class ResponseTrans implements Externalizable {
// hashmap for skin caching
private transient HashMap skincache;
// buffer for debug messages - will be automatically appended to response
private transient StringBuffer debugBuffer;
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
* case nothing happens.
*/
public void insert (int offset, String str) {
if (str != null)
buffer.insert (offset, str);
public void debug (String str) {
if (debugBuffer == null)
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;
if (response == null) {
if (buffer != null) {
if (debugBuffer != null)
buffer.append (debugBuffer);
try {
response = buffer.toString ().getBytes (charset);
} catch (UnsupportedEncodingException uee) {