1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.wikimodel.xhtml.filter

File DefaultXMLFilter.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

20
25
12
1
138
97
22
0.88
2.08
12
1.83

Classes

Class Line # Actions
DefaultXMLFilter 36 25 0% 22 16
0.7192982471.9%
 

Contributing tests

This file is covered by 324 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 java.io.IOException;
23   
24    import org.xml.sax.InputSource;
25    import org.xml.sax.SAXException;
26    import org.xml.sax.SAXNotRecognizedException;
27    import org.xml.sax.SAXNotSupportedException;
28    import org.xml.sax.XMLReader;
29    import org.xml.sax.ext.LexicalHandler;
30    import org.xml.sax.helpers.XMLFilterImpl;
31   
32    /**
33    * @version $Id: b835e5e8b3f65f2605ae506c182953847d5466e4 $
34    * @since 4.0M1
35    */
 
36    public class DefaultXMLFilter extends XMLFilterImpl implements LexicalHandler
37    {
38    public static final String SAX_LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler";
39   
40    private LexicalHandler lexicalHandler;
41   
 
42  2 toggle public DefaultXMLFilter()
43    {
44  2 super();
45    }
46   
 
47  1313 toggle public DefaultXMLFilter(XMLReader reader)
48    {
49  1313 super(reader);
50    }
51   
 
52  1348 toggle @Override
53    public void parse(InputSource input) throws SAXException, IOException
54    {
55  1348 if (getParent() != null) {
56  1348 getParent().setProperty(SAX_LEXICAL_HANDLER_PROPERTY, this);
57    }
58  1348 super.parse(input);
59    }
60   
 
61  1313 toggle @Override
62    public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
63    {
64    // We save the lexical handler so that we can use it in the
65    // implementation of the LexicalHandler interface methods.
66  1313 if (SAX_LEXICAL_HANDLER_PROPERTY.equals(name)) {
67  1313 this.lexicalHandler = (LexicalHandler) value;
68    } else {
69  0 super.setProperty(name, value);
70    }
71    }
72   
 
73  0 toggle @Override
74    public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
75    {
76  0 if (SAX_LEXICAL_HANDLER_PROPERTY.equals(name)) {
77  0 return this.lexicalHandler;
78    } else {
79  0 return super.getProperty(name);
80    }
81    }
82   
 
83  784 toggle @Override
84    public void comment(char[] ch, int start, int length) throws SAXException
85    {
86  784 if (this.lexicalHandler != null) {
87  784 this.lexicalHandler.comment(ch, start, length);
88    }
89    }
90   
 
91  108 toggle @Override
92    public void endCDATA() throws SAXException
93    {
94  108 if (this.lexicalHandler != null) {
95  108 this.lexicalHandler.endCDATA();
96    }
97    }
98   
 
99  909 toggle @Override
100    public void endDTD() throws SAXException
101    {
102  909 if (this.lexicalHandler != null) {
103  909 this.lexicalHandler.endDTD();
104    }
105    }
106   
 
107  16185 toggle @Override
108    public void endEntity(String name) throws SAXException
109    {
110  16185 if (this.lexicalHandler != null) {
111  16185 this.lexicalHandler.endEntity(name);
112    }
113    }
114   
 
115  108 toggle @Override
116    public void startCDATA() throws SAXException
117    {
118  108 if (this.lexicalHandler != null) {
119  108 this.lexicalHandler.startCDATA();
120    }
121    }
122   
 
123  909 toggle @Override
124    public void startDTD(String name, String publicId, String systemId) throws SAXException
125    {
126  909 if (this.lexicalHandler != null) {
127  909 this.lexicalHandler.startDTD(name, publicId, systemId);
128    }
129    }
130   
 
131  16185 toggle @Override
132    public void startEntity(String name) throws SAXException
133    {
134  16185 if (this.lexicalHandler != null) {
135  16185 this.lexicalHandler.startEntity(name);
136    }
137    }
138    }