KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > DelegatingBugReporter


1 /*
2  * FindBugs - Find bugs in Java programs
3  * Copyright (C) 2003,2004 University of Maryland
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 edu.umd.cs.findbugs;
21
22 import org.apache.bcel.classfile.JavaClass;
23
24 import edu.umd.cs.findbugs.ba.JavaClassAndMethod;
25 import edu.umd.cs.findbugs.ba.MethodUnprofitableException;
26 import edu.umd.cs.findbugs.classfile.ClassDescriptor;
27 import edu.umd.cs.findbugs.classfile.MethodDescriptor;
28
29 /**
30  * A BugReporter which delegates all method calls to another BugReporter.
31  * This is useful for customizing the behavior of another bug reporter.
32  *
33  * @author David Hovemeyer
34  */

35 public class DelegatingBugReporter implements BugReporter {
36     private BugReporter delegate;
37
38     /**
39      * Constructor.
40      *
41      * @param delegate another BugReporter to delegate all BugReporter methods to
42      */

43     public DelegatingBugReporter(BugReporter delegate) {
44         this.delegate = delegate;
45     }
46
47     public BugReporter getRealBugReporter() {
48         return delegate.getRealBugReporter();
49     }
50
51     /**
52      * Set BugReporter to delegate reported BugInstances to.
53      *
54      * @param delegate BugReporter to delegate all BugReporter methods to
55      */

56     public void setDelegate(BugReporter delegate) {
57         this.delegate = delegate;
58     }
59     
60     public BugReporter getDelegate() {
61         return this.delegate;
62     }
63
64 // public void setEngine(FindBugs engine) {
65
// delegate.setEngine(engine);
66
// }
67

68     public void setErrorVerbosity(int level) {
69         delegate.setErrorVerbosity(level);
70     }
71
72     public void setPriorityThreshold(int threshold) {
73         delegate.setPriorityThreshold(threshold);
74     }
75
76     public void observeClass(ClassDescriptor classDescriptor) {
77         delegate.observeClass(classDescriptor);
78     }
79
80     public void reportBug(BugInstance bugInstance) {
81         delegate.reportBug(bugInstance);
82     }
83
84     public void logError(String JavaDoc message) {
85         delegate.logError(message);
86     }
87
88     public void reportMissingClass(ClassNotFoundException JavaDoc ex) {
89         delegate.reportMissingClass(ex);
90     }
91     
92     /* (non-Javadoc)
93      * @see edu.umd.cs.findbugs.classfile.IErrorLogger#reportMissingClass(edu.umd.cs.findbugs.classfile.ClassDescriptor)
94      */

95     public void reportMissingClass(ClassDescriptor classDescriptor) {
96         delegate.reportMissingClass(classDescriptor);
97     }
98
99     public void finish() {
100         delegate.finish();
101     }
102
103     public void reportQueuedErrors() {
104         delegate.reportQueuedErrors();
105     }
106
107     public void addObserver(BugReporterObserver observer) {
108         delegate.addObserver(observer);
109     }
110
111     public ProjectStats getProjectStats() {
112         return delegate.getProjectStats();
113     }
114
115     public void logError(String JavaDoc message, Throwable JavaDoc e) {
116         if (e instanceof MethodUnprofitableException) return;
117         delegate.logError(message, e);
118     }
119     /**
120      * Report that we skipped some analysis of a method
121      * @param method
122      */

123     public void reportSkippedAnalysis(MethodDescriptor method) {
124         delegate.reportSkippedAnalysis(method);
125     }
126 }
127
128 // vim:ts=4
129
Popular Tags