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.ChapterVo;
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 public class ChapterHandler extends AbstractSimpleHandler {
29
30
31 private final LatexListHandler titleHandler;
32
33
34 private final LatexListHandler introductionHandler;
35
36
37 private final SectionHandler sectionHandler;
38
39
40 private ChapterVo chapter;
41
42
43
44
45
46
47 public ChapterHandler(final AbstractSimpleHandler handler) {
48 super(handler, "CHAPTER");
49 titleHandler = new LatexListHandler(this, "TITLE");
50 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
51 sectionHandler = new SectionHandler(this);
52 }
53
54 public void init() {
55 chapter = null;
56 }
57
58
59
60
61
62
63 public final ChapterVo getChapter() {
64 return chapter;
65 }
66
67 public final void startElement(final String name, final SimpleAttributes attributes)
68 throws XmlSyntaxException {
69 if (getStartTag().equals(name)) {
70 chapter = new ChapterVo();
71 chapter.setNoNumber(attributes.getBoolean("noNumber"));
72 } else if (titleHandler.getStartTag().equals(name)) {
73 changeHandler(titleHandler, name, attributes);
74 } else if (introductionHandler.getStartTag().equals(name)) {
75 changeHandler(introductionHandler, name, attributes);
76 } else if (sectionHandler.getStartTag().equals(name)) {
77 changeHandler(sectionHandler, 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 chapter.setTitle(titleHandler.getLatexList());
88 } else if (introductionHandler.getStartTag().equals(name)) {
89 chapter.setIntroduction(introductionHandler.getLatexList());
90 } else if (sectionHandler.getStartTag().equals(name)) {
91 chapter.addSection(sectionHandler.getSection());
92 } else {
93 throw XmlSyntaxException.createUnexpectedTagException(name);
94 }
95 }
96
97
98 }