1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.renderer.xwiki21.reference; |
21 |
|
|
22 |
|
import javax.inject.Named; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.rendering.internal.parser.reference.DefaultResourceReferenceParser; |
27 |
|
import org.xwiki.rendering.internal.parser.reference.InterWikiResourceReferenceTypeParser; |
28 |
|
import org.xwiki.rendering.listener.reference.InterWikiResourceReference; |
29 |
|
import org.xwiki.rendering.listener.reference.ResourceReference; |
30 |
|
import org.xwiki.rendering.renderer.reference.ResourceReferenceTypeSerializer; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
38 |
|
@Component |
39 |
|
@Named("xwiki/2.1/interwiki") |
40 |
|
@Singleton |
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 2 |
Complexity Density: 0.22 |
|
41 |
|
public class InterWikiReferenceTypeSerializer implements ResourceReferenceTypeSerializer |
42 |
|
{ |
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
43 |
2
|
@Override... |
44 |
|
public String serialize(ResourceReference reference) |
45 |
|
{ |
46 |
2
|
StringBuilder result = new StringBuilder(); |
47 |
2
|
result.append(reference.getType().getScheme()); |
48 |
2
|
result.append(DefaultResourceReferenceParser.TYPE_SEPARATOR); |
49 |
2
|
String interWikiAlias = reference.getParameter(InterWikiResourceReference.INTERWIKI_ALIAS); |
50 |
2
|
if (interWikiAlias != null) { |
51 |
2
|
result.append(interWikiAlias); |
52 |
2
|
result.append(InterWikiResourceReferenceTypeParser.INTERWIKI_ALIAS_SEPARATOR); |
53 |
|
} |
54 |
2
|
result.append(reference.getReference()); |
55 |
2
|
return result.toString(); |
56 |
|
} |
57 |
|
} |