01: /*******************************************************************************
02: * Product of NIST/ITL Advanced Networking Technologies Division (ANTD). *
03: *******************************************************************************/package tools.tracesviewer;
04:
05: import java.util.*;
06:
07: /**
08: *This class stores a sorted list messages for logging.
09: *
10: *@version 1.2
11: *
12: *@author M. Ranganathan
13: *@author Marc Bednarek
14: *
15: *
16: */
17:
18: public class MessageLogList extends TreeSet {
19: protected String description;
20: protected static long startTime;
21:
22: static {
23: startTime = -1;
24: }
25:
26: /** Constructor.
27: *@param comp comparator for sorting the logs
28: */
29: public MessageLogList(Comparator comp) {
30: super (comp);
31: }
32:
33: /** set a descriptive string for this log (for id purposes).
34: *@param description is the decriptive string to add.
35: */
36: public void addDescription(String description) {
37: this .description = description;
38: }
39:
40: /** Constructor given callId and a comparator.
41: *@param callId is the call id for which to store the log.
42: *@param comp is the comparator to sort the log records.
43: */
44:
45: public MessageLogList(String callId, Comparator comp) {
46: super (comp);
47: }
48:
49: /** Add a comparable object to the messgageLog
50: *@param obj is the comparable object to add to the message log.
51: */
52: public synchronized boolean add(Object obj) {
53: TracesMessage log = (TracesMessage) obj;
54: long ts = Long.parseLong(log.getTime());
55: if (ts < startTime || startTime < 0)
56: startTime = ts;
57: return super.add(obj);
58: }
59:
60: }
|