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

File XDOMXMLChainingStreamRenderer.java

 

Coverage histogram

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

Code metrics

0
6
4
1
83
38
5
0.83
1.5
4
1.25

Classes

Class Line # Actions
XDOMXMLChainingStreamRenderer 38 6 0% 5 4
0.660%
 

Contributing tests

This file is covered by 275 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.xdomxmlcurrent.internal.renderer;
21   
22    import javax.xml.stream.XMLStreamException;
23    import javax.xml.transform.sax.SAXResult;
24   
25    import org.xml.sax.ContentHandler;
26    import org.xwiki.filter.xml.serializer.XMLSerializerFactory;
27    import org.xwiki.rendering.listener.Listener;
28    import org.xwiki.rendering.listener.WrappingListener;
29    import org.xwiki.rendering.renderer.xml.ContentHandlerStreamRenderer;
30    import org.xwiki.rendering.syntax.Syntax;
31   
32    /**
33    * Current version of the XDOM+XML stream based renderer.
34    *
35    * @version $Id: b066d29f04a6c5ed0f8cf44d907d6bd7bce4ceab $
36    * @since 3.3M1
37    */
 
38    public class XDOMXMLChainingStreamRenderer extends WrappingListener implements ContentHandlerStreamRenderer
39    {
40    /**
41    * The actual XML serializer factory.
42    */
43    private XMLSerializerFactory serializerFactory;
44   
45    /**
46    * The content handler to send SAX events to.
47    */
48    private ContentHandler contentHandler;
49   
50    /**
51    * @param serializerFactory the actual XML serializer factory
52    */
 
53  527 toggle public XDOMXMLChainingStreamRenderer(XMLSerializerFactory serializerFactory)
54    {
55  527 this.serializerFactory = serializerFactory;
56    }
57   
 
58  0 toggle @Override
59    public Syntax getSyntax()
60    {
61  0 return Syntax.XDOMXML_CURRENT;
62    }
63   
 
64  0 toggle @Override
65    public ContentHandler getContentHandler()
66    {
67  0 return this.contentHandler;
68    }
69   
 
70  527 toggle @Override
71    public void setContentHandler(ContentHandler contentHandler)
72    {
73  527 this.contentHandler = contentHandler;
74   
75  527 try {
76  527 setWrappedListener(this.serializerFactory.createSerializer(Listener.class, new SAXResult(
77    this.contentHandler), null));
78    } catch (XMLStreamException e) {
79    // Should never happen
80    // TODO: log an error something
81    }
82    }
83    }