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.common.SyntaxException; |
21 |
| import org.qedeq.kernel.dto.module.LatexVo; |
22 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
23 |
| import org.qedeq.kernel.xml.parser.SimpleAttributes; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public 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 |
46
| public LatexHandler(final AbstractSimpleHandler handler, final String startTag) {
|
51 |
46
| super(handler, startTag);
|
52 |
| } |
53 |
| |
54 |
41
| public final void init() {
|
55 |
41
| latex = null;
|
56 |
| } |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
41
| public final LatexVo getLatex() {
|
64 |
41
| return latex;
|
65 |
| } |
66 |
| |
67 |
82
| public final void startElement(final String name, final SimpleAttributes attributes)
|
68 |
| throws SyntaxException { |
69 |
82
| if (getStartTag().equals(name)) {
|
70 |
| |
71 |
41
| } else if ("LATEX".equals(name)) {
|
72 |
41
| this.data = null;
|
73 |
41
| language = attributes.getString("language");
|
74 |
| } else { |
75 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
76 |
| } |
77 |
| } |
78 |
| |
79 |
82
| public void endElement(final String name) throws SyntaxException {
|
80 |
82
| if (getStartTag().equals(name)) {
|
81 |
| |
82 |
41
| } else if ("LATEX".equals(name)) {
|
83 |
41
| latex = new LatexVo(language, data);
|
84 |
| } else { |
85 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
86 |
| } |
87 |
| } |
88 |
| |
89 |
41
| public void characters(final String name, final String data) throws SyntaxException {
|
90 |
41
| if (getStartTag().equals(name)) {
|
91 |
| |
92 |
41
| } else if ("LATEX".equals(name)) {
|
93 |
41
| this.data = data;
|
94 |
| } else { |
95 |
0
| throw SyntaxException.createUnexpectedTextDataException(name, data);
|
96 |
| } |
97 |
| } |
98 |
| |
99 |
| } |