Inspector | Message | Severity | Location |
---|---|---|---|
Java Inspector 048 | Copyrights information should be present in each file. | 1 | |
Java Inspector 089 | Type is not documented | 2 | 43:1 |
Java Inspector 089 | Undocumented constructor | 2 | 45:5 |
Java Inspector 089 | Undocumented constructor | 2 | 49:5 |
Java Inspector 089 | Undocumented method | 2 | 53:5 |
Java Inspector 089 | Method is not properly documented | 2 | 98:9 |
Java Inspector 089 | Empty @throws tag in documentation. | 2 | 98:9 |
Java Inspector 089 | Parameter ms is not documented | 2 | 98:9 |
Java Inspector 089 | Parameter me is not documented | 2 | 98:9 |
Java Inspector 089 | Javadoc contains tag for exception which method doesn't throw RenderingException | 2 | 98:9 |
Java Inspector 089 | Javadoc contains tag for exception which method doesn't throw DOMException | 2 | 98:9 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 54:44 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 69:37 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 70:29 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 71:29 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 72:37 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 74:29 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 75:29 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 76:37 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 83:78 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 99:33 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 100:33 |
1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; 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.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.metrics;
24
25import java.util.Collection;
26import java.util.Iterator;
27
28import org.w3c.dom.DOMException;
29import org.w3c.dom.Document;
30import org.w3c.dom.Element;
31
32import biz.hammurapi.metrics.Metric.Measurement;
33import biz.hammurapi.render.RenderRequest;
34import biz.hammurapi.render.RenderingException;
35import biz.hammurapi.render.dom.AbstractRenderer;
36import biz.hammurapi.render.dom.DomRenderer;
37
38
39/**
40 * @author Pavel Vlasov
41 * @version $Revision: 1.8 $
42 */
43public class MetricRenderer extends AbstractRenderer implements DomRenderer {
44
45 public MetricRenderer(RenderRequest request) {
46 super(request);
47 }
48
49 public MetricRenderer(RenderRequest request, String profile) {
50 super(request, profile);
51 }
52
53 public Element render(Document document) throws RenderingException {
54 Element ret=document.createElement("metric");
55 Metric m=(Metric) request.getRenderee();
56
57 toDom(ret, m);
58 return ret;
59 }
60
61 /**
62 * @param document
63 * @param holder
64 * @param m
65 * @throws RenderingException
66 * @throws RenderingException
67 */
68 private void toDom(Element holder, Metric m) throws RenderingException {
69 holder.setAttribute("name", m.getName());
70 holder.setAttribute("avg", String.valueOf(m.getAvg()));
71 holder.setAttribute("min", String.valueOf(m.getMin()));
72 holder.setAttribute("max", String.valueOf(m.getMax()));
73
74 holder.setAttribute("total", String.valueOf(m.getTotal()));
75 holder.setAttribute("number", String.valueOf(m.getNumber()));
76 holder.setAttribute("deviation", String.valueOf(m.getDeviation()));
77
78 Collection measurements = m.getMeasurements();
79 if (measurements!=null) {
80 Iterator it=measurements.iterator();
81 while (it.hasNext()) {
82 Measurement ms=(Measurement) it.next();
83 Element me = holder.getOwnerDocument().createElement("measurement");
84 holder.appendChild(me);
85 renderMeasurement(ms, me);
86 }
87 }
88 }
89
90 /**
91 * @param ms
92 * @param me
93 * @throws RenderingException
94 * @throws
95 * @throws RenderingException
96 * @throws DOMException
97 */
98 protected void renderMeasurement(Measurement ms, Element me) throws RenderingException {
99 me.setAttribute("value", String.valueOf(ms.getValue()));
100 me.setAttribute("time", String.valueOf(ms.getTime()));
101 }
102
103}
104