View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2017 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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      /** Keeps track whether this {@code AuditListener} was called. */
27      private boolean called;
28  
29      /** Keeps track of the number of files started. */
30      private int numFilesStarted;
31  
32      /** Keeps track of the number of files finished. */
33      private int numFilesFinished;
34  
35      public int getNumFilesStarted() {
36          return numFilesStarted;
37      }
38  
39      public int getNumFilesFinished() {
40          return numFilesFinished;
41      }
42  
43      public boolean wasCalled() {
44          return called;
45      }
46  
47      public void resetListener() {
48          called = false;
49      }
50  
51      @Override
52      public void addError(AuditEvent event) {
53          called = true;
54      }
55  
56      @Override
57      public void addException(AuditEvent event, Throwable throwable) {
58          called = true;
59      }
60  
61      @Override
62      public void auditStarted(AuditEvent event) {
63          called = true;
64      }
65  
66      @Override
67      public void fileStarted(AuditEvent event) {
68          called = true;
69          numFilesStarted++;
70      }
71  
72      @Override
73      public void auditFinished(AuditEvent event) {
74          called = true;
75      }
76  
77      @Override
78      public void fileFinished(AuditEvent event) {
79          called = true;
80          numFilesFinished++;
81      }
82  }