|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
XWiki21XWikiGeneratorListener | Line # 41 | 14 | 0% | 8 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(29) | |||
Result | |||
0.8888889
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.8888889
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.8888889
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.5185185
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.4814815
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.44444445
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.37037036
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.37037036
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.37037036
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.37037036
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.37037036
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22222222
|
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.xwiki21; | |
21 | ||
22 | import java.util.Map; | |
23 | ||
24 | import org.xwiki.rendering.internal.parser.wikimodel.DefaultXWikiGeneratorListener; | |
25 | import org.xwiki.rendering.listener.reference.DocumentResourceReference; | |
26 | import org.xwiki.rendering.listener.reference.ResourceReference; | |
27 | import org.xwiki.rendering.listener.reference.ResourceType; | |
28 | import org.xwiki.rendering.listener.Listener; | |
29 | import org.xwiki.rendering.parser.ResourceReferenceParser; | |
30 | import org.xwiki.rendering.parser.StreamParser; | |
31 | import org.xwiki.rendering.renderer.PrintRendererFactory; | |
32 | import org.xwiki.rendering.syntax.Syntax; | |
33 | import org.xwiki.rendering.util.IdGenerator; | |
34 | ||
35 | /** | |
36 | * WikiModel listener bridge for the XWiki Syntax 2.1. | |
37 | * | |
38 | * @version $Id: abe2b9cb826649d72658c5dbc7d29d950ad19427 $ | |
39 | * @since 2.5RC1 | |
40 | */ | |
41 | public class XWiki21XWikiGeneratorListener extends DefaultXWikiGeneratorListener | |
42 | { | |
43 | /** | |
44 | * Parameter name for Query String. | |
45 | */ | |
46 | private static final String QUERY_STRING = "queryString"; | |
47 | ||
48 | /** | |
49 | * Parameter name for Anchor. | |
50 | */ | |
51 | private static final String ANCHOR = "anchor"; | |
52 | ||
53 | /** | |
54 | * @param parser the parser to use to parse link labels | |
55 | * @param listener the XWiki listener to which to forward WikiModel events | |
56 | * @param linkReferenceParser the parser to parse link references | |
57 | * @param imageReferenceParser the parser to parse image references | |
58 | * @param plainRendererFactory used to generate header ids | |
59 | * @param idGenerator used to generate header ids | |
60 | * @param syntax the syntax of the parsed source | |
61 | * @since 3.0M3 | |
62 | */ | |
63 | 33 | public XWiki21XWikiGeneratorListener(StreamParser parser, Listener listener, |
64 | ResourceReferenceParser linkReferenceParser, ResourceReferenceParser imageReferenceParser, | |
65 | PrintRendererFactory plainRendererFactory, IdGenerator idGenerator, Syntax syntax) | |
66 | { | |
67 | 33 | super(parser, listener, linkReferenceParser, imageReferenceParser, plainRendererFactory, idGenerator, syntax); |
68 | } | |
69 | ||
70 | 34 | @Override |
71 | protected void onReference(ResourceReference reference, String label, boolean isFreeStandingURI, | |
72 | Map<String, String> parameters) | |
73 | { | |
74 | // Since 2.5M2, handle the special case when the link syntax used for a link to a document has the | |
75 | // query string and/or the anchor specified as parameters. This is how the XWiki Syntax 2.1 specifies | |
76 | // query string and anchor (ex: [[label>>doc:docReference||queryString="a=b" anchor="anchor"]]). | |
77 | 34 | if (reference.getType().equals(ResourceType.DOCUMENT)) { |
78 | 9 | String queryString = parameters.remove(QUERY_STRING); |
79 | 9 | if (queryString != null) { |
80 | 4 | reference.setParameter(DocumentResourceReference.QUERY_STRING, queryString); |
81 | } | |
82 | 9 | String anchor = parameters.remove(ANCHOR); |
83 | 9 | if (anchor != null) { |
84 | 5 | reference.setParameter(DocumentResourceReference.ANCHOR, anchor); |
85 | } | |
86 | } | |
87 | ||
88 | 34 | super.onReference(reference, label, isFreeStandingURI, parameters); |
89 | } | |
90 | ||
91 | 16 | @Override |
92 | protected void onImage(ResourceReference reference, boolean isFreeStandingURI, Map<String, String> parameters) | |
93 | { | |
94 | // Since 2.5M2, handle the special case when the image syntax used for an image has a query string specified. | |
95 | 16 | if (reference.getType().equals(ResourceType.ATTACHMENT)) { |
96 | 7 | String queryString = parameters.remove(QUERY_STRING); |
97 | 7 | if (queryString != null) { |
98 | 4 | reference.setParameter(DocumentResourceReference.QUERY_STRING, queryString); |
99 | } | |
100 | } | |
101 | ||
102 | 16 | super.onImage(reference, isFreeStandingURI, parameters); |
103 | } | |
104 | } |
|