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

File GroupStateChainingListener.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

0
7
5
1
69
30
5
0.71
1.4
5
1

Classes

Class Line # Actions
GroupStateChainingListener 33 7 0% 5 4
0.666666766.7%
 

Contributing tests

This file is covered by 278 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.listener.chaining;
21   
22    import java.util.Map;
23   
24    /**
25    * Provides information on whether we're inside a group. Note that this listener is separated from the
26    * {@link org.xwiki.rendering.listener.chaining.BlockStateChainingListener} class because we don't want this listener to
27    * be stackable (since we need to create new instance of stackable listeners to reset states when we encounter a begin
28    * group event but we also need to know we're inside a group).
29    *
30    * @version $Id: 4e8c71efb0b8b87ec448f1f91983d37d5dde3871 $
31    * @since 1.8.3
32    */
 
33    public class GroupStateChainingListener extends AbstractChainingListener
34    {
35    private int groupDepth;
36   
 
37  334 toggle public GroupStateChainingListener(ListenerChain listenerChain)
38    {
39  334 setListenerChain(listenerChain);
40    }
41   
 
42  0 toggle public int getDocumentDepth()
43    {
44  0 return this.groupDepth;
45    }
46   
 
47  0 toggle public boolean isInGroup()
48    {
49  0 return this.groupDepth > 0;
50    }
51   
52    // Events
53   
 
54  29 toggle @Override
55    public void beginGroup(Map<String, String> parameters)
56    {
57  29 ++this.groupDepth;
58   
59  29 super.beginGroup(parameters);
60    }
61   
 
62  29 toggle @Override
63    public void endGroup(Map<String, String> parameters)
64    {
65  29 super.endGroup(parameters);
66   
67  29 --this.groupDepth;
68    }
69    }