1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.parser.xhtml.wikimodel

File XWikiSpanTagHandler.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

20
24
3
1
110
64
17
0.71
8
3
5.67

Classes

Class Line # Actions
XWikiSpanTagHandler 36 24 0% 17 4
0.914893691.5%
 

Contributing tests

This file is covered by 332 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.component.manager.ComponentManager;
23    import org.xwiki.rendering.internal.parser.xhtml.XHTMLParser;
24    import org.xwiki.rendering.wikimodel.WikiParameter;
25    import org.xwiki.rendering.wikimodel.WikiParameters;
26    import org.xwiki.rendering.wikimodel.xhtml.handler.SpanTagHandler;
27    import org.xwiki.rendering.wikimodel.xhtml.impl.TagContext;
28   
29    /**
30    * Handle XWiki span elements (we need to ensure we skip link content when we generate them and also skip the spans for
31    * the "?" for links pointing to non existing pages).
32    *
33    * @version $Id: c65f84e5ba23a74a215c1d2e38558f558f5a63ff $
34    * @since 1.7M1
35    */
 
36    public class XWikiSpanTagHandler extends SpanTagHandler implements XWikiWikiModelHandler
37    {
38   
39    private XWikiMacroHandler xWikiMacroHandler;
40   
41    /**
42    * Default constructor of a {@link XWikiSpanTagHandler}.
43    *
44    * @param componentManager is used to retrieved the proper parser component for serializing a non generated content
45    * @param parser the current parser is actually used to simplify the build of other parsers.
46    * @since 10.10RC1
47    */
 
48  334 toggle public XWikiSpanTagHandler(ComponentManager componentManager, XHTMLParser parser)
49    {
50  334 this.xWikiMacroHandler = new XWikiMacroHandler(componentManager, parser);
51    }
52   
 
53  164 toggle @Override
54    protected void begin(TagContext context)
55    {
56  164 WikiParameters params = context.getParams();
57  164 boolean withNonGeneratedContent = this.xWikiMacroHandler.handleBegin(context);
58   
59    // we only go through the element if we're not in a macro, or we are in a potentially new content
60  164 if (!withNonGeneratedContent) {
61    // If we're on a span for unknown links then skip the event for its content.
62    // Ex: <a href="..."><span class="wikicreatelinktext">...</span><span class="wikicreatelinkqm">?</span></a>
63  161 WikiParameter classParam = params.getParameter("class");
64  161 if (classParam != null) {
65  96 if (classParam.getValue().contains("wikigeneratedlinkcontent"))
66    {
67  37 setAccumulateContent(true);
68  59 } else if ("wikilink".equals(classParam.getValue())
69    || "wikicreatelink".equals(classParam.getValue())
70    || "wikiexternallink".equals(classParam.getValue()))
71    {
72    // Nothing to do
73  9 } else if ("xwikirenderingerror".equals(classParam.getValue())) {
74  0 setAccumulateContent(true);
75    } else {
76  9 super.begin(context);
77    }
78    } else {
79  65 super.begin(context);
80    }
81    }
82    }
83   
 
84  164 toggle @Override
85    protected void end(TagContext context)
86    {
87  164 boolean nonGeneratedContent = this.xWikiMacroHandler.handleEnd(context);
88   
89  164 if (!nonGeneratedContent) {
90  161 WikiParameter classParam = context.getParams().getParameter("class");
91  161 if (classParam != null) {
92  96 if (classParam.getValue().contains("wikigeneratedlinkcontent"))
93    {
94  37 setAccumulateContent(false);
95  59 } else if ("wikilink".equals(classParam.getValue())
96    || "wikicreatelink".equals(classParam.getValue())
97    || "wikiexternallink".equals(classParam.getValue()))
98    {
99    // Nothing to do
100  9 } else if ("xwikirenderingerror".equals(classParam.getValue())) {
101  0 setAccumulateContent(false);
102    } else {
103  9 super.end(context);
104    }
105    } else {
106  65 super.end(context);
107    }
108    }
109    }
110    }