File: EventCounter.java

package info (click to toggle)
biojava-live 1%3A1.7.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 55,160 kB
  • sloc: java: 180,820; xml: 6,908; sql: 510; makefile: 50
file content (51 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download | duplicates (7)
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;
  }
}