Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../img/srcFileCovDistChart6.png 81% of files have more coverage
9   78   4   3
0   38   0.44   3
3     1.33  
1    
 
  AbstractStreamRendererFactory       Line # 39 9 0% 4 5 58.3% 0.5833333
 
  (8)
 
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.internal.renderer.xml;
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: 2e46875e971c108e4d7ba74562a4109b49b9ba8b $
37    * @since 3.3M1
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  4 toggle protected ContentHandlerStreamRenderer createContentHandlerStreamRenderer()
52    {
53  4 ContentHandlerStreamRenderer renderer;
54  4 try {
55  4 renderer = this.componentManager.lookup(ContentHandlerStreamRenderer.class, getSyntax().toIdString());
56    } catch (ComponentLookupException e) {
57  0 throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
58    }
59   
60  4 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  8 toggle @Override
74    public PrintRenderer createRenderer(WikiPrinter printer)
75    {
76  8 return new ContentHandlerPrintRenderer(createContentHandlerStreamRenderer(), printer);
77    }
78    }