KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * FindBugs - Find bugs in Java programs
3  * Copyright (C) 2004-2005 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 package edu.umd.cs.findbugs;
20
21 import java.io.IOException JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 import org.dom4j.Document;
28 import org.dom4j.DocumentException;
29
30 import edu.umd.cs.findbugs.model.ClassFeatureSet;
31 import edu.umd.cs.findbugs.xml.XMLOutput;
32
33 public interface BugCollection
34 {
35     static final String JavaDoc ROOT_ELEMENT_NAME = "BugCollection";
36     static final String JavaDoc SRCMAP_ELEMENT_NAME = "SrcMap";
37     static final String JavaDoc PROJECT_ELEMENT_NAME = "Project";
38     static final String JavaDoc ERRORS_ELEMENT_NAME = "Errors";
39     static final String JavaDoc ANALYSIS_ERROR_ELEMENT_NAME = "AnalysisError"; // 0.8.6 and earlier
40
static final String JavaDoc ERROR_ELEMENT_NAME = "Error"; // 0.8.7 and later
41
static final String JavaDoc ERROR_MESSAGE_ELEMENT_NAME = "ErrorMessage"; // 0.8.7 and later
42
static final String JavaDoc ERROR_EXCEPTION_ELEMENT_NAME = "Exception"; // 0.8.7 and later
43
static final String JavaDoc ERROR_STACK_TRACE_ELEMENT_NAME = "StackTrace"; // 0.8.7 and later
44
static final String JavaDoc MISSING_CLASS_ELEMENT_NAME = "MissingClass";
45     static final String JavaDoc SUMMARY_HTML_ELEMENT_NAME = "SummaryHTML";
46     static final String JavaDoc APP_CLASS_ELEMENT_NAME = "AppClass";
47     static final String JavaDoc CLASS_HASHES_ELEMENT_NAME = "ClassHashes"; // 0.9.2 and later
48
static final String JavaDoc HISTORY_ELEMENT_NAME = "History"; // 0.9.2 and later
49

50     /**
51      * Set the current release name.
52      *
53      * @param releaseName the current release name
54      */

55     public void setReleaseName(String JavaDoc releaseName);
56     /**
57      * Get the current release name.
58      *
59      * @return current release name
60      */

61     public String JavaDoc getReleaseName();
62     
63     /**
64      * Get the project stats.
65      */

66     public ProjectStats getProjectStats();
67
68     /**
69      * Get the timestamp for the analyzed code
70      *
71      * @param timestamp the timestamp.
72      */

73     public void setTimestamp(long timestamp);
74     
75     /**
76      * Get the timestamp for the analyzed code
77      * return the timestamp.
78      */

79     public long getTimestamp();
80     
81     /**
82      * Get the timestamp for when the analysis was performed.
83      *
84      * @param timestamp the analysis timestamp.
85      */

86     public void setAnalysisTimestamp(long timestamp);
87     
88     /**
89      * Get the timestamp for when the analysis was performed.
90      */

91     public long getAnalysisTimestamp();
92     
93     
94     /**
95      * Gets the AppVersion corresponding to the given sequence number.
96      */

97     
98     public AppVersion getAppVersionFromSequenceNumber(long target);
99     
100     /**
101      * Set the sequence number of the BugCollection.
102      *
103      * @param sequence the sequence number
104      * @see BugCollection#getSequenceNumber()
105      */

106     public void setSequenceNumber(long sequence);
107
108     /**
109      * Get the sequence number of the BugCollection.
110      * This value represents the number of times the user has
111      * analyzed a different version of the application and
112      * updated the historical bug collection using the
113      * UpdateBugCollection class.
114      *
115      * @return the sequence number
116      */

117     public long getSequenceNumber();
118
119     /**
120      * Clear all AppVersions representing previously-analyzed versions
121      * of the application.
122      */

123     public abstract void clearAppVersions();
124     /**
125      * Add an AppVersion representing a version of the analyzed application.
126      *
127      * @param appVersion the AppVersion
128      */

129     public void addAppVersion(AppVersion appVersion);
130
131     /**
132      * Get the current AppVersion.
133      */

134     public AppVersion getCurrentAppVersion();
135
136     /**
137      * Get an Iterator over AppVersions defined in the collection.
138      */

139     public Iterator JavaDoc<AppVersion> appVersionIterator();
140     
141     /**
142      * Add a BugInstance to this BugCollection.
143      * This just calls add(bugInstance, true).
144      *
145      * @param bugInstance the BugInstance
146      * @return true if the BugInstance was added, or false if a matching
147      * BugInstance was already in the BugCollection
148      */

149     public boolean add(BugInstance bugInstance);
150     
151     /**
152      * Add a BugInstance to this BugCollection.
153      *
154      * @param bugInstance the BugInstance
155      * @param updateActiveTime true if the warning's active time should be updated
156      * to include the collection's current time
157      * @return true if the BugInstance was added, or false if a matching
158      * BugInstance was already in the BugCollection
159      */

160     public boolean add(BugInstance bugInstance, boolean updateActiveTime);
161
162     /**
163      * Look up a BugInstance by its unique id.
164      *
165      * @param uniqueId the BugInstance's unique id.
166      * @return the BugInstance with the given unique id,
167      * or null if there is no such BugInstance
168      *
169      * This is deprecated; uniqueIDs are not persistent.
170      */

171     @Deprecated JavaDoc
172     public BugInstance lookupFromUniqueId(String JavaDoc uniqueId);
173     
174     /**
175      * Add an analysis error.
176      *
177      * @param message the error message
178      */

179     public void addError(String JavaDoc message);
180
181     /**
182      * Add an analysis error.
183      *
184      * @param error the AnalysisError object to add
185      */

186     public void addError(AnalysisError error);
187
188     /**
189      * Add a missing class message.
190      *
191      * @param message the missing class message
192      */

193     public void addMissingClass(String JavaDoc message);
194
195     public void setClassFeatureSet(ClassFeatureSet classFeatureSet);
196
197     public void writePrologue(XMLOutput xmlOutput, Project project) throws IOException JavaDoc;
198     
199     public void writeEpilogue(XMLOutput xmlOutput) throws IOException JavaDoc;
200     
201     public void clearClassFeatures();
202
203     /**
204      * Read XML data from given file into this object,
205      * populating given Project as a side effect.
206      *
207      * @param fileName name of the file to read
208      * @param project the Project
209      */

210     public void readXML(String JavaDoc fileName, Project project)
211         throws IOException JavaDoc, DocumentException;
212     
213     /**
214      * Read XML data from given input stream into this
215      * object, populating the Project as a side effect.
216      * An attempt will be made to close the input stream
217      * (even if an exception is thrown).
218      *
219      * @param in the InputStream
220      * @param project the Project
221      */

222     public void readXML(InputStream JavaDoc in, Project project)
223             throws IOException JavaDoc, DocumentException;
224
225     /**
226      * Write this BugCollection to a file as XML.
227      *
228      * @param fileName the file to write to
229      * @param project the Project from which the BugCollection was generated
230      */

231     public void writeXML(String JavaDoc fileName, Project project)
232         throws IOException JavaDoc;
233     
234     /**
235      * Write the BugCollection to given output stream as XML.
236      * The output stream will be closed, even if an exception is thrown.
237      *
238      * @param out the OutputStream to write to
239      * @param project the Project from which the BugCollection was generated
240      */

241     public void writeXML(OutputStream JavaDoc out, Project project) throws IOException JavaDoc;
242
243     /**
244      * Write the BugCollection to an XMLOutput object.
245      * The finish() method of the XMLOutput object is guaranteed
246      * to be called.
247      *
248      * <p>
249      * To write the SummaryHTML element, set property
250      * findbugs.report.SummaryHTML to "true".
251      * </p>
252      *
253      * @param xmlOutput the XMLOutput object
254      * @param project the Project from which the BugCollection was generated
255      */

256     public void writeXML(XMLOutput xmlOutput, Project project) throws IOException JavaDoc;
257     
258     /**
259      * Return an Iterator over all the BugInstance objects in
260      * the BugCollection.
261      */

262     public Iterator JavaDoc<BugInstance> iterator();
263     
264     /**
265      * Return the Collection storing the BugInstance objects.
266      */

267     public Collection JavaDoc<BugInstance> getCollection();
268     
269     /**
270      * Convert the BugCollection into a dom4j Document object.
271      *
272      * @param project the Project from which the BugCollection was generated
273      * @return the Document representing the BugCollection as a dom4j tree
274      */

275     public Document toDocument(Project project);
276     
277     /**
278      * Create a new empty BugCollection with the same metadata as this one.
279      *
280      * @return a new empty BugCollection with the same metadata as this one
281      */

282     public BugCollection createEmptyCollectionWithMetadata();
283     
284     /**
285      * Set whether textual messages should be added to any generated XML
286      */

287     public void setWithMessages(boolean withMessages);
288
289     /**
290      * Return whether textual messages will be added to any generated XML
291      */

292     public boolean getWithMessages();
293         
294     public BugInstance findBug(String JavaDoc instanceHash, String JavaDoc bugType, int lineNumber);
295
296 }
297
Popular Tags