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

File XWikiTableDataTagHandler.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

12
12
1
1
77
33
7
0.58
12
1
7

Classes

Class Line # Actions
XWikiTableDataTagHandler 34 12 0% 7 6
0.7676%
 

Contributing tests

This file is covered by 11 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.WikiParameters;
24    import org.xwiki.rendering.wikimodel.xhtml.handler.TableDataTagHandler;
25    import org.xwiki.rendering.wikimodel.xhtml.impl.TagContext;
26   
27    /**
28    * Override the default implementation of hte WikiModel XHTML parser for handling HTML table cells. We need to do this
29    * in order to handle clean auto generated scope attributes.
30    *
31    * @version $Id: 5983c0d0bcd2e01eabac4fd8a65de0287842c954 $
32    * @since 2.4M1
33    */
 
34    public class XWikiTableDataTagHandler extends TableDataTagHandler implements XWikiWikiModelHandler
35    {
36    /**
37    * Name of the th scope attribute.
38    */
39    private static final String TH_SCOPE = "scope";
40   
41    /**
42    * Column value of the th scope attribute.
43    */
44    private static final String TH_SCOPE_COL = "col";
45   
46    /**
47    * Row value of the th scope attribute.
48    */
49    private static final String TH_SCOPE_ROW = "row";
50   
 
51  26 toggle @Override
52    protected void begin(TagContext context)
53    {
54  26 WikiParameters parameters = context.getParams();
55   
56    // clean useless scope attributes
57  26 WikiParameter scopeParameter = parameters.getParameter(TH_SCOPE);
58   
59  26 if (scopeParameter != null) {
60  21 if (context.getScannerContext().getTableRowCounter() == 0) {
61  17 if (scopeParameter.getValue().equals(TH_SCOPE_COL)) {
62  16 parameters = parameters.remove(TH_SCOPE);
63    }
64  4 } else if (context.getScannerContext().getTableCellCounter() == 0) {
65  4 if (scopeParameter.getValue().equals(TH_SCOPE_ROW)) {
66  4 parameters = parameters.remove(TH_SCOPE);
67    }
68    } else {
69  0 if (scopeParameter.getValue().equals(TH_SCOPE_COL)) {
70  0 parameters = parameters.remove(TH_SCOPE);
71    }
72    }
73    }
74   
75  26 context.getScannerContext().beginTableCell(true, parameters);
76    }
77    }