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.dto.module.ChapterVo; |
21 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
22 |
| import org.qedeq.kernel.xml.parser.SimpleAttributes; |
23 |
| import org.qedeq.kernel.xml.parser.SyntaxException; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public final class ChapterHandler extends AbstractSimpleHandler { |
32 |
| |
33 |
| |
34 |
| private final LatexListHandler titleHandler; |
35 |
| |
36 |
| |
37 |
| private final LatexListHandler introductionHandler; |
38 |
| |
39 |
| |
40 |
| private final SectionHandler sectionHandler; |
41 |
| |
42 |
| |
43 |
| private ChapterVo chapter; |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
27
| public ChapterHandler(final AbstractSimpleHandler handler) {
|
51 |
27
| super(handler, "CHAPTER");
|
52 |
27
| titleHandler = new LatexListHandler(this, "TITLE");
|
53 |
27
| introductionHandler = new LatexListHandler(this, "INTRODUCTION");
|
54 |
27
| sectionHandler = new SectionHandler(this);
|
55 |
| } |
56 |
| |
57 |
85
| public void init() {
|
58 |
85
| chapter = null;
|
59 |
| } |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
85
| public final ChapterVo getChapter() {
|
67 |
85
| return chapter;
|
68 |
| } |
69 |
| |
70 |
390
| public final void startElement(final String name, final SimpleAttributes attributes)
|
71 |
| throws SyntaxException { |
72 |
390
| if (getStartTag().equals(name)) {
|
73 |
85
| chapter = new ChapterVo();
|
74 |
85
| chapter.setNoNumber(attributes.getBoolean("noNumber"));
|
75 |
305
| } else if (titleHandler.getStartTag().equals(name)) {
|
76 |
85
| changeHandler(titleHandler, name, attributes);
|
77 |
220
| } else if (introductionHandler.getStartTag().equals(name)) {
|
78 |
85
| changeHandler(introductionHandler, name, attributes);
|
79 |
135
| } else if (sectionHandler.getStartTag().equals(name)) {
|
80 |
135
| changeHandler(sectionHandler, name, attributes);
|
81 |
| } else { |
82 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
83 |
| } |
84 |
| } |
85 |
| |
86 |
390
| public final void endElement(final String name) throws SyntaxException {
|
87 |
390
| if (getStartTag().equals(name)) {
|
88 |
| |
89 |
305
| } else if (titleHandler.getStartTag().equals(name)) {
|
90 |
85
| chapter.setTitle(titleHandler.getLatexList());
|
91 |
220
| } else if (introductionHandler.getStartTag().equals(name)) {
|
92 |
85
| chapter.setIntroduction(introductionHandler.getLatexList());
|
93 |
135
| } else if (sectionHandler.getStartTag().equals(name)) {
|
94 |
135
| chapter.addSection(sectionHandler.getSection());
|
95 |
| } else { |
96 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
97 |
| } |
98 |
| } |
99 |
| |
100 |
| |
101 |
| } |