MetricDomSerializer.java

biz/hammurapi/metrics/MetricDomSerializer.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 089 Type is not documented 2 36:1
Java Inspector 089 Undocumented method 2 38:9
Java Inspector 089 Undocumented method 2 41:25
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 55:37
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 56:29
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 57:29
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 58:37
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 60:29
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 61:29
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 62:37
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 64:53

Source code

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 org.w3c.dom.Element;
26
27import biz.hammurapi.render.RenderingException;
28import biz.hammurapi.xml.dom.DOMUtils;
29import biz.hammurapi.xml.dom.DomSerializable;
30
31
32/**
33 * @author Pavel Vlasov
34 * @revision $Revision$
35 */
36public class MetricDomSerializer {
37
38 public DomSerializable toDomSerializable(final Metric metric) {
39 return new DomSerializable() {
40
41 public void toDom(Element holder) {
42 MetricDomSerializer.this.toDom(holder, metric);
43 }
44
45 };
46 }
47
48 /**
49 * @param document
50 * @param holder
51 * @param m
52 * @throws RenderingException
53 */
54 private void toDom(Element holder, Metric m) {
55 holder.setAttribute("name", m.getName());
56 holder.setAttribute("avg", String.valueOf(m.getAvg()));
57 holder.setAttribute("min", String.valueOf(m.getMin()));
58 holder.setAttribute("max", String.valueOf(m.getMax()));
59
60 holder.setAttribute("total", String.valueOf(m.getTotal()));
61 holder.setAttribute("number", String.valueOf(m.getNumber()));
62 holder.setAttribute("deviation", String.valueOf(m.getDeviation()));
63
64 DOMUtils.toDom(m.getMeasurements(), "measurements", holder);
65 }
66}
67