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
23   103   11   4.6
12   61   0.48   5
5     2.2  
1    
 
  DivisionTagHandler       Line # 32 23 0% 11 2 95% 0.95
 
  (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.wikimodel.xhtml.handler;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import org.xwiki.rendering.wikimodel.WikiParameter;
26    import org.xwiki.rendering.wikimodel.xhtml.impl.XhtmlHandler.TagStack.TagContext;
27   
28    /**
29    * @version $Id: 283d8973e3eadc7b22bbcb4bd68beddd16ba563d $
30    * @since 4.0M1
31    */
 
32    public class DivisionTagHandler extends TagHandler
33    {
 
34  528 toggle public DivisionTagHandler()
35    {
36  528 super(true, false, true);
37    }
38   
 
39  86 toggle @Override
40    public boolean isBlockHandler(TagContext context)
41    {
42  86 WikiParameter param = context.getParams().getParameter("class");
43  86 if (param != null) {
44  34 List<String> classes = Arrays.asList(param.getValue().split(" "));
45   
46  34 if (classes.contains("wikimodel-emptyline")) {
47  28 return true;
48    }
49    }
50   
51  58 return false;
52    }
53   
54    /**
55    * @return the class used to indicate the division block is an embedded
56    * document. Note that use a method instead of a static private
57    * String field so that user code can override the class name.
58    */
 
59  0 toggle protected String getDocumentClass()
60    {
61  0 return "wikimodel-document";
62    }
63   
 
64  43 toggle @Override
65    protected void begin(TagContext context)
66    {
67  43 WikiParameter param = context.getParams().getParameter("class");
68  43 if (param != null) {
69  17 List<String> classes = Arrays.asList(param.getValue().split(" "));
70   
71    // Check if we have a div meaning an empty line between block
72  17 if (classes.contains("wikimodel-emptyline")) {
73  14 int value = (Integer) context.getTagStack().getStackParameter(
74    "emptyLinesCount");
75  14 value++;
76  14 context.getTagStack().setStackParameter(
77    "emptyLinesCount",
78    value);
79    } else {
80    // Consider that we're inside an embedded document
81  3 beginDocument(context, context.getParams());
82    }
83    } else {
84    // Consider that we're inside an embedded document
85  26 beginDocument(context, context.getParams());
86    }
87    }
88   
 
89  43 toggle @Override
90    protected void end(TagContext context)
91    {
92  43 WikiParameter param = context.getParams().getParameter("class");
93  43 if (param != null) {
94  17 List<String> classes = Arrays.asList(param.getValue().split(" "));
95   
96  17 if (!classes.contains("wikimodel-emptyline")) {
97  3 endDocument(context);
98    }
99    } else {
100  26 endDocument(context);
101    }
102    }
103    }