1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.xdomxml10.internal.parser; |
21 |
|
|
22 |
|
import java.util.HashSet; |
23 |
|
import java.util.Set; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
|
28 |
|
import org.xml.sax.SAXException; |
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
31 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
32 |
|
import org.xwiki.rendering.parser.ParseException; |
33 |
|
import org.xwiki.rendering.syntax.SyntaxFactory; |
34 |
|
|
35 |
|
@Component |
36 |
|
@Named("rawtext") |
37 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.67 |
|
38 |
|
public class RawTextBlockParser extends DefaultBlockParser |
39 |
|
{ |
40 |
|
private static final Set<String> NAMES = new HashSet<String>() |
41 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
42 |
0 |
{... |
43 |
0 |
add("content"); |
44 |
0 |
add("syntax"); |
45 |
|
} |
46 |
|
}; |
47 |
|
|
48 |
|
@Inject |
49 |
|
private SyntaxFactory syntaxFactory; |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0 |
public RawTextBlockParser()... |
52 |
|
{ |
53 |
0 |
super(NAMES); |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
56 |
0 |
@Override... |
57 |
|
protected void endBlock() throws SAXException |
58 |
|
{ |
59 |
0 |
try { |
60 |
0 |
getListener().onRawText(getParameterAsString("content", ""), |
61 |
|
this.syntaxFactory.createSyntaxFromIdString(getParameterAsString("syntax", null))); |
62 |
|
} catch (ParseException e) { |
63 |
0 |
throw new SAXException("Failed to parse [syntax] parameter in rw block", e); |
64 |
|
} |
65 |
|
} |
66 |
|
} |