You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2003/12/03 00:16:11 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw ChainsawCyclicBufferTableModel.java
sdeboy 2003/12/02 15:16:11
Modified: src/java/org/apache/log4j/chainsaw
ChainsawCyclicBufferTableModel.java
Log:
cyclicbuffermodel now stores IDs that it's seen in order to not load duplicates. Was relying on .contains but that relies on an equals method to recognize equality, which LoggingEvent doesn't provide.
Revision Changes Path
1.12 +18 -5 jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
Index: ChainsawCyclicBufferTableModel.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ChainsawCyclicBufferTableModel.java 2 Nov 2003 19:53:47 -0000 1.11
+++ ChainsawCyclicBufferTableModel.java 2 Dec 2003 23:16:11 -0000 1.12
@@ -95,6 +95,7 @@
private static final String PANEL_CAPACITY = "CHAINSAW_CAPACITY";
List unfilteredList = new CyclicBufferList(capacity);
List filteredList = new CyclicBufferList(capacity);
+ List idList = new CyclicBufferList(capacity);
private boolean currentSortAscending;
private int currentSortColumn;
private EventListenerList eventListenerList = new EventListenerList();
@@ -241,6 +242,7 @@
synchronized (unfilteredList) {
unfilteredList.clear();
filteredList.clear();
+ idList.clear();
uniqueRow = 0;
}
@@ -261,7 +263,6 @@
}
int currentRow = -1;
- String thisVal = null;
synchronized (filteredList) {
ListIterator iter = filteredList.listIterator();
@@ -419,10 +420,10 @@
}
//prevent duplicate rows
- if (unfilteredList.contains(e)) {
+ if (idList.contains(id)) {
return false;
}
-
+ idList.add(id);
unfilteredList.add(e);
rowAdded = true;
@@ -449,7 +450,7 @@
* If so, we should add them as columns and notify listeners.
*/
for (Iterator iter = e.getMDCKeySet().iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
+ Object key = iter.next();
if (!columnNames.contains(key)) {
columnNames.add(key);
@@ -677,20 +678,32 @@
"Changing Model, isCyclic is now " + isCyclic());
List newUnfilteredList = null;
+ List newIDList = null;
if (isCyclic()) {
newUnfilteredList = new CyclicBufferList(capacity);
+ newIDList = new CyclicBufferList(capacity);
} else {
newUnfilteredList = new ArrayList(capacity);
+ newIDList = new ArrayList(capacity);
}
+ int increment = 0;
for (Iterator iter = unfilteredList.iterator();
iter.hasNext();) {
- newUnfilteredList.add(iter.next());
+ LoggingEvent e = (LoggingEvent)iter.next();
+ newUnfilteredList.add(e);
+ Object o = e.getProperty(e.getProperty(ChainsawConstants.LOG4J_ID_KEY));
+ if (o != null) {
+ newIDList.add(o);
+ } else {
+ newIDList.add(new Integer(increment++));
+ }
monitor.setProgress(index++);
}
unfilteredList = newUnfilteredList;
+ idList = newIDList;
}
monitor.setNote("Refiltering...");
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org