1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
package org.biojava.bio.dp;
import java.util.ArrayList;
import java.util.List;
import org.biojava.utils.ChangeEvent;
import org.biojava.utils.ChangeListener;
import org.biojava.utils.ChangeVetoException;
/**
* Utility class for event handler tests.
*
* @author Matthew Pocock
*/
class EventCounter
implements ChangeListener {
private final String name;
private final List preList;
private final List postList;
public EventCounter(String name) {
this.name = name;
this.preList = new ArrayList();
this.postList = new ArrayList();
}
public void preChange(ChangeEvent cev) throws ChangeVetoException {
preList.add(cev);
}
public void postChange(ChangeEvent cev) {
postList.add(cev);
}
public int getPreCounts() {
return preList.size();
}
public int getPostCounts() {
return postList.size();
}
public void zeroCounts() {
preList.clear();
postList.clear();
}
public String toString() {
return "EventCounter(" + name + ")\n\t" + preList + "\n\t" + postList;
}
}
|