|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
XWikiSyntaxResourceRenderer | Line # 39 | 26 | 0% | 10 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(43) | |||
Result | |||
0.70454544
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.59090906
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.45454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.4318182
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.38636363
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.29545453
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.29545453
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22727273
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22727273
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22727273
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22727273
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.22727273
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
org.xwiki.rendering.test.integration.RenderingTest.execute org.xwiki.rendering.test.integration.RenderingTest.execute | 1 PASS | |
0.045454547
|
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.renderer.xwiki21.reference; | |
21 | ||
22 | import java.util.Map; | |
23 | ||
24 | import org.apache.commons.lang3.StringUtils; | |
25 | import org.xwiki.rendering.internal.renderer.xwiki20.XWikiSyntaxEscapeWikiPrinter; | |
26 | import org.xwiki.rendering.internal.renderer.xwiki20.XWikiSyntaxListenerChain; | |
27 | import org.xwiki.rendering.listener.reference.AttachmentResourceReference; | |
28 | import org.xwiki.rendering.listener.reference.DocumentResourceReference; | |
29 | import org.xwiki.rendering.listener.reference.ResourceReference; | |
30 | import org.xwiki.rendering.listener.reference.ResourceType; | |
31 | import org.xwiki.rendering.renderer.reference.ResourceReferenceSerializer; | |
32 | ||
33 | /** | |
34 | * Logic to render a XWiki Link into XWiki Syntax 2.1. | |
35 | * | |
36 | * @version $Id: c96a09c1a1cd670cce022421b9f4f61b0be25798 $ | |
37 | * @since 2.5M2 | |
38 | */ | |
39 | public class XWikiSyntaxResourceRenderer | |
40 | extends org.xwiki.rendering.internal.renderer.xwiki20.reference.XWikiSyntaxResourceRenderer | |
41 | { | |
42 | /** | |
43 | * Parameter name under which to serialize the query string in XWiki Syntax 2.1. | |
44 | */ | |
45 | private static final String QUERY_STRING = "queryString"; | |
46 | ||
47 | /** | |
48 | * Parameter name under which to serialize the query string in XWiki Syntax 2.1. | |
49 | */ | |
50 | private static final String ANCHOR = "anchor"; | |
51 | ||
52 | /** | |
53 | * @param listenerChain the rendering chain | |
54 | * @param referenceSerializer the serializer implementation to use to serialize link references | |
55 | * @since 2.5RC1 | |
56 | */ | |
57 | 122 | public XWikiSyntaxResourceRenderer(XWikiSyntaxListenerChain listenerChain, |
58 | ResourceReferenceSerializer referenceSerializer) | |
59 | { | |
60 | 122 | super(listenerChain, referenceSerializer); |
61 | } | |
62 | ||
63 | 21 | @Override |
64 | protected void printParameters(XWikiSyntaxEscapeWikiPrinter printer, ResourceReference reference, | |
65 | Map<String, String> parameters) | |
66 | { | |
67 | // Print the Query String and Anchor as parameters if they're defined and if the link is a link to a document. | |
68 | 21 | boolean shouldPrintSeparator = true; |
69 | ||
70 | // The XWiki Syntax 2.1 supports two special reference parameters for document references: | |
71 | // - queryString and anchor. | |
72 | // The XWiki Syntax 2.1 supports one special reference parameters for attachment references: | |
73 | // - queryString. | |
74 | 21 | if (reference.getType().equals(ResourceType.DOCUMENT)) { |
75 | // Print first the query string | |
76 | 7 | String queryString = reference.getParameter(DocumentResourceReference.QUERY_STRING); |
77 | 7 | if (!StringUtils.isEmpty(queryString)) { |
78 | 2 | printer.print(PARAMETER_SEPARATOR); |
79 | 2 | printer.print(this.parametersPrinter.print(QUERY_STRING, queryString, '~')); |
80 | 2 | shouldPrintSeparator = false; |
81 | } | |
82 | // Then print the anchor | |
83 | 7 | String anchor = reference.getParameter(DocumentResourceReference.ANCHOR); |
84 | 7 | if (!StringUtils.isEmpty(anchor)) { |
85 | 3 | if (shouldPrintSeparator) { |
86 | 1 | printer.print(PARAMETER_SEPARATOR); |
87 | } else { | |
88 | 2 | printer.print(" "); |
89 | } | |
90 | 3 | printer.print(this.parametersPrinter.print(ANCHOR, anchor, '~')); |
91 | 3 | shouldPrintSeparator = false; |
92 | } | |
93 | 14 | } else if (reference.getType().equals(ResourceType.ATTACHMENT)) { |
94 | 6 | String queryString = reference.getParameter(AttachmentResourceReference.QUERY_STRING); |
95 | 6 | if (!StringUtils.isEmpty(queryString)) { |
96 | 1 | printer.print(PARAMETER_SEPARATOR); |
97 | 1 | printer.print(this.parametersPrinter.print(QUERY_STRING, queryString, '~')); |
98 | 1 | shouldPrintSeparator = false; |
99 | } | |
100 | } | |
101 | ||
102 | // Add all Link parameters but only if there isn't a Link Reference parameter of the same name... | |
103 | 21 | if (!parameters.isEmpty()) { |
104 | 3 | if (shouldPrintSeparator) { |
105 | 1 | printer.print(PARAMETER_SEPARATOR); |
106 | } else { | |
107 | 2 | printer.print(" "); |
108 | } | |
109 | 3 | printer.print(this.parametersPrinter.print(parameters, '~')); |
110 | } | |
111 | } | |
112 | } |
|