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

File AbstractBlockParser.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
8
2
1
71
31
3
0.38
4
2
1.5

Classes

Class Line # Actions
AbstractBlockParser 39 8 0% 3 1
0.990%
 

Contributing tests

This file is covered by 57 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;
21   
22    import java.io.Reader;
23   
24    import javax.inject.Inject;
25   
26    import org.xwiki.component.manager.ComponentLookupException;
27    import org.xwiki.component.manager.ComponentManager;
28    import org.xwiki.rendering.block.XDOM;
29    import org.xwiki.rendering.parser.ParseException;
30    import org.xwiki.rendering.parser.Parser;
31    import org.xwiki.rendering.parser.StreamParser;
32   
33    /**
34    * Common code for {@link Parser} implementation that produce a {@link XDOM} from {@link StreamParser}.
35    *
36    * @version $Id: a224044087a412b988a5ebce1925d3259564e204 $
37    * @since 2.1M1
38    */
 
39    public abstract class AbstractBlockParser implements Parser
40    {
41    /**
42    * Used to lookup the {@link StreamParser} for the syntax.
43    */
44    @Inject
45    private ComponentManager componentManager;
46   
47    /**
48    * @return the {@link StreamParser} to use to parser the input content
49    */
 
50  32034 toggle protected StreamParser getStreamParser()
51    {
52  32032 StreamParser streamParser;
53  32039 try {
54  32037 streamParser = this.componentManager.getInstance(StreamParser.class, getSyntax().toIdString());
55    } catch (ComponentLookupException e) {
56  0 throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
57    }
58   
59  32041 return streamParser;
60    }
61   
 
62  32045 toggle @Override
63    public XDOM parse(Reader source) throws ParseException
64    {
65  32043 XDOMGeneratorListener listener = new XDOMGeneratorListener();
66   
67  32036 getStreamParser().parse(source, listener);
68   
69  32042 return listener.getXDOM();
70    }
71    }