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

File XWikiSpanTagHandler.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

16
18
2
1
82
49
14
0.78
9
2
7

Classes

Class Line # Actions
XWikiSpanTagHandler 33 18 0% 14 4
0.888888988.9%
 

Contributing tests

This file is covered by 72 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.internal.parser.xhtml.wikimodel;
21   
22    import org.xwiki.rendering.wikimodel.WikiParameter;
23    import org.xwiki.rendering.wikimodel.xhtml.handler.SpanTagHandler;
24    import org.xwiki.rendering.wikimodel.xhtml.impl.TagContext;
25   
26    /**
27    * Handle XWiki span elements (we need to ensure we skip link content when we generate them and also skip the spans for
28    * the "?" for links pointing to non existing pages).
29    *
30    * @version $Id: 5785702863ccb82dc4511a75ee6d853a956c9ef0 $
31    * @since 1.7M1
32    */
 
33    public class XWikiSpanTagHandler extends SpanTagHandler implements XWikiWikiModelHandler
34    {
 
35  170 toggle @Override
36    protected void begin(TagContext context)
37    {
38    // If we're on a span for unknown links then skip the event for its content.
39    // Ex: <a href="..."><span class="wikicreatelinktext">...</span><span class="wikicreatelinkqm">?</span></a>
40  170 WikiParameter classParam = context.getParams().getParameter("class");
41  170 if (classParam != null) {
42  96 if (classParam.getValue().contains("wikigeneratedlinkcontent"))
43    {
44  37 setAccumulateContent(true);
45  59 } else if (classParam.getValue().equals("wikilink")
46    || classParam.getValue().equals("wikicreatelink")
47    || classParam.getValue().equals("wikiexternallink"))
48    {
49    // Nothing to do
50  7 } else if (classParam.getValue().equals("xwikirenderingerror")) {
51  0 setAccumulateContent(true);
52    } else {
53  7 super.begin(context);
54    }
55    } else {
56  74 super.begin(context);
57    }
58    }
59   
 
60  170 toggle @Override
61    protected void end(TagContext context)
62    {
63  170 WikiParameter classParam = context.getParams().getParameter("class");
64  170 if (classParam != null) {
65  96 if (classParam.getValue().contains("wikigeneratedlinkcontent"))
66    {
67  37 setAccumulateContent(false);
68  59 } else if (classParam.getValue().equals("wikilink")
69    || classParam.getValue().equals("wikicreatelink")
70    || classParam.getValue().equals("wikiexternallink"))
71    {
72    // Nothing to do
73  7 } else if (classParam.getValue().equals("xwikirenderingerror")) {
74  0 setAccumulateContent(false);
75    } else {
76  7 super.end(context);
77    }
78    } else {
79  74 super.end(context);
80    }
81    }
82    }