1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.xml.internal.renderer

File SAXSerializer.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

4
11
4
1
83
36
6
0.55
2.75
4
1.5

Classes

Class Line # Actions
SAXSerializer 34 11 0% 6 8
0.5789473757.9%
 

Contributing tests

This file is covered by 277 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.xml.internal.renderer;
21   
22    import java.io.IOException;
23    import java.io.Writer;
24   
25    import org.dom4j.io.OutputFormat;
26    import org.dom4j.io.XMLWriter;
27   
28    /**
29    * Fix various issues in {@link XMLWriter}.
30    *
31    * @version $Id: f45e6f2ce21ca4b3fe410af204f11397f8ac319b $
32    * @since 5.2M1
33    */
 
34    public class SAXSerializer extends XMLWriter
35    {
36    /**
37    * Indicate if something has been written already (only used when formatting is enabled).
38    */
39    private boolean started;
40   
41    /**
42    * @param writer the actual writer
43    */
 
44  529 toggle public SAXSerializer(Writer writer)
45    {
46  529 super(writer);
47    }
48   
49    /**
50    * @param writer the actual writer
51    * @param format the XML format to use
52    * @since 5.2M1
53    */
 
54  0 toggle public SAXSerializer(Writer writer, OutputFormat format)
55    {
56  0 super(writer, format);
57    }
58   
 
59  615 toggle @Override
60    // FIXME: remove that when https://sourceforge.net/p/dom4j/bugs/202/ is fixed
61    protected String escapeAttributeEntities(String text)
62    {
63  615 String escapedTest = super.escapeAttributeEntities(text);
64  615 escapedTest = escapedTest.replace("\t", "	");
65  615 escapedTest = escapedTest.replace("\n", "
");
66  615 escapedTest = escapedTest.replace("\r", "
");
67   
68  615 return escapedTest;
69    }
70   
71    // Workaround a XMLWriter with the first new line
 
72  17994 toggle @Override
73    protected void writePrintln() throws IOException
74    {
75  17994 if (getOutputFormat().isNewlines()) {
76  0 if (this.started) {
77  0 super.writePrintln();
78    }
79   
80  0 this.started = true;
81    }
82    }
83    }