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
8   66   1   8
0   26   0.12   1
1     1  
1    
 
  AbstractXWikiSyntaxRenderer       Line # 39 8 0% 1 0 100% 1.0
 
  (326)
 
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.renderer.xwiki20;
21   
22    import org.xwiki.component.phase.Initializable;
23    import org.xwiki.component.phase.InitializationException;
24    import org.xwiki.rendering.listener.chaining.BlockStateChainingListener;
25    import org.xwiki.rendering.listener.chaining.ChainingListener;
26    import org.xwiki.rendering.listener.chaining.ConsecutiveNewLineStateChainingListener;
27    import org.xwiki.rendering.listener.chaining.GroupStateChainingListener;
28    import org.xwiki.rendering.listener.chaining.ListenerChain;
29    import org.xwiki.rendering.listener.chaining.LookaheadChainingListener;
30    import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
31   
32    /**
33    * XWiki Syntax Renderer implementation common to XWiki Syntax versions greater than 2.0 (X>iki Syntax 2.0,
34    * XWiki Syntax 2.1, etc).
35    *
36    * @version $Id: 7effe3f71db1b54d901bf4df037211c20392a8c3 $
37    * @since 2.5M2
38    */
 
39    public abstract class AbstractXWikiSyntaxRenderer extends AbstractChainingPrintRenderer implements Initializable
40    {
41    /**
42    * Allows extending classes to choose which implementation to use.
43    *
44    * @param chain the rendering chain, see {@link org.xwiki.rendering.listener.chaining.ListenerChain}
45    * @return the XWiki Syntax renderer containing the implementation to use for handling the listener's events
46    */
47    protected abstract ChainingListener createXWikiSyntaxChainingRenderer(ListenerChain chain);
48   
 
49  346 toggle @Override
50    public void initialize() throws InitializationException
51    {
52  346 ListenerChain chain = new XWikiSyntaxListenerChain();
53  346 setListenerChain(chain);
54   
55    // Construct the listener chain in the right order. Listeners early in the chain are called before listeners
56    // placed later in the chain. This chain allows using several listeners that make it easier
57    // to write the XWiki Syntax chaining listener, for example for saving states (are we in a list, in a
58    // paragraph, are we starting a new line, etc).
59  346 chain.addListener(this);
60  346 chain.addListener(new LookaheadChainingListener(chain, 2));
61  346 chain.addListener(new GroupStateChainingListener(chain));
62  346 chain.addListener(new BlockStateChainingListener(chain));
63  346 chain.addListener(new ConsecutiveNewLineStateChainingListener(chain));
64  346 chain.addListener(createXWikiSyntaxChainingRenderer(chain));
65    }
66    }