|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| XHTMLMarkerResourceReferenceSerializer | Line # 43 | 11 | 0% | 2 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (36) | |||
| Result | |||
|
1.0
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.9285714
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.9285714
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.9285714
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.9285714
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.78571427
|
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.xhtml; | |
| 21 | ||
| 22 | import java.util.Map; | |
| 23 | ||
| 24 | import javax.inject.Named; | |
| 25 | import javax.inject.Singleton; | |
| 26 | ||
| 27 | import org.xwiki.component.annotation.Component; | |
| 28 | import org.xwiki.rendering.internal.renderer.ParametersPrinter; | |
| 29 | import org.xwiki.rendering.listener.reference.ResourceReference; | |
| 30 | import org.xwiki.rendering.renderer.reference.ResourceReferenceSerializer; | |
| 31 | ||
| 32 | /** | |
| 33 | * Serialize a Resource Reference into XHTML comments using the syntax | |
| 34 | * {@code (isTyped)|-|(type)|-|(reference)|-|(parameters: key="value")}. This is used for example to save a Link or | |
| 35 | * Image Reference in XHTML Comment in the Annotated XHTML Renderer. | |
| 36 | * | |
| 37 | * @version $Id: b4adb0ac62f1180b5ad50b8f11cc92be45e73cf8 $ | |
| 38 | * @since 2.5RC1 | |
| 39 | */ | |
| 40 | @Component | |
| 41 | @Named("xhtmlmarker") | |
| 42 | @Singleton | |
| 43 | public class XHTMLMarkerResourceReferenceSerializer implements ResourceReferenceSerializer | |
| 44 | { | |
| 45 | /** | |
| 46 | * Character to separate Link reference and parameters in XHTML comments. | |
| 47 | */ | |
| 48 | private static final String COMMENT_SEPARATOR = "|-|"; | |
| 49 | ||
| 50 | /** | |
| 51 | * Used to print Link Parameters in XHTML comments. | |
| 52 | */ | |
| 53 | private ParametersPrinter parametersPrinter = new ParametersPrinter(); | |
| 54 | ||
| 55 | 60 |
@Override |
| 56 | public String serialize(ResourceReference reference) | |
| 57 | { | |
| 58 | 60 | StringBuilder buffer = new StringBuilder(); |
| 59 | ||
| 60 | // Print if the Resource Reference is typed, the Resource Reference Type and the Reference itself | |
| 61 | 60 | buffer.append(reference.isTyped()); |
| 62 | 60 | buffer.append(COMMENT_SEPARATOR); |
| 63 | 60 | buffer.append(reference.getType().getScheme()); |
| 64 | 60 | buffer.append(COMMENT_SEPARATOR); |
| 65 | 60 | buffer.append(reference.getReference()); |
| 66 | ||
| 67 | // Print Resource Reference parameters. We need to do this so that the XHTML parser doesn't have | |
| 68 | // to parse the query string to extract the parameters. Doing so could lead to false result since | |
| 69 | // for example the XHTML renderer can add a parent parameter in the query string for links to non | |
| 70 | // existing documents. | |
| 71 | // | |
| 72 | // Also note that we don't need to print Resource Reference parameters since they are added as XHTML class | |
| 73 | // attributes by the XHTML Renderer and thus the XHTML parser will be able to get them again as attributes. | |
| 74 | 60 | Map<String, String> linkReferenceParameters = reference.getParameters(); |
| 75 | 60 | if (!linkReferenceParameters.isEmpty()) { |
| 76 | 7 | buffer.append(COMMENT_SEPARATOR); |
| 77 | 7 | buffer.append(this.parametersPrinter.print(linkReferenceParameters, '\\')); |
| 78 | } | |
| 79 | ||
| 80 | 60 | return buffer.toString(); |
| 81 | } | |
| 82 | } | |
|
||||||||||||