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

File AbstractStreamRendererFactory.java

 

Coverage histogram

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

Code metrics

0
9
3
1
78
38
4
0.44
3
3
1.33

Classes

Class Line # Actions
AbstractStreamRendererFactory 39 9 0% 4 5
0.583333358.3%
 

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 javax.inject.Inject;
23   
24    import org.xml.sax.ContentHandler;
25    import org.xwiki.component.manager.ComponentLookupException;
26    import org.xwiki.component.manager.ComponentManager;
27    import org.xwiki.rendering.renderer.PrintRenderer;
28    import org.xwiki.rendering.renderer.PrintRendererFactory;
29    import org.xwiki.rendering.renderer.printer.WikiPrinter;
30    import org.xwiki.rendering.renderer.xml.ContentHandlerStreamRenderer;
31    import org.xwiki.rendering.renderer.xml.ContentHandlerStreamRendererFactory;
32   
33    /**
34    * Base class for XML based syntax stream renderers.
35    *
36    * @version $Id: 1a59a7d1087f935e3651027ee8ed9cf46df6170e $
37    * @since 5.2M1
38    */
 
39    public abstract class AbstractStreamRendererFactory implements PrintRendererFactory,
40    ContentHandlerStreamRendererFactory
41    {
42    /**
43    * Used to lookup the actual renderer.
44    */
45    @Inject
46    protected ComponentManager componentManager;
47   
48    /**
49    * @return the new {@link ContentHandlerStreamRenderer} instance
50    */
 
51  2 toggle protected ContentHandlerStreamRenderer createContentHandlerStreamRenderer()
52    {
53  2 ContentHandlerStreamRenderer renderer;
54  2 try {
55  2 renderer = this.componentManager.getInstance(ContentHandlerStreamRenderer.class, getSyntax().toIdString());
56    } catch (ComponentLookupException e) {
57  0 throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
58    }
59   
60  2 return renderer;
61    }
62   
 
63  0 toggle @Override
64    public ContentHandlerStreamRenderer createRenderer(ContentHandler contentHandler)
65    {
66  0 ContentHandlerStreamRenderer renderer = createContentHandlerStreamRenderer();
67   
68  0 renderer.setContentHandler(contentHandler);
69   
70  0 return renderer;
71    }
72   
 
73  529 toggle @Override
74    public PrintRenderer createRenderer(WikiPrinter printer)
75    {
76  529 return new ContentHandlerPrintRenderer(createContentHandlerStreamRenderer(), printer);
77    }
78    }