KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > gui2 > BugSaver


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, 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.gui2;
21
22 import java.io.File JavaDoc;
23 import java.io.FileNotFoundException JavaDoc;
24 import java.io.FileOutputStream JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.OutputStream JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import javax.swing.JOptionPane JavaDoc;
30
31 import edu.umd.cs.findbugs.Project;
32 import edu.umd.cs.findbugs.SortedBugCollection;
33
34 /**
35  * Save bugs here, uses SortedBugCollection.writeXML()
36  * @author Dan
37  *
38  */

39 public class BugSaver {
40     
41     private static String JavaDoc lastPlaceSaved;
42     public static void saveBugs(OutputStream JavaDoc out, BugSet data, Project p)
43     {
44         SortedBugCollection col=new SortedBugCollection();
45         Iterator JavaDoc<BugLeafNode> iter = data.iterator();
46         
47         while (iter.hasNext())
48         {
49             col.add(iter.next().getBug());
50         }
51         
52         try {
53             col.writeXML(out,p);
54         } catch (IOException JavaDoc e) {
55             Debug.println(e);
56         }
57     }
58
59     public static void saveBugs(File JavaDoc out, BugSet data, Project p)
60     {
61         try {
62             out.createNewFile();
63             saveBugs(new FileOutputStream JavaDoc(out),data,p);
64             lastPlaceSaved=out.getAbsolutePath();
65         } catch (IOException JavaDoc e) {
66             JOptionPane.showMessageDialog(null, "An error has occured in saving your file");
67         }
68     }
69
70     public static String JavaDoc getLastPlaceSaved()
71     {
72         return lastPlaceSaved;
73     }
74     
75 }
76
Popular Tags