MessageLogpublic class MessageLog extends Object This class stores a message along with some other informations
Used to log messages. |
Fields Summary |
---|
private String | messageMessage to be logged. | private String | sourceOriginator of this mesage. | private String | destinationTarget recipient for the message. | private long | timeStampTime of the logging event. | private boolean | isSenderFlag indicating if we are the message sender. | private String | firstLineFirst line from the message. | private String | statusMessageStatus line from the transaction. | private String | tidTransaction identifier. | private String | callIdCaller identification. |
Constructors Summary |
---|
public MessageLog(String message, String source, String destination, String timeStamp, boolean isSender, String firstLine, String statusMessage, String tid, String callId)Constructor with initial parameters.
if (message == null
|| message.equals(""))
throw new IllegalArgumentException("null msg");
this.message = message;
this.source = source;
this.destination = destination;
try {
long ts = Long.parseLong(timeStamp);
if (ts < 0)
throw new IllegalArgumentException("Bad time stamp ");
this.timeStamp = ts;
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Bad number format "
+ timeStamp);
}
this.isSender = isSender;
this.firstLine = firstLine;
this.statusMessage = statusMessage;
this.tid = tid;
this.callId = callId;
| public MessageLog(String message, String source, String destination, long timeStamp, boolean isSender, String firstLine, String statusMessage, String tid, String callId)Constructor with initial parameters.
if (message == null
|| message.equals(""))
throw new IllegalArgumentException("null msg");
this.message = message;
this.source = source;
this.destination = destination;
if (timeStamp < 0)
throw new IllegalArgumentException("negative ts");
this.timeStamp = timeStamp;
this.isSender = isSender;
this.firstLine = firstLine;
this.statusMessage = statusMessage;
this.tid = tid;
this.callId = callId;
|
Methods Summary |
---|
public boolean | equals(java.lang.Object other)Compares object for equivalence.
if (! (other instanceof MessageLog)) {
return false;
} else {
MessageLog otherLog = (MessageLog) other;
return otherLog.message.equals(message) &&
otherLog.timeStamp == timeStamp;
}
| public java.lang.String | flush(long startTime)Constructs an XML formatted log message.
String log;
if (statusMessage != null) {
log = " <message\nfrom = \"" + source +
"\" \nto = \"" + destination +
"\" \ntime = \"" + (timeStamp - startTime) +
"\" \nisSender = \"" + isSender +
"\" \nstatusMessage = \"" + statusMessage +
"\" \ntransactionId = \"" + tid +
"\" \ncallId = \"" + callId +
"\" \nfirstLine = \"" + firstLine.trim() +
"\" > \n";
log += "<![CDATA[";
log += message;
log += "]]>\n";
log += "</message>\n";
} else {
log = " <message\nfrom = \"" + source +
"\" \nto = \"" + destination +
"\" \ntime = \"" + (timeStamp - startTime) +
"\" \nisSender = \"" + isSender +
"\" \ntransactionId = \"" + tid +
"\" \ncallId = \"" + callId +
"\" \nfirstLine = \"" + firstLine.trim() +
"\" > \n";
log += "<![CDATA[";
log += message;
log += "]]>\n";
log += "</message>\n";
}
return log;
| public java.lang.String | flush()Constructs an XML formatted log message.
String log;
if (statusMessage != null) {
log = " < message\nfrom = \"" + source +
"\" \nto = \"" + destination +
"\" \ntime = \"" + timeStamp +
"\" \nisSender = \"" + isSender +
"\" \nstatusMessage = \"" + statusMessage +
"\" \ntransactionId = \"" + tid +
"\" \nfirstLine = \"" + firstLine.trim() +
"\" \ncallId = \"" + callId +
"\" \n > \n";
log += "<![CDATA[";
log += message;
log += "]]>\n";
log += "</message>\n";
} else {
log = " < message\nfrom = \"" + source +
"\" \nto = \"" + destination +
"\" \ntime = \"" + timeStamp +
"\" \nisSender = \"" + isSender +
"\" \ntransactionId = \"" + tid +
"\" \ncallId = \"" + callId +
"\" \nfirstLine = \"" + firstLine.trim() +
"\" \n > \n";
log += "<![CDATA[";
log += message;
log += "]]>\n";
log += "</message>\n";
}
return log;
| protected long | getTimeStamp()Gets the logged timestamp.
return this.timeStamp;
|
|