KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > results > simple > SimpleInspectorSummary


1 /*
2  * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Hammurapi Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.hammurapi.org
21  * e-Mail: support@hammurapi.biz
22  */

23 package org.hammurapi.results.simple;
24
25 import java.io.Serializable JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.LinkedList JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.hammurapi.HammurapiException;
31 import org.hammurapi.Inspector;
32 import org.hammurapi.InspectorDescriptor;
33 import org.hammurapi.results.InspectorSummary;
34
35 import com.pavelvlasov.config.ConfigurationException;
36 import com.pavelvlasov.jsel.CompilationUnit;
37 import com.pavelvlasov.jsel.LanguageElement;
38 import com.pavelvlasov.review.SimpleSourceMarker;
39 import com.pavelvlasov.review.SourceMarker;
40
41
42 public class SimpleInspectorSummary implements Comparable JavaDoc, InspectorSummary, Serializable JavaDoc {
43     /**
44      * Comment for <code>serialVersionUID</code>
45      */

46     private static final long serialVersionUID = 823706029595309352L;
47     private List JavaDoc locations=new LinkedList JavaDoc();
48     private String JavaDoc description;
49     private String JavaDoc name;
50     private Number JavaDoc severity;
51     private String JavaDoc configInfo;
52     
53     SimpleInspectorSummary(InspectorDescriptor descriptor) throws HammurapiException {
54         this.description=descriptor.getDescription();
55         this.name=descriptor.getName();
56         this.severity=descriptor.getSeverity();
57         try {
58             Inspector inspector = descriptor.getInspector();
59             configInfo = inspector==null ? null : inspector.getConfigInfo();
60         } catch (ConfigurationException e) {
61             throw new HammurapiException("Unable to obtain inspector config info");
62         }
63     }
64     
65     SimpleInspectorSummary(InspectorSummary anotherEntry) {
66         this.description=anotherEntry.getDescription();
67         this.name=anotherEntry.getName();
68         this.severity=anotherEntry.getSeverity();
69         this.configInfo=anotherEntry.getConfigInfo();
70         this.locations.addAll(anotherEntry.getLocations());
71     }
72     
73     public String JavaDoc getDescription() {
74         return description;
75     }
76     
77     public List JavaDoc getLocations() {
78         return locations;
79     }
80     
81     public int getLocationsCount() {
82         return locations.size();
83     }
84     
85     public void addLocation(SourceMarker location) {
86         SimpleSourceMarker ssm=new SimpleSourceMarker(location);
87         
88         // Bad design, fix in the future
89
if (location instanceof LanguageElement) {
90             CompilationUnit cu=((LanguageElement) location).getCompilationUnit();
91             ssm.setSourceURL(cu.getPackage().getName().replace('.', '/')+'/'+cu.getName());
92         }
93         locations.add(ssm);
94     }
95     
96     public void addLocations(Collection JavaDoc locations) {
97         this.locations.addAll(locations);
98     }
99     
100     /**
101      * @return Returns the name.
102      */

103     public String JavaDoc getName() {
104         return name;
105     }
106
107     /**
108      * @return Returns the severity.
109      */

110     public Number JavaDoc getSeverity() {
111         return severity;
112     }
113
114     public int compareTo(Object JavaDoc o) {
115         return name.compareTo(((InspectorSummary) o).getName());
116     }
117
118     public String JavaDoc getConfigInfo() {
119         return configInfo;
120     }
121
122     public String JavaDoc getVersion() {
123         return null;
124     }
125
126     public int getBaseLineLocationsCount() {
127         return 0;
128     }
129
130 }
Popular Tags