1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.wikimodel.xhtml.filter

File DTDXMLFilter.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

12
18
10
1
129
78
16
0.89
1.8
10
1.6

Classes

Class Line # Actions
DTDXMLFilter 32 18 0% 16 7
0.82582.5%
 

Contributing tests

This file is covered by 351 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.wikimodel.xhtml.filter;
21   
22    import org.xml.sax.Attributes;
23    import org.xml.sax.SAXException;
24    import org.xml.sax.XMLReader;
25   
26    /**
27    * Skip all callbacks when parsing the DTD.
28    *
29    * @version $Id: 702d75e4187f45b19301381a846304a8704d5135 $
30    * @since 4.0M1
31    */
 
32    public class DTDXMLFilter extends DefaultXMLFilter
33    {
34    /**
35    * We want to accumulate characters only when not parsing the DTD.
36    */
37    private boolean fIsInDTD;
38   
 
39  0 toggle public DTDXMLFilter()
40    {
41  0 super();
42    }
43   
 
44  433 toggle public DTDXMLFilter(XMLReader reader)
45    {
46  433 super(reader);
47    }
48   
49    /**
50    * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
51    */
 
52  1667 toggle @Override
53    public void characters(char[] array, int start, int length)
54    throws SAXException
55    {
56  1667 if (!fIsInDTD) {
57  1667 super.characters(array, start, length);
58    }
59    }
60   
61    /**
62    * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
63    * java.lang.String, java.lang.String, org.xml.sax.Attributes)
64    */
 
65  2340 toggle @Override
66    public void startElement(
67    String uri,
68    String localName,
69    String qName,
70    Attributes attributes) throws SAXException
71    {
72  2340 if (!fIsInDTD) {
73  2340 super.startElement(uri, localName, qName, attributes);
74    }
75    }
76   
77    /**
78    * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
79    * java.lang.String, java.lang.String)
80    */
 
81  2340 toggle @Override
82    public void endElement(String uri, String localName, String qName)
83    throws SAXException
84    {
85  2340 if (!fIsInDTD) {
86  2340 super.endElement(uri, localName, qName);
87    }
88    }
89   
 
90  124271 toggle @Override
91    public void comment(char[] array, int start, int length)
92    throws SAXException
93    {
94  124271 if (!fIsInDTD) {
95  303 super.comment(array, start, length);
96    }
97    }
98   
 
99  3 toggle @Override
100    public void startCDATA() throws SAXException
101    {
102  3 if (!fIsInDTD) {
103  3 super.startCDATA();
104    }
105    }
106   
 
107  3 toggle @Override
108    public void endCDATA() throws SAXException
109    {
110  3 if (!fIsInDTD) {
111  3 super.endCDATA();
112    }
113    }
114   
 
115  298 toggle @Override
116    public void startDTD(String name, String publicId, String systemId)
117    throws SAXException
118    {
119  298 fIsInDTD = true;
120  298 super.startDTD(name, publicId, systemId);
121    }
122   
 
123  298 toggle @Override
124    public void endDTD() throws SAXException
125    {
126  298 fIsInDTD = false;
127  298 super.endDTD();
128    }
129    }