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

File XWikiDivTagHandler.java

 

Coverage histogram

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

Code metrics

4
10
3
1
81
34
5
0.5
3.33
3
1.67

Classes

Class Line # Actions
XWikiDivTagHandler 35 10 0% 5 0
1.0100%
 

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.xhtml.handler.DivisionTagHandler;
25    import org.xwiki.rendering.wikimodel.xhtml.impl.TagContext;
26    import org.xwiki.stability.Unstable;
27   
28    /**
29    * The div might contain a non generated content metadata which needs a specific processing.
30    *
31    * @version $Id: dccc6dadc4f1bc82b9bf85f0b856d5df09513838 $
32    * @since 10.10RC1
33    */
34    @Unstable
 
35    public class XWikiDivTagHandler extends DivisionTagHandler implements XWikiWikiModelHandler
36    {
37    private XWikiMacroHandler xWikiMacroHandler;
38   
39    /**
40    * Default constructor of a {@link XWikiDivTagHandler}.
41    *
42    * @param documentClass used by {@link DivisionTagHandler}
43    * @param componentManager is used to retrieved the proper parser component for serializing a non generated content
44    * @param parser the current parser is actually used to simplify the build of other parsers.
45    */
 
46  334 toggle public XWikiDivTagHandler(String documentClass, ComponentManager componentManager, XHTMLParser parser)
47    {
48  334 super(documentClass);
49  334 this.xWikiMacroHandler = new XWikiMacroHandler(componentManager, parser);
50    }
51   
 
52  53 toggle @Override
53    protected void begin(TagContext context)
54    {
55  53 boolean withNonGeneratedContent = this.xWikiMacroHandler.handleBegin(context);
56   
57    // we only go through the element if we're not in a macro, or we are in a potentially new content
58  53 if (!withNonGeneratedContent) {
59  41 super.begin(context);
60   
61    // in case of beginDocument we use a new stack of parameter, so we need to put in it the
62    // NON_GENERATED_CONTENT_STACK value, as it will be popped in end()
63  41 context.getTagStack().pushStackParameter(NON_GENERATED_CONTENT_STACK, false);
64    }
65    }
66   
67   
 
68  53 toggle @Override
69    protected void end(TagContext context)
70    {
71  53 boolean nonGeneratedContent = this.xWikiMacroHandler.handleEnd(context);
72   
73  53 if (!nonGeneratedContent) {
74  41 super.end(context);
75   
76    // we still have one non generated content value in the context,
77    // we remove it to be consistent
78  41 context.getTagStack().popStackParameter(NON_GENERATED_CONTENT_STACK);
79    }
80    }
81    }