EMMA Coverage Report (generated Tue Jun 26 14:54:12 CEST 2012)
[all classes][org.tomdroid.util]

COVERAGE SUMMARY FOR SOURCE FILE [XmlUtils.java]

nameclass, %method, %block, %line, %
XmlUtils.java100% (1/1)33%  (1/3)46%  (17/37)33%  (1/3)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class XmlUtils100% (1/1)33%  (1/3)46%  (17/37)33%  (1/3)
XmlUtils (): void 0%   (0/1)0%   (0/3)0%   (0/1)
unescape (String): String 0%   (0/1)0%   (0/17)0%   (0/1)
escape (String): String 100% (1/1)100% (17/17)100% (1/1)

1/*
2 * Tomdroid
3 * Tomboy on Android
4 * http://www.launchpad.net/tomdroid
5 * 
6 * Copyright 2009, Benoit Garret <benoit.garret_launchpad@gadz.org>
7 * 
8 * This file is part of Tomdroid.
9 * 
10 * Tomdroid is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 * 
15 * Tomdroid is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 * 
20 * You should have received a copy of the GNU General Public License
21 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
22 */
23package org.tomdroid.util;
24 
25public class XmlUtils {
26        
27        /**
28         * Useful to replace the characters forbidden in xml by their escaped counterparts
29         * Ex: &amp; -> &amp;amp;
30         * 
31         * @param input the string to escape
32         * @return the escaped string
33         */
34        public static String escape(String input) {
35                return input
36                        .replace("&", "&amp;")
37                        .replace("<", "&lt;")
38                        .replace(">", "&gt;")
39                        .replace("\"", "&quot;")
40                        .replace("\'", "&apos;");
41        }
42        
43        /**
44         * Useful to replace the escaped characters their unescaped counterparts
45         * Ex: &amp;amp; -> &amp;
46         * 
47         * @param input the string to unescape
48         * @return the unescaped string
49         */
50        public static String unescape(String input) {
51                return input
52                        .replace("&amp;", "&")
53                        .replace("&lt;", "<")
54                        .replace("&gt;", ">")
55                        .replace("&quot;", "\"")
56                        .replace("&apos;", "\'");
57        }
58}

[all classes][org.tomdroid.util]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov