|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AbstractBlockParser | Line # 39 | 8 | 0% | 3 | 1 | 90% |
0.9
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(2) | |||
Result | |||
0.9
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.9
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
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: ac43bf2ab58bd1d3677c381498d0a6a2a7b056ed $ | |
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 | 53 | protected StreamParser getStreamParser() |
51 | { | |
52 | 53 | StreamParser streamParser; |
53 | 53 | try { |
54 | 53 | streamParser = this.componentManager.lookup(StreamParser.class, getSyntax().toIdString()); |
55 | } catch (ComponentLookupException e) { | |
56 | 0 | throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e); |
57 | } | |
58 | ||
59 | 53 | return streamParser; |
60 | } | |
61 | ||
62 | 53 | @Override |
63 | public XDOM parse(Reader source) throws ParseException | |
64 | { | |
65 | 53 | XDOMGeneratorListener listener = new XDOMGeneratorListener(); |
66 | ||
67 | 53 | getStreamParser().parse(source, listener); |
68 | ||
69 | 53 | return listener.getXDOM(); |
70 | } | |
71 | } |
|