1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.block; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import org.xwiki.component.manager.ComponentLookupException; |
25 |
|
import org.xwiki.component.manager.ComponentManager; |
26 |
|
import org.xwiki.rendering.block.match.MetadataBlockMatcher; |
27 |
|
import org.xwiki.rendering.listener.MetaData; |
28 |
|
import org.xwiki.rendering.renderer.BlockRenderer; |
29 |
|
import org.xwiki.rendering.renderer.printer.DefaultWikiPrinter; |
30 |
|
import org.xwiki.rendering.renderer.printer.WikiPrinter; |
31 |
|
import org.xwiki.rendering.syntax.Syntax; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
|
37 |
|
@since |
38 |
|
@version |
39 |
|
|
|
|
| 93.5% |
Uncovered Elements: 2 (31) |
Complexity: 10 |
Complexity Density: 0.53 |
|
40 |
|
public class ExpandedMacroBlock extends MacroBlock |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
private final BlockRenderer contentRenderer; |
46 |
|
|
47 |
|
|
48 |
|
@link |
49 |
|
|
50 |
|
private final ComponentManager componentManager; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
@param |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
4 |
public ExpandedMacroBlock(String id, Map<String, String> parameters, BlockRenderer contentRenderer, boolean inline)... |
61 |
|
{ |
62 |
4 |
this(id, parameters, contentRenderer, inline, null); |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
@param |
70 |
|
@param |
71 |
|
@param |
72 |
|
@param |
73 |
|
|
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
75 |
6 |
public ExpandedMacroBlock(String id, Map<String, String> parameters, BlockRenderer contentRenderer, boolean inline,... |
76 |
|
ComponentManager componentManager) |
77 |
|
{ |
78 |
6 |
super(id, parameters, inline); |
79 |
6 |
this.contentRenderer = contentRenderer; |
80 |
6 |
this.componentManager = componentManager; |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
83 |
3 |
@Override... |
84 |
|
public String getContent() |
85 |
|
{ |
86 |
|
|
87 |
3 |
WikiPrinter printer = new DefaultWikiPrinter(); |
88 |
3 |
XDOM xdom; |
89 |
|
|
90 |
3 |
if (getChildren().size() == 1 && getChildren().get(0) instanceof XDOM) { |
91 |
1 |
xdom = (XDOM) getChildren().get(0); |
92 |
|
} else { |
93 |
2 |
xdom = new XDOM(getChildren()); |
94 |
|
} |
95 |
3 |
getContentRenderer().render(xdom, printer); |
96 |
3 |
return printer.toString(); |
97 |
|
} |
98 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
99 |
3 |
private BlockRenderer getContentRenderer()... |
100 |
|
{ |
101 |
3 |
if (this.componentManager != null) { |
102 |
1 |
MetaDataBlock metaDataBlock = |
103 |
|
getFirstBlock(new MetadataBlockMatcher(MetaData.SYNTAX), Axes.ANCESTOR_OR_SELF); |
104 |
1 |
if (metaDataBlock != null) { |
105 |
1 |
Syntax syntax = (Syntax) metaDataBlock.getMetaData().getMetaData(MetaData.SYNTAX); |
106 |
1 |
if (this.componentManager.hasComponent(BlockRenderer.class, syntax.toIdString())) { |
107 |
1 |
try { |
108 |
1 |
return this.componentManager.getInstance(BlockRenderer.class, syntax.toIdString()); |
109 |
|
} catch (ComponentLookupException e) { |
110 |
|
|
111 |
|
} |
112 |
|
} |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
2 |
return this.contentRenderer; |
117 |
|
} |
118 |
|
} |