1 23 package org.hammurapi.results.simple; 24 25 import java.io.Serializable ; 26 import java.util.Collection ; 27 import java.util.LinkedList ; 28 import java.util.List ; 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 , InspectorSummary, Serializable { 43 46 private static final long serialVersionUID = 823706029595309352L; 47 private List locations=new LinkedList (); 48 private String description; 49 private String name; 50 private Number severity; 51 private String 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 getDescription() { 74 return description; 75 } 76 77 public List 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 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 locations) { 97 this.locations.addAll(locations); 98 } 99 100 103 public String getName() { 104 return name; 105 } 106 107 110 public Number getSeverity() { 111 return severity; 112 } 113 114 public int compareTo(Object o) { 115 return name.compareTo(((InspectorSummary) o).getName()); 116 } 117 118 public String getConfigInfo() { 119 return configInfo; 120 } 121 122 public String getVersion() { 123 return null; 124 } 125 126 public int getBaseLineLocationsCount() { 127 return 0; 128 } 129 130 } | Popular Tags |