KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > render > dom > InspectorSummaryRenderer


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
24 package org.hammurapi.render.dom;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collections JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.hammurapi.results.InspectorSummary;
32 import org.w3c.dom.Document JavaDoc;
33 import org.w3c.dom.Element JavaDoc;
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 /**
43  *
44  * @author Pavel Vlasov
45  * @version $Revision: 1.5 $
46  */

47 public class InspectorSummaryRenderer extends AbstractRenderer {
48     
49     public InspectorSummaryRenderer(RenderRequest request) {
50         super(request);
51     }
52     
53     public InspectorSummaryRenderer(RenderRequest request, String JavaDoc profile) {
54         super(request, profile);
55     }
56     
57     public Element JavaDoc render(Document JavaDoc document) throws RenderingException {
58         Element JavaDoc 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 JavaDoc inspectorConfigInfo=is.getConfigInfo();
72         if (inspectorConfigInfo!=null) {
73             ret
74             .appendChild(document.createElement("config-info"))
75             .appendChild(document.createTextNode(inspectorConfigInfo));
76         }
77         
78         List JavaDoc locations=is.getLocations();
79         if (locations!=null) {
80             locations=new ArrayList JavaDoc(locations);
81             Collections.sort(locations, new SourceMarkerComparator());
82             Iterator JavaDoc 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