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.dto.module.SectionVo;
19 import org.qedeq.kernel.xml.common.XmlSyntaxException;
20 import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21 import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22
23
24
25
26
27
28
29
30 public class SectionHandler extends AbstractSimpleHandler {
31
32
33 public static final String INTRODUCTION_TAG = "INTRODUCTION";
34
35
36 public static final String SECTION_TAG = "SECTION";
37
38
39 public static final String TITLE_TAG = "TITLE";
40
41
42 private final LatexListHandler titleHandler;
43
44
45 private final LatexListHandler introductionHandler;
46
47
48 private final SubsectionListHandler subsectionListHandler;
49
50
51 private SectionVo section;
52
53
54
55
56
57
58
59
60 public SectionHandler(final AbstractSimpleHandler handler) {
61 super(handler, SECTION_TAG);
62 titleHandler = new LatexListHandler(this, TITLE_TAG);
63 introductionHandler = new LatexListHandler(this, INTRODUCTION_TAG);
64 subsectionListHandler = new SubsectionListHandler(this);
65 }
66
67 public final void init() {
68 section = null;
69 }
70
71
72
73
74
75
76 public final SectionVo getSection() {
77 return section;
78 }
79
80 public final void startElement(final String name, final SimpleAttributes attributes)
81 throws XmlSyntaxException {
82 if (getStartTag().equals(name)) {
83 section = new SectionVo();
84 section.setNoNumber(attributes.getBoolean("noNumber"));
85 } else if (TITLE_TAG.equals(name)) {
86 changeHandler(titleHandler, name, attributes);
87 } else if (INTRODUCTION_TAG.equals(name)) {
88 changeHandler(introductionHandler, name, attributes);
89 } else if ("SUBSECTIONS".equals(name)) {
90 changeHandler(subsectionListHandler, name, attributes);
91 } else {
92 throw XmlSyntaxException.createUnexpectedTagException(name);
93 }
94 }
95
96 public final void endElement(final String name) throws XmlSyntaxException {
97 if (getStartTag().equals(name)) {
98
99 } else if (TITLE_TAG.equals(name)) {
100 section.setTitle(titleHandler.getLatexList());
101 } else if (INTRODUCTION_TAG.equals(name)) {
102 section.setIntroduction(introductionHandler.getLatexList());
103 } else if ("SUBSECTIONS".equals(name)) {
104 section.setSubsectionList(subsectionListHandler.getSubsectionList());
105 } else {
106 throw XmlSyntaxException.createUnexpectedTagException(name);
107 }
108 }
109
110
111 }