1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.internal.testmodules;
21
22 import com.puppycrawl.tools.checkstyle.api.AuditEvent;
23 import com.puppycrawl.tools.checkstyle.api.AuditListener;
24
25 public final class DebugAuditAdapter implements AuditListener {
26
27
28 private boolean called;
29
30
31 private boolean passedEvent;
32
33
34 private int numFilesStarted;
35
36
37 private int numFilesFinished;
38
39 public int getNumFilesStarted() {
40 return numFilesStarted;
41 }
42
43 public int getNumFilesFinished() {
44 return numFilesFinished;
45 }
46
47 public boolean wasCalled() {
48 return called;
49 }
50
51 public boolean wasEventPassed() {
52 return passedEvent;
53 }
54
55 public void resetListener() {
56 called = false;
57 passedEvent = false;
58 }
59
60 @Override
61 public void addError(AuditEvent event) {
62 called = true;
63 if (event != null) {
64 passedEvent = true;
65 }
66 }
67
68 @Override
69 public void addException(AuditEvent event, Throwable throwable) {
70 called = true;
71 if (event != null) {
72 passedEvent = true;
73 }
74 }
75
76 @Override
77 public void auditStarted(AuditEvent event) {
78 called = true;
79 if (event != null) {
80 passedEvent = true;
81 }
82 }
83
84 @Override
85 public void fileStarted(AuditEvent event) {
86 called = true;
87 numFilesStarted++;
88 if (event != null) {
89 passedEvent = true;
90 }
91 }
92
93 @Override
94 public void auditFinished(AuditEvent event) {
95 called = true;
96 if (event != null) {
97 passedEvent = true;
98 }
99 }
100
101 @Override
102 public void fileFinished(AuditEvent event) {
103 called = true;
104 numFilesFinished++;
105 if (event != null) {
106 passedEvent = true;
107 }
108 }
109
110 }