1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.qedeq.kernel.xml.mapper; |
19 |
|
|
20 |
|
import java.util.StringTokenizer; |
21 |
|
|
22 |
|
import org.qedeq.base.trace.Trace; |
23 |
|
import org.qedeq.base.utility.StringUtility; |
24 |
|
import org.qedeq.kernel.common.ModuleContext; |
25 |
|
import org.qedeq.kernel.xml.tracker.SimpleXPath; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@version |
49 |
|
@author |
50 |
|
@deprecated |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 153 (153) |
Complexity: 35 |
Complexity Density: 0,31 |
|
52 |
|
public final class Context2XPathOld { |
53 |
|
|
54 |
|
|
55 |
|
private static final Class CLASS = Context2XPathOld.class; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
60 |
0
|
private Context2XPathOld() {... |
61 |
|
|
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@param |
68 |
|
@return |
69 |
|
@deprecated |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0
|
public static final String getFileName(final ModuleContext context) {... |
72 |
0
|
return context.getModuleLocation().toString(); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@param |
79 |
|
@return |
80 |
|
@deprecated |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 134 (134) |
Complexity: 30 |
Complexity Density: 0,29 |
|
82 |
0
|
public static final String getXPath(final ModuleContext context) {... |
83 |
0
|
final String method = "getXPath(String)"; |
84 |
0
|
String xpath = context.getLocationWithinModule(); |
85 |
0
|
Trace.param(CLASS, method, "context", xpath); |
86 |
0
|
xpath = StringUtility.replace(xpath, ".get(", "["); |
87 |
0
|
xpath = StringUtility.replace(xpath, "()", ""); |
88 |
0
|
xpath = StringUtility.replace(xpath, ")", "]"); |
89 |
0
|
xpath = StringUtility.replace(xpath, ".get", "/"); |
90 |
0
|
xpath = StringUtility.replace(xpath, "get", "/Qedeq/"); |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
0
|
xpath = StringUtility.replace(xpath, "Title[", "Title/Latex["); |
96 |
|
|
97 |
0
|
xpath = StringUtility.replace(xpath, "PredicateDefinition", "DEFINITION_PREDICATE"); |
98 |
0
|
xpath = StringUtility.replace(xpath, "FunctionDefinition", "DEFINITION_FUNCTION"); |
99 |
0
|
xpath = StringUtility.replace(xpath, "AuthorList[", "Authors/Author["); |
100 |
0
|
xpath = StringUtility.replace(xpath, "ImportList[", "Imports/Import["); |
101 |
0
|
xpath = StringUtility.replace(xpath, "LiteratureItemList[", "BIBLIOGRAPHY/ITEM["); |
102 |
0
|
xpath = StringUtility.replace(xpath, "LiteratureItemList", "BIBLIOGRAPHY"); |
103 |
0
|
xpath = StringUtility.replace(xpath, "/Item[", "/Latex["); |
104 |
0
|
xpath = StringUtility.replace(xpath, "/Item", "/Latex"); |
105 |
0
|
xpath = StringUtility.replace(xpath, "UsedByList[", "UsedBy/Specification["); |
106 |
0
|
xpath = StringUtility.replace(xpath, "ChapterList[", "Chapter["); |
107 |
0
|
xpath = StringUtility.replace(xpath, "AuthorList[", "Author["); |
108 |
0
|
xpath = StringUtility.replace(xpath, "AuthorList", "Authors"); |
109 |
0
|
xpath = StringUtility.replace(xpath, "ImportList", "Imports"); |
110 |
0
|
xpath = StringUtility.replace(xpath, "LocationList", "Locations"); |
111 |
0
|
xpath = StringUtility.replace(xpath, "LinkList[", "Link["); |
112 |
0
|
xpath = StringUtility.replace(xpath, "SectionList[", "Section["); |
113 |
0
|
xpath = StringUtility.replace(xpath, "SubsectionList", "Subsections/*"); |
114 |
0
|
xpath = StringUtility.replace(xpath, "VariableList", "VARLIST/*"); |
115 |
0
|
xpath = StringUtility.replace(xpath, "ProofList[", "PROOF["); |
116 |
0
|
xpath = StringUtility.replace(xpath, "ProofList", "PROOF"); |
117 |
0
|
xpath = StringUtility.replace(xpath, "/NodeType", ""); |
118 |
0
|
xpath = StringUtility.replace(xpath, "Summary", "Abstract/Latex"); |
119 |
0
|
xpath = StringUtility.replace(xpath, "Introduction", "Introduction/Latex"); |
120 |
0
|
xpath = StringUtility.replace(xpath, "PrecedingText", "PRECEDING/Latex"); |
121 |
0
|
xpath = StringUtility.replace(xpath, "SucceedingText", "SUCCEEDING/Latex"); |
122 |
0
|
xpath = StringUtility.replace(xpath, "Description[", "Description/Latex["); |
123 |
0
|
xpath = StringUtility.replace(xpath, "Proposition", "Theorem"); |
124 |
0
|
xpath = StringUtility.replace(xpath, "Formula/Element/", "Formula/*/"); |
125 |
0
|
xpath = StringUtility.replace(xpath, "Element", "*"); |
126 |
|
|
127 |
0
|
xpath = StringUtility.replace(xpath, "/NonFormalProof[", "/Latex["); |
128 |
0
|
xpath = StringUtility.replace(xpath, "/NonFormalProof", "/Latex"); |
129 |
|
|
130 |
0
|
xpath = StringUtility.replace(xpath, "/List", ""); |
131 |
0
|
xpath = StringUtility.replace(xpath, "List", ""); |
132 |
0
|
xpath = StringUtility.replace(xpath, "(", "["); |
133 |
0
|
xpath = xpath.toUpperCase(); |
134 |
|
|
135 |
0
|
xpath = incrementNumbers(xpath); |
136 |
|
|
137 |
|
|
138 |
0
|
SimpleXPath sxp = new SimpleXPath(xpath); |
139 |
|
|
140 |
0
|
final String beforeLast = sxp.getBeforeLastElement(); |
141 |
0
|
final String last = sxp.getLastElement(); |
142 |
0
|
if ("EMAIL".equals(last)) { |
143 |
0
|
sxp.deleteLastElement(); |
144 |
0
|
sxp.setAttribute("email"); |
145 |
0
|
} else if ("LABEL".equals(last)) { |
146 |
0
|
sxp.deleteLastElement(); |
147 |
0
|
sxp.setAttribute("label"); |
148 |
0
|
} else if ("ID".equals(last)) { |
149 |
0
|
sxp.deleteLastElement(); |
150 |
0
|
sxp.setAttribute("id"); |
151 |
0
|
} else if ("SPECIFICATION".equals(beforeLast) && "NAME".equals(last)) { |
152 |
0
|
sxp.deleteLastElement(); |
153 |
0
|
sxp.setAttribute("name"); |
154 |
0
|
} else if ("SPECIFICATION".equals(beforeLast) && "RULEVERSION".equals(last)) { |
155 |
0
|
sxp.deleteLastElement(); |
156 |
0
|
sxp.setAttribute("ruleVersion"); |
157 |
0
|
} else if ("CHAPTER".equals(beforeLast) && "NONUMBER".equals(last)) { |
158 |
0
|
sxp.deleteLastElement(); |
159 |
0
|
sxp.setAttribute("noNumber"); |
160 |
0
|
} else if ("SECTION".equals(beforeLast) && "NONUMBER".equals(last)) { |
161 |
0
|
sxp.deleteLastElement(); |
162 |
0
|
sxp.setAttribute("noNumber"); |
163 |
0
|
} else if ("*".equals(beforeLast) && "LATEX".equals(last)) { |
164 |
0
|
sxp.deleteLastElement(); |
165 |
0
|
sxp.addElement("TEXT"); |
166 |
0
|
sxp.addElement("LATEX"); |
167 |
0
|
} else if ("DEFINITION_PREDICATE".equals(beforeLast) && "ARGUMENTNUMBER".equals(last)) { |
168 |
0
|
sxp.deleteLastElement(); |
169 |
0
|
sxp.setAttribute("arguments"); |
170 |
0
|
} else if ("DEFINITION_PREDICATE".equals(beforeLast) && "NAME".equals(last)) { |
171 |
0
|
sxp.deleteLastElement(); |
172 |
0
|
sxp.setAttribute("name"); |
173 |
0
|
} else if ("DEFINITION_FUNCTION".equals(beforeLast) && "ARGUMENTNUMBER".equals(last)) { |
174 |
0
|
sxp.deleteLastElement(); |
175 |
0
|
sxp.setAttribute("arguments"); |
176 |
0
|
} else if ("DEFINITION_FUNCTION".equals(beforeLast) && "NAME".equals(last)) { |
177 |
0
|
sxp.deleteLastElement(); |
178 |
0
|
sxp.setAttribute("name"); |
179 |
0
|
} else if ("RULE".equals(beforeLast) && "NAME".equals(last)) { |
180 |
0
|
sxp.deleteLastElement(); |
181 |
0
|
sxp.setAttribute("name"); |
182 |
0
|
} else if ("*".equals(beforeLast) && "LEVEL".equals(last)) { |
183 |
0
|
sxp.deleteLastElement(); |
184 |
0
|
sxp.setAttribute("level"); |
185 |
0
|
} else if ("*".equals(beforeLast) && "NONUMBER".equals(last)) { |
186 |
0
|
sxp.deleteLastElement(); |
187 |
0
|
sxp.setAttribute("noNumber"); |
188 |
0
|
} else if ("*".equals(beforeLast) && "NAME".equals(last)) { |
189 |
0
|
final int len = sxp.getElementOccurrence(sxp.size() - 1); |
190 |
0
|
sxp.deleteLastElement(); |
191 |
0
|
sxp.addElement("NAME"); |
192 |
0
|
sxp.addElement("LATEX", len); |
193 |
|
} |
194 |
|
|
195 |
0
|
xpath = sxp.toString(); |
196 |
0
|
Trace.param(CLASS, method, "xpath", xpath); |
197 |
0
|
return xpath; |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
@return |
205 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0,3 |
|
206 |
0
|
private static String incrementNumbers(final String xpath) {... |
207 |
0
|
final StringTokenizer tokenizer = new StringTokenizer(xpath, "/", true); |
208 |
0
|
String newXpath = ""; |
209 |
0
|
while (tokenizer.hasMoreTokens()) { |
210 |
0
|
String token = tokenizer.nextToken(); |
211 |
0
|
if (token.indexOf('[') >= 0) { |
212 |
0
|
final StringTokenizer getnu = new StringTokenizer(token, "[]"); |
213 |
0
|
newXpath += getnu.nextToken() + "["; |
214 |
0
|
newXpath += ((new Integer(getnu.nextToken())).intValue() + 1) + "]"; |
215 |
|
} else { |
216 |
0
|
newXpath += token; |
217 |
|
} |
218 |
|
} |
219 |
0
|
return newXpath; |
220 |
|
} |
221 |
|
|
222 |
|
} |