1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.xml.handler.module;
17
18 import org.qedeq.kernel.se.base.module.Subsection;
19 import org.qedeq.kernel.se.dto.module.SubsectionVo;
20 import org.qedeq.kernel.xml.common.XmlSyntaxException;
21 import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
22 import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
23
24
25
26
27
28
29
30
31 public class SubsectionHandler extends AbstractSimpleHandler {
32
33
34 private final LatexListHandler titleHandler;
35
36
37 private final LatexListHandler latexHandler;
38
39
40 private SubsectionVo subsection;
41
42
43
44
45
46
47
48 public SubsectionHandler(final AbstractSimpleHandler handler) {
49 super(handler, "SUBSECTION");
50 titleHandler = new LatexListHandler(this, "TITLE");
51 latexHandler = new LatexListHandler(this, "TEXT");
52 subsection = new SubsectionVo();
53 }
54
55 public final void init() {
56 subsection = null;
57 }
58
59
60
61
62
63
64 public final Subsection getSubsection() {
65 return subsection;
66 }
67
68 public final void startElement(final String name, final SimpleAttributes attributes)
69 throws XmlSyntaxException {
70 if (getStartTag().equals(name)) {
71 subsection = new SubsectionVo();
72 subsection.setId(attributes.getString("id"));
73 subsection.setLevel(attributes.getString("level"));
74 } else if (titleHandler.getStartTag().equals(name)) {
75 changeHandler(titleHandler, name, attributes);
76 } else if (latexHandler.getStartTag().equals(name)) {
77 changeHandler(latexHandler, name, attributes);
78 } else {
79 throw XmlSyntaxException.createUnexpectedTagException(name);
80 }
81 }
82
83 public final void endElement(final String name) throws XmlSyntaxException {
84 if (getStartTag().equals(name)) {
85
86 } else if (titleHandler.getStartTag().equals(name)) {
87 subsection.setTitle(titleHandler.getLatexList());
88 } else if (latexHandler.getStartTag().equals(name)) {
89 subsection.setLatex(latexHandler.getLatexList());
90 } else {
91 throw XmlSyntaxException.createUnexpectedTagException(name);
92 }
93 }
94
95 }