1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.qedeq.kernel.xml.handler.module; |
19 |
| |
20 |
| import org.qedeq.kernel.dto.module.LatexVo; |
21 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
22 |
| import org.qedeq.kernel.xml.parser.SimpleAttributes; |
23 |
| import org.qedeq.kernel.xml.parser.SyntaxException; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public final class LatexHandler extends AbstractSimpleHandler { |
33 |
| |
34 |
| |
35 |
| private String language; |
36 |
| |
37 |
| |
38 |
| private LatexVo latex; |
39 |
| |
40 |
| |
41 |
| private String data; |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
27
| public LatexHandler(final AbstractSimpleHandler handler, final String startTag) {
|
51 |
27
| super(handler, startTag);
|
52 |
| } |
53 |
| |
54 |
26
| public final void init() {
|
55 |
26
| latex = null;
|
56 |
| } |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
26
| public final LatexVo getLatex() {
|
64 |
26
| return latex;
|
65 |
| } |
66 |
| |
67 |
52
| public final void startElement(final String name, final SimpleAttributes attributes)
|
68 |
| throws SyntaxException { |
69 |
52
| if (getStartTag().equals(name)) {
|
70 |
| |
71 |
26
| } else if ("LATEX".equals(name)) {
|
72 |
26
| this.data = null;
|
73 |
26
| language = attributes.getString("language");
|
74 |
| } else { |
75 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
76 |
| } |
77 |
| } |
78 |
| |
79 |
52
| public void endElement(final String name) throws SyntaxException {
|
80 |
52
| if (getStartTag().equals(name)) {
|
81 |
| |
82 |
26
| } else if ("LATEX".equals(name)) {
|
83 |
26
| latex = new LatexVo(language, data);
|
84 |
| } else { |
85 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
86 |
| } |
87 |
| } |
88 |
| |
89 |
26
| public void characters(final String name, final String data) throws SyntaxException {
|
90 |
26
| if (getStartTag().equals(name)) {
|
91 |
| |
92 |
26
| } else if ("LATEX".equals(name)) {
|
93 |
26
| this.data = data;
|
94 |
| } else { |
95 |
0
| throw SyntaxException.createUnexpectedTextDataException(name, data);
|
96 |
| } |
97 |
| } |
98 |
| |
99 |
| } |