Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WSPLGENCalculation.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENCalculation.java@975f608dd254 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.model.map; | |
2 | |
3 import java.util.HashMap; | |
4 import java.util.Map; | |
5 | |
6 import org.w3c.dom.Document; | |
7 import org.w3c.dom.Element; | |
8 | |
9 import org.apache.log4j.Logger; | |
10 | |
11 import org.dive4elements.artifacts.CallMeta; | |
12 import org.dive4elements.river.artifacts.model.Calculation; | |
13 | |
14 | |
15 public class WSPLGENCalculation extends Calculation { | |
16 | |
17 private static final Logger log = Logger.getLogger(WSPLGENCalculation.class); | |
18 | |
19 protected Map<Integer, String> errors; | |
20 protected Map<Integer, String> warnings; | |
21 | |
22 | |
23 public WSPLGENCalculation() { | |
24 errors = new HashMap<Integer, String>(); | |
25 warnings = new HashMap<Integer, String>(); | |
26 } | |
27 | |
28 | |
29 public void addError(Integer key, String msg) { | |
30 log.debug("New error: (" + key + ") " + msg); | |
31 errors.put(key, msg); | |
32 } | |
33 | |
34 | |
35 public void addWarning(Integer key, String msg) { | |
36 log.debug("New warning: (" + key + ") " + msg); | |
37 warnings.put(key, msg); | |
38 } | |
39 | |
40 | |
41 public int numErrors() { | |
42 return errors.size(); | |
43 } | |
44 | |
45 | |
46 public int numWarnings() { | |
47 return warnings.size(); | |
48 } | |
49 | |
50 | |
51 @Override | |
52 public void toXML(Document document, CallMeta meta) { | |
53 Element root = document.createElement("problems"); | |
54 | |
55 if (numErrors() > 0) { | |
56 for (Map.Entry<Integer, String> entry: errors.entrySet()) { | |
57 Element problem = document.createElement("problem"); | |
58 problem.setAttribute("error", String.valueOf(entry.getKey())); | |
59 problem.setTextContent(entry.getValue()); | |
60 | |
61 root.appendChild(problem); | |
62 } | |
63 } | |
64 | |
65 if (numWarnings() > 0) { | |
66 for (Map.Entry<Integer, String> entry: warnings.entrySet()) { | |
67 Element problem = document.createElement("problem"); | |
68 problem.setAttribute("error", String.valueOf(entry.getKey())); | |
69 problem.setTextContent(entry.getValue()); | |
70 | |
71 root.appendChild(problem); | |
72 } | |
73 } | |
74 | |
75 document.appendChild(root); | |
76 } | |
77 } | |
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |