1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.listener

File SectionGeneratorListener.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

6
9
3
1
68
29
6
0.67
3
3
2

Classes

Class Line # Actions
SectionGeneratorListener 30 9 0% 6 18
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.listener;
21   
22    import java.util.Map;
23   
24    /**
25    * Automatically generate section events from header events.
26    *
27    * @version $Id: 50078dc96029c6f442a769ed751526d04c3fd625 $
28    * @since 8.2RC1
29    */
 
30    public class SectionGeneratorListener extends WrappingListener
31    {
32    private int sectionDepth = -1;
33   
34    /**
35    * @param listener the listener to wrapp
36    */
 
37  0 toggle public SectionGeneratorListener(Listener listener)
38    {
39  0 setWrappedListener(listener);
40    }
41   
 
42  0 toggle @Override
43    public void beginHeader(HeaderLevel level, String id, Map<String, String> parameters)
44    {
45    // Close sections that need to be closed
46  0 for (; this.sectionDepth >= level.ordinal(); --this.sectionDepth) {
47  0 endSection(Listener.EMPTY_PARAMETERS);
48    }
49   
50    // Open new sections
51  0 for (; this.sectionDepth < level.ordinal(); ++this.sectionDepth) {
52  0 beginSection(Listener.EMPTY_PARAMETERS);
53    }
54   
55  0 super.beginHeader(level, id, parameters);
56    }
57   
 
58  0 toggle @Override
59    public void endDocument(MetaData metadata)
60    {
61    // Close sections that need to be closed
62  0 for (; this.sectionDepth > -1; --this.sectionDepth) {
63  0 endSection(Listener.EMPTY_PARAMETERS);
64    }
65   
66  0 super.endDocument(metadata);
67    }
68    }