11package scoverage .report
22
3- import scala .xml .{Utility , PrettyPrinter , Node }
43import java .io .File
4+
5+ import scala .xml .{Node , PrettyPrinter }
6+
57import org .apache .commons .io .FileUtils
8+
69import scoverage ._
7- import scoverage .MeasuredStatement
8- import scoverage .MeasuredClass
9- import scoverage .MeasuredMethod
1010
1111/** @author Stephen Samuel */
1212class ScoverageXmlWriter (sourceDir : File , outputDir : File , debug : Boolean ) {
@@ -19,31 +19,6 @@ class ScoverageXmlWriter(sourceDir: File, outputDir: File, debug: Boolean) {
1919 FileUtils .write(file, new PrettyPrinter (120 , 4 ).format(xml(coverage)))
2020 }
2121
22- /**
23- * This method ensures that the output String has only
24- * valid XML unicode characters as specified by the
25- * XML 1.0 standard. For reference, please see
26- * <a href="http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">the
27- * standard</a>. This method will return an empty
28- * String if the input is null or empty.
29- *
30- * @param in The String whose non-valid characters we want to remove.
31- * @return The in String, stripped of non-valid characters.
32- * @see http://blog.mark-mclaren.info/2007/02/invalid-xml-characters-when-valid-utf8_5873.html
33- *
34- */
35- private def escape (in : String ): String = {
36- val out = new StringBuilder ()
37- for ( current <- Option (in).getOrElse(" " ).toCharArray ) {
38- if ((current == 0x9 ) || (current == 0xA ) || (current == 0xD ) ||
39- ((current >= 0x20 ) && (current <= 0xD7FF )) ||
40- ((current >= 0xE000 ) && (current <= 0xFFFD )) ||
41- ((current >= 0x10000 ) && (current <= 0x10FFFF )))
42- out.append(current)
43- }
44- out.mkString
45- }
46-
4722 def statement (stmt : MeasuredStatement ): Node = {
4823 debug match {
4924 case true =>
@@ -52,20 +27,18 @@ class ScoverageXmlWriter(sourceDir: File, outputDir: File, debug: Boolean) {
5227 method= {stmt.location.method}
5328 start= {stmt.start.toString}
5429 line= {stmt.line.toString}
55- symbol= {escape(stmt.symbolName)}
56- tree= {stmt.treeName}
30+ symbol= {IOUtils . escape(stmt.symbolName)}
31+ tree= {IOUtils .escape( stmt.treeName) }
5732 branch= {stmt.branch.toString}
5833 invocation- count= {stmt.count.toString}>
59- {escape(stmt.desc)}
34+ {IOUtils . escape(stmt.desc)}
6035 </statement >
6136 case false =>
6237 < statement package= {stmt.location._package}
6338 class = {stmt.location._class}
6439 method= {stmt.location.method}
6540 start= {stmt.start.toString}
6641 line= {stmt.line.toString}
67- symbol= {escape(stmt.symbolName)}
68- tree= {stmt.treeName}
6942 branch= {stmt.branch.toString}
7043 invocation- count= {stmt.count.toString}/>
7144 }
0 commit comments