Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
17   103   5   5.67
4   50   0.29   3
3     1.67  
1    
 
  XHTMLXWikiGeneratorListener       Line # 39 17 0% 5 0 100% 1.0
 
  (219)
 
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.parser.xhtml.wikimodel;
21   
22    import org.xwiki.rendering.wikimodel.WikiReference;
23    import org.xwiki.rendering.internal.parser.wikimodel.DefaultXWikiGeneratorListener;
24    import org.xwiki.rendering.listener.Listener;
25    import org.xwiki.rendering.listener.reference.ResourceReference;
26    import org.xwiki.rendering.listener.reference.ResourceType;
27    import org.xwiki.rendering.parser.ResourceReferenceParser;
28    import org.xwiki.rendering.parser.StreamParser;
29    import org.xwiki.rendering.renderer.PrintRendererFactory;
30    import org.xwiki.rendering.syntax.Syntax;
31    import org.xwiki.rendering.util.IdGenerator;
32   
33    /**
34    * WikiModel listener bridge for the XHTML Syntax.
35    *
36    * @version $Id: 3fa598160b53d4297a281869b17ea56f263a8efa $
37    * @since 2.5RC1
38    */
 
39    public class XHTMLXWikiGeneratorListener extends DefaultXWikiGeneratorListener
40    {
41    /**
42    * @param parser the parser to use to parse link labels
43    * @param listener the XWiki listener to which to forward WikiModel events
44    * @param linkReferenceParser the parser to parse link references
45    * @param imageReferenceParser the parser to parse image references
46    * @param plainRendererFactory used to generate header ids
47    * @param idGenerator used to generate header ids
48    * @param syntax the syntax of the parsed source
49    * @since 3.0M3
50    */
 
51  271 toggle public XHTMLXWikiGeneratorListener(StreamParser parser, Listener listener,
52    ResourceReferenceParser linkReferenceParser, ResourceReferenceParser imageReferenceParser,
53    PrintRendererFactory plainRendererFactory, IdGenerator idGenerator, Syntax syntax)
54    {
55  271 super(parser, listener, linkReferenceParser, imageReferenceParser, plainRendererFactory, idGenerator, syntax);
56    }
57   
 
58  52 toggle @Override
59    public void onReference(WikiReference reference)
60    {
61    // We need to handle 2 cases:
62    // - when the passed reference is an instance of XWikiWikiReference, i.e. when a XHTML comment defining a XWiki
63    // link has been specified
64    // - when the passed reference is not an instance of XWikiWikiReference which will happen if there's no special
65    // XHTML comment defining a XWiki link7
66  52 ResourceReference resourceReference;
67  52 boolean isFreeStanding;
68  52 if (!(reference instanceof XWikiWikiReference)) {
69  7 resourceReference = new ResourceReference(reference.getLink(), ResourceType.URL);
70  7 isFreeStanding = false;
71    } else {
72  45 XWikiWikiReference xwikiReference = (XWikiWikiReference) reference;
73  45 resourceReference = xwikiReference.getReference();
74  45 isFreeStanding = xwikiReference.isFreeStanding();
75   
76  45 flushFormat();
77    }
78   
79  52 onReference(resourceReference, reference.getLabel(), isFreeStanding,
80    convertParameters(reference.getParameters()));
81    }
82   
 
83  19 toggle @Override
84    public void onImage(WikiReference reference)
85    {
86    // We need to handle 2 cases:
87    // - when the passed reference is an instance of XWikiWikiReference, i.e. when a XHTML comment defining a XWiki
88    // image has been specified
89    // - when the passed reference is not an instance of XWikiWikiReference which will happen if there's no special
90    // XHTML comment defining a XWiki image
91  19 if (!(reference instanceof XWikiWikiReference)) {
92  4 super.onImage(reference);
93    } else {
94  15 XWikiWikiReference xwikiReference = (XWikiWikiReference) reference;
95  15 ResourceReference resourceReference = xwikiReference.getReference();
96   
97  15 flushFormat();
98   
99  15 onImage(resourceReference, xwikiReference.isFreeStanding(),
100    convertParameters(xwikiReference.getParameters()));
101    }
102    }
103    }