01: /*
02: * Hammurapi
03: * Automated Java code review system.
04: * Copyright (C) 2004 Hammurapi Group
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (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;
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: /**
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,
54: String profile) {
55: super (request, profile);
56: }
57:
58: public Element render(Document document) throws RenderingException {
59: Element ret = document.createElement("inspector-summary");
60: InspectorSummary is = (InspectorSummary) request.getRenderee();
61:
62: ret.setAttribute("inspector", is.getName());
63: ret.setAttribute("description", is.getDescription());
64: ret.setAttribute("severity", is.getSeverity().toString());
65: ret.setAttribute("baseline", String.valueOf(is
66: .getBaseLineLocationsCount()));
67: ret.setAttribute("count", String
68: .valueOf(is.getLocationsCount()));
69:
70: if (is.getVersion() != null) {
71: ret.setAttribute("version", is.getVersion());
72: }
73:
74: String inspectorConfigInfo = is.getConfigInfo();
75: if (inspectorConfigInfo != null) {
76: ret
77: .appendChild(document.createElement("config-info"))
78: .appendChild(
79: document
80: .createTextNode(inspectorConfigInfo));
81: }
82:
83: List locations = is.getLocations();
84: if (locations != null) {
85: locations = new ArrayList(locations);
86: Collections.sort(locations, new SourceMarkerComparator());
87: Iterator smit = locations.iterator();
88: while (smit.hasNext()) {
89: SourceMarkerRenderer smr = new SourceMarkerRenderer(
90: new RenderRequest((SourceMarker) smit.next()));
91: ret.appendChild(smr.render(document));
92: }
93: }
94: return ret;
95: }
96: }
|