|
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.dto.module.SubsectionVo; |
|
22 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
|
23 |
| import org.qedeq.kernel.xml.parser.SyntaxException; |
|
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 |
27
| public SubsectionHandler(final AbstractSimpleHandler handler) {
|
|
51 |
27
| super(handler, "SUBSECTION");
|
|
52 |
27
| titleHandler = new LatexListHandler(this, "TITLE");
|
|
53 |
27
| latexHandler = new LatexListHandler(this, "TEXT");
|
|
54 |
27
| subsection = new SubsectionVo();
|
|
55 |
| } |
|
56 |
| |
|
57 |
61
| public final void init() {
|
|
58 |
61
| subsection = null;
|
|
59 |
| } |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
61
| public final Subsection getSubsection() {
|
|
67 |
61
| return subsection;
|
|
68 |
| } |
|
69 |
| |
|
70 |
174
| public final void startElement(final String name, final SimpleAttributes attributes)
|
|
71 |
| throws SyntaxException { |
|
72 |
174
| if (getStartTag().equals(name)) {
|
|
73 |
61
| subsection = new SubsectionVo();
|
|
74 |
61
| subsection.setId(attributes.getString("label"));
|
|
75 |
61
| subsection.setLevel(attributes.getString("level"));
|
|
76 |
113
| } else if (titleHandler.getStartTag().equals(name)) {
|
|
77 |
52
| changeHandler(titleHandler, name, attributes);
|
|
78 |
61
| } else if (latexHandler.getStartTag().equals(name)) {
|
|
79 |
61
| changeHandler(latexHandler, name, attributes);
|
|
80 |
| } else { |
|
81 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
|
82 |
| } |
|
83 |
| } |
|
84 |
| |
|
85 |
174
| public final void endElement(final String name) throws SyntaxException {
|
|
86 |
174
| if (getStartTag().equals(name)) {
|
|
87 |
| |
|
88 |
113
| } else if (titleHandler.getStartTag().equals(name)) {
|
|
89 |
52
| subsection.setTitle(titleHandler.getLatexList());
|
|
90 |
61
| } else if (latexHandler.getStartTag().equals(name)) {
|
|
91 |
61
| subsection.setLatex(latexHandler.getLatexList());
|
|
92 |
| } else { |
|
93 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
|
94 |
| } |
|
95 |
| } |
|
96 |
| |
|
97 |
| } |