%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
ca.spaz.util.XMLNode |
|
|
1 | /* |
|
2 | * Created on Apr 10, 2005 by davidson |
|
3 | */ |
|
4 | package ca.spaz.util; |
|
5 | ||
6 | import java.io.PrintStream; |
|
7 | import java.util.*; |
|
8 | ||
9 | /** |
|
10 | * A super simple class for quickly outputting some XML |
|
11 | * |
|
12 | * @author davidson |
|
13 | */ |
|
14 | public class XMLNode { |
|
15 | String name; |
|
16 | 0 | HashMap attributes = new HashMap(); |
17 | 0 | ArrayList children = new ArrayList(); |
18 | ||
19 | 0 | public XMLNode(String name) { |
20 | 0 | this.name = name; |
21 | 0 | } |
22 | ||
23 | public void addAttribute(String key, String val) { |
|
24 | 0 | attributes.put(key, val); |
25 | 0 | } |
26 | ||
27 | public void addChild(XMLNode node) { |
|
28 | 0 | children.add(node); |
29 | 0 | } |
30 | ||
31 | /** |
|
32 | * Escape a string so that it's safe to put in XML |
|
33 | * @param str |
|
34 | * @return an escaped string, safe for XML. |
|
35 | */ |
|
36 | public String escape(String str) { |
|
37 | 0 | str = str.replaceAll("&", "&"); |
38 | 0 | str = str.replaceAll("\"", ""e;"); |
39 | 0 | str = str.replaceAll("<", "<"); |
40 | 0 | str = str.replaceAll(">", ">"); |
41 | 0 | return str; |
42 | } |
|
43 | ||
44 | public void print(PrintStream out) { |
|
45 | ||
46 | 0 | } |
47 | ||
48 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |