|
1 |
| package com.agical.rdoc.core.model.impl; |
|
2 |
| |
|
3 |
| import com.agical.rdoc.core.model.CodeFormatter; |
|
4 |
| import com.agical.rdoc.core.model.TextFormatter; |
|
5 |
| |
|
6 |
| public class XmlCodeFormatter implements CodeFormatter { |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| private static final long serialVersionUID = 1L; |
|
11 |
| |
|
12 |
| private static final String DOUBLE_QUOTE = """; |
|
13 |
| private static final String SINGLE_QUOTE = "'"; |
|
14 |
| private final TextFormatter docTextFormatter; |
|
15 |
| |
|
16 |
27
| public XmlCodeFormatter(TextFormatter docTextFormatter) {
|
|
17 |
27
| this.docTextFormatter = docTextFormatter;
|
|
18 |
| } |
|
19 |
| |
|
20 |
30
| private String emphasize(String value) {
|
|
21 |
30
| return docTextFormatter.beginEmphasis()+
|
|
22 |
| value+ |
|
23 |
| docTextFormatter.endEmphasis(); |
|
24 |
| } |
|
25 |
| |
|
26 |
22
| public String number(String number) {
|
|
27 |
22
| return number;
|
|
28 |
| } |
|
29 |
| |
|
30 |
16
| public String reservedWord(String word) {
|
|
31 |
16
| return strong(word);
|
|
32 |
| } |
|
33 |
| |
|
34 |
24
| private String strong(String word) {
|
|
35 |
24
| return docTextFormatter.beginStrong() +
|
|
36 |
| word + |
|
37 |
| docTextFormatter.endStrong(); |
|
38 |
| } |
|
39 |
| |
|
40 |
8
| public String primitive(String primitive) {
|
|
41 |
8
| return strong(primitive);
|
|
42 |
| } |
|
43 |
| |
|
44 |
869
| public String identifier(String identifer) {
|
|
45 |
869
| return identifer;
|
|
46 |
| } |
|
47 |
| |
|
48 |
222
| public String stringLiteral(String stringLiteral) {
|
|
49 |
222
| return DOUBLE_QUOTE+stringLiteral+DOUBLE_QUOTE;
|
|
50 |
| } |
|
51 |
| |
|
52 |
3
| public String charLiteral(String charLiteral) {
|
|
53 |
3
| return SINGLE_QUOTE+charLiteral+SINGLE_QUOTE;
|
|
54 |
| } |
|
55 |
| |
|
56 |
29
| public String singleLineComment(String singleLineComment) {
|
|
57 |
29
| return emphasize(singleLineComment);
|
|
58 |
| } |
|
59 |
| |
|
60 |
1
| public String formalComment(String formalComment) {
|
|
61 |
1
| return emphasize(formalComment);
|
|
62 |
| } |
|
63 |
| |
|
64 |
606
| public String newLine() {
|
|
65 |
606
| return "\n";
|
|
66 |
| } |
|
67 |
| |
|
68 |
5025
| public String space() {
|
|
69 |
5025
| return " ";
|
|
70 |
| } |
|
71 |
| |
|
72 |
63
| public String tab() {
|
|
73 |
63
| return " ";
|
|
74 |
| } |
|
75 |
| |
|
76 |
1651
| public String other(String other) {
|
|
77 |
1651
| return other;
|
|
78 |
| } |
|
79 |
| |
|
80 |
| } |