1 23 24 package org.hammurapi.render.dom; 25 26 import java.util.ArrayList ; 27 import java.util.Collections ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 31 import org.hammurapi.results.InspectorSummary; 32 import org.w3c.dom.Document ; 33 import org.w3c.dom.Element ; 34 35 import com.pavelvlasov.render.RenderRequest; 36 import com.pavelvlasov.render.RenderingException; 37 import com.pavelvlasov.render.dom.AbstractRenderer; 38 import com.pavelvlasov.review.SourceMarker; 39 import com.pavelvlasov.review.SourceMarkerComparator; 40 import com.pavelvlasov.review.SourceMarkerRenderer; 41 42 47 public class InspectorSummaryRenderer extends AbstractRenderer { 48 49 public InspectorSummaryRenderer(RenderRequest request) { 50 super(request); 51 } 52 53 public InspectorSummaryRenderer(RenderRequest request, String profile) { 54 super(request, profile); 55 } 56 57 public Element render(Document document) throws RenderingException { 58 Element ret=document.createElement("inspector-summary"); 59 InspectorSummary is=(InspectorSummary) request.getRenderee(); 60 61 ret.setAttribute("inspector", is.getName()); 62 ret.setAttribute("description", is.getDescription()); 63 ret.setAttribute("severity", is.getSeverity().toString()); 64 ret.setAttribute("baseline", String.valueOf(is.getBaseLineLocationsCount())); 65 ret.setAttribute("count", String.valueOf(is.getLocationsCount())); 66 67 if (is.getVersion()!=null) { 68 ret.setAttribute("version", is.getVersion()); 69 } 70 71 String inspectorConfigInfo=is.getConfigInfo(); 72 if (inspectorConfigInfo!=null) { 73 ret 74 .appendChild(document.createElement("config-info")) 75 .appendChild(document.createTextNode(inspectorConfigInfo)); 76 } 77 78 List locations=is.getLocations(); 79 if (locations!=null) { 80 locations=new ArrayList (locations); 81 Collections.sort(locations, new SourceMarkerComparator()); 82 Iterator smit=locations.iterator(); 83 while (smit.hasNext()) { 84 SourceMarkerRenderer smr=new SourceMarkerRenderer(new RenderRequest((SourceMarker) smit.next())); 85 ret.appendChild(smr.render(document)); 86 } 87 } 88 return ret; 89 } 90 } 91 | Popular Tags |