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