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.base.module.Subsection; |
21 |
| import org.qedeq.kernel.common.SyntaxException; |
22 |
| import org.qedeq.kernel.dto.module.SubsectionVo; |
23 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
24 |
| import org.qedeq.kernel.xml.parser.SimpleAttributes; |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class SubsectionHandler extends AbstractSimpleHandler { |
34 |
| |
35 |
| |
36 |
| private final LatexListHandler titleHandler; |
37 |
| |
38 |
| |
39 |
| private final LatexListHandler latexHandler; |
40 |
| |
41 |
| |
42 |
| private SubsectionVo subsection; |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
46
| public SubsectionHandler(final AbstractSimpleHandler handler) {
|
51 |
46
| super(handler, "SUBSECTION");
|
52 |
46
| titleHandler = new LatexListHandler(this, "TITLE");
|
53 |
46
| latexHandler = new LatexListHandler(this, "TEXT");
|
54 |
46
| subsection = new SubsectionVo();
|
55 |
| } |
56 |
| |
57 |
83
| public final void init() {
|
58 |
83
| subsection = null;
|
59 |
| } |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
83
| public final Subsection getSubsection() {
|
67 |
83
| return subsection;
|
68 |
| } |
69 |
| |
70 |
236
| public final void startElement(final String name, final SimpleAttributes attributes)
|
71 |
| throws SyntaxException { |
72 |
236
| if (getStartTag().equals(name)) {
|
73 |
83
| subsection = new SubsectionVo();
|
74 |
83
| subsection.setId(attributes.getString("label"));
|
75 |
83
| subsection.setLevel(attributes.getString("level"));
|
76 |
153
| } else if (titleHandler.getStartTag().equals(name)) {
|
77 |
70
| changeHandler(titleHandler, name, attributes);
|
78 |
83
| } else if (latexHandler.getStartTag().equals(name)) {
|
79 |
83
| changeHandler(latexHandler, name, attributes);
|
80 |
| } else { |
81 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
82 |
| } |
83 |
| } |
84 |
| |
85 |
236
| public final void endElement(final String name) throws SyntaxException {
|
86 |
236
| if (getStartTag().equals(name)) {
|
87 |
| |
88 |
153
| } else if (titleHandler.getStartTag().equals(name)) {
|
89 |
70
| subsection.setTitle(titleHandler.getLatexList());
|
90 |
83
| } else if (latexHandler.getStartTag().equals(name)) {
|
91 |
83
| subsection.setLatex(latexHandler.getLatexList());
|
92 |
| } else { |
93 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
94 |
| } |
95 |
| } |
96 |
| |
97 |
| } |