1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.confluence; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
|
24 |
|
import org.xwiki.rendering.wikimodel.IWikiReferenceParser; |
25 |
|
import org.xwiki.rendering.wikimodel.WikiParameter; |
26 |
|
import org.xwiki.rendering.wikimodel.WikiParameters; |
27 |
|
import org.xwiki.rendering.wikimodel.WikiReference; |
28 |
|
import org.xwiki.rendering.wikimodel.impl.WikiScannerUtil; |
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
@see |
34 |
|
|
|
|
| 90.3% |
Uncovered Elements: 3 (31) |
Complexity: 4 |
Complexity Density: 0.17 |
|
35 |
|
public class ConfluenceImageWikiReferenceParser implements IWikiReferenceParser |
36 |
|
{ |
|
|
| 90% |
Uncovered Elements: 3 (30) |
Complexity: 4 |
Complexity Density: 0.17 |
|
37 |
5 |
public WikiReference parse(String str)... |
38 |
|
{ |
39 |
5 |
str = str.trim(); |
40 |
5 |
String[] array = str.split("[|]"); |
41 |
5 |
String link; |
42 |
5 |
String label; |
43 |
5 |
String tip; |
44 |
5 |
WikiParameters params; |
45 |
5 |
if (array.length == 1) { |
46 |
3 |
link = str; |
47 |
3 |
label = null; |
48 |
3 |
tip = null; |
49 |
3 |
params = WikiParameters.EMPTY; |
50 |
|
} else { |
51 |
|
|
52 |
2 |
String s = array[1].trim(); |
53 |
2 |
ArrayList<WikiParameter> kps = new ArrayList<WikiParameter>(); |
54 |
2 |
WikiScannerUtil.splitToPairs(s, kps, ","); |
55 |
2 |
params = WikiParameters.newWikiParameters(""); |
56 |
2 |
for (WikiParameter param : kps) { |
57 |
3 |
params = params.addParameter(param.getKey(), param.getValue()); |
58 |
|
} |
59 |
2 |
label = array[0].trim(); |
60 |
2 |
link = array[0].trim(); |
61 |
2 |
tip = (array.length > 2) ? array[2].trim() : null; |
62 |
|
} |
63 |
5 |
if (tip != null) { |
64 |
0 |
params = params.addParameter("title", tip); |
65 |
|
} |
66 |
5 |
WikiReference ref = new WikiReference(link, label, params); |
67 |
5 |
return ref; |
68 |
|
} |
69 |
|
} |