1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.xml.handler.parser; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import javax.xml.parsers.ParserConfigurationException; |
22 |
|
|
23 |
|
import org.qedeq.base.trace.Trace; |
24 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
25 |
|
import org.qedeq.kernel.se.common.ModuleService; |
26 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
27 |
|
import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler; |
28 |
|
import org.qedeq.kernel.xml.parser.SaxParser; |
29 |
|
import org.xml.sax.SAXException; |
30 |
|
import org.xml.sax.SAXParseException; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 10 |
Complexity Density: 0.4 |
|
38 |
|
public final class LoadXmlOperatorListUtility implements ModuleService { |
39 |
|
|
40 |
|
|
41 |
|
private static final Class CLASS = LoadXmlOperatorListUtility.class; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
46 |
0
|
private LoadXmlOperatorListUtility() {... |
47 |
|
|
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@param |
55 |
|
@return |
56 |
|
@throws |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.27 |
|
58 |
0
|
public static List getOperatorList(final InternalKernelServices services, final File from)... |
59 |
|
throws SourceFileExceptionList { |
60 |
0
|
final String method = "List getOperatorList(String)"; |
61 |
0
|
final LoadXmlOperatorListUtility util = new LoadXmlOperatorListUtility(); |
62 |
0
|
try { |
63 |
0
|
Trace.begin(CLASS, method); |
64 |
0
|
Trace.param(CLASS, method, "from", from); |
65 |
0
|
SaxDefaultHandler handler = new SaxDefaultHandler(util); |
66 |
0
|
ParserHandler simple = new ParserHandler(handler); |
67 |
0
|
handler.setBasisDocumentHandler(simple); |
68 |
0
|
SaxParser parser = new SaxParser(util, handler); |
69 |
0
|
parser.parse(from, null); |
70 |
0
|
return simple.getOperators(); |
71 |
|
} catch (RuntimeException e) { |
72 |
0
|
Trace.fatal(CLASS, "Programming error.", method, e); |
73 |
0
|
throw services.createSourceFileExceptionList( |
74 |
|
ParserErrors.PARSER_PROGRAMMING_ERROR_CODE, |
75 |
|
ParserErrors.PARSER_PROGRAMMING_ERROR_TEXT, |
76 |
|
"" + from, e); |
77 |
|
} catch (ParserConfigurationException e) { |
78 |
0
|
Trace.fatal(CLASS, "Parser configuration error.", method, e); |
79 |
0
|
throw services.createSourceFileExceptionList( |
80 |
|
ParserErrors.PARSER_CONFIGURATION_ERROR_CODE, |
81 |
|
ParserErrors.PARSER_CONFIGURATION_ERROR_TEXT, |
82 |
|
"" + from, e); |
83 |
|
} catch (final SAXParseException e) { |
84 |
0
|
Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e); |
85 |
0
|
throw services.createSourceFileExceptionList( |
86 |
|
ParserErrors.XML_FILE_PARSING_FAILED_CODE, |
87 |
|
ParserErrors.XML_FILE_PARSING_FAILED_TEXT, |
88 |
|
"" + from, e); |
89 |
|
} catch (SAXException e) { |
90 |
0
|
Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e); |
91 |
0
|
throw services.createSourceFileExceptionList( |
92 |
|
ParserErrors.XML_FILE_PARSING_FAILED_CODE, |
93 |
|
ParserErrors.XML_FILE_PARSING_FAILED_TEXT, |
94 |
|
"" + from, e); |
95 |
|
} catch (javax.xml.parsers.FactoryConfigurationError e) { |
96 |
0
|
Trace.trace(CLASS, method, e); |
97 |
0
|
throw services.createSourceFileExceptionList( |
98 |
|
ParserErrors.PARSER_FACTORY_CONFIGURATION_CODE, |
99 |
|
ParserErrors.PARSER_FACTORY_CONFIGURATION_TEXT, |
100 |
|
"" + from, new RuntimeException( |
101 |
|
ParserErrors.PARSER_FACTORY_CONFIGURATION_TEXT, e)); |
102 |
|
} finally { |
103 |
0
|
Trace.end(CLASS, method); |
104 |
|
} |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0
|
public String getServiceId() {... |
108 |
0
|
return CLASS.getName(); |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0
|
public String getServiceAction() {... |
112 |
0
|
return "Operator Loader"; |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0
|
public String getServiceDescription() {... |
116 |
0
|
return "loads XML descriptoin of mathematical operators"; |
117 |
|
} |
118 |
|
|
119 |
|
} |