1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.renderer.xwiki20

File AbstractXWikiSyntaxRenderer.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
2
1
77
35
2
0.22
4.5
2
1

Classes

Class Line # Actions
AbstractXWikiSyntaxRenderer 43 9 0% 2 0
1.0100%
 

Contributing tests

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