|
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.SectionVo; |
|
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 |
| |
|
32 |
| public final 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 |
27
| public SectionHandler(final AbstractSimpleHandler handler) {
|
|
63 |
27
| super(handler, SECTION_TAG);
|
|
64 |
27
| titleHandler = new LatexListHandler(this, TITLE_TAG);
|
|
65 |
27
| introductionHandler = new LatexListHandler(this, INTRODUCTION_TAG);
|
|
66 |
27
| subsectionListHandler = new SubsectionListHandler(this);
|
|
67 |
| } |
|
68 |
| |
|
69 |
135
| public final void init() {
|
|
70 |
135
| section = null;
|
|
71 |
| } |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
135
| public final SectionVo getSection() {
|
|
79 |
135
| return section;
|
|
80 |
| } |
|
81 |
| |
|
82 |
474
| public final void startElement(final String name, final SimpleAttributes attributes)
|
|
83 |
| throws SyntaxException { |
|
84 |
474
| if (getStartTag().equals(name)) {
|
|
85 |
135
| section = new SectionVo();
|
|
86 |
135
| section.setNoNumber(attributes.getBoolean("noNumber"));
|
|
87 |
339
| } else if (TITLE_TAG.equals(name)) {
|
|
88 |
135
| changeHandler(titleHandler, name, attributes);
|
|
89 |
204
| } else if (INTRODUCTION_TAG.equals(name)) {
|
|
90 |
134
| changeHandler(introductionHandler, name, attributes);
|
|
91 |
70
| } else if ("SUBSECTIONS".equals(name)) {
|
|
92 |
70
| changeHandler(subsectionListHandler, name, attributes);
|
|
93 |
| } else { |
|
94 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
|
95 |
| } |
|
96 |
| } |
|
97 |
| |
|
98 |
474
| public final void endElement(final String name) throws SyntaxException {
|
|
99 |
474
| if (getStartTag().equals(name)) {
|
|
100 |
| |
|
101 |
339
| } else if (TITLE_TAG.equals(name)) {
|
|
102 |
135
| section.setTitle(titleHandler.getLatexList());
|
|
103 |
204
| } else if (INTRODUCTION_TAG.equals(name)) {
|
|
104 |
134
| section.setIntroduction(introductionHandler.getLatexList());
|
|
105 |
70
| } else if ("SUBSECTIONS".equals(name)) {
|
|
106 |
70
| section.setSubsectionList(subsectionListHandler.getSubsectionList());
|
|
107 |
| } else { |
|
108 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
|
109 |
| } |
|
110 |
| } |
|
111 |
| |
|
112 |
| |
|
113 |
| } |