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.macro.id; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.rendering.block.Block; |
30 |
|
import org.xwiki.rendering.block.IdBlock; |
31 |
|
import org.xwiki.rendering.macro.AbstractMacro; |
32 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
33 |
|
import org.xwiki.rendering.macro.id.IdMacroParameters; |
34 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
@Named("id") |
45 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
46 |
|
public class IdMacro extends AbstractMacro<IdMacroParameters> |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
private static final String DESCRIPTION = |
52 |
|
"Allows putting a reference/location in a page." + " In HTML for example this is called an Anchor." |
53 |
|
+ " It allows pointing to that location, for example in links."; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
58 |
6 |
public IdMacro()... |
59 |
|
{ |
60 |
6 |
super("Id", DESCRIPTION, IdMacroParameters.class); |
61 |
|
|
62 |
|
|
63 |
6 |
setPriority(20); |
64 |
6 |
setDefaultCategory(DEFAULT_CATEGORY_NAVIGATION); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
4 |
@Override... |
68 |
|
public boolean supportsInlineMode() |
69 |
|
{ |
70 |
4 |
return true; |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
73 |
6 |
@Override... |
74 |
|
public List<Block> execute(IdMacroParameters parameters, String content, MacroTransformationContext context) |
75 |
|
throws MacroExecutionException |
76 |
|
{ |
77 |
6 |
IdBlock idBlock = new IdBlock(parameters.getName()); |
78 |
|
|
79 |
6 |
return Collections.singletonList((Block) idBlock); |
80 |
|
} |
81 |
|
} |