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.HeaderVo;
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 HeaderHandler extends AbstractSimpleHandler {
31
32
33 private HeaderVo header;
34
35
36 private final SpecificationHandler specificationHandler;
37
38
39 private final LatexListHandler titleHandler;
40
41
42 private final LatexListHandler abstractHandler;
43
44
45 private final AuthorListHandler authorListHandler;
46
47
48 private final ImportListHandler importListHandler;
49
50
51 private final UsedByListHandler usedbyListHandler;
52
53
54
55
56
57
58
59 public HeaderHandler(final AbstractSimpleHandler handler) {
60 super(handler, "HEADER");
61 titleHandler = new LatexListHandler(this, "TITLE");
62 abstractHandler = new LatexListHandler(this, "ABSTRACT");
63 specificationHandler = new SpecificationHandler(this);
64 authorListHandler = new AuthorListHandler(this);
65 importListHandler = new ImportListHandler(this);
66 usedbyListHandler = new UsedByListHandler(this);
67 }
68
69 public final void init() {
70 header = null;
71 }
72
73
74
75
76
77
78 public final HeaderVo getHeader() {
79 return header;
80 }
81
82 public final void startElement(final String name, final SimpleAttributes attributes)
83 throws XmlSyntaxException {
84 if (getStartTag().equals(name)) {
85 header = new HeaderVo();
86 header.setEmail(attributes.getString("email"));
87 } else if (specificationHandler.getStartTag().equals(name)) {
88 changeHandler(specificationHandler, name, attributes);
89 } else if (titleHandler.getStartTag().equals(name)) {
90 changeHandler(titleHandler, name, attributes);
91 } else if (abstractHandler.getStartTag().equals(name)) {
92 changeHandler(abstractHandler, name, attributes);
93 } else if (authorListHandler.getStartTag().equals(name)) {
94 changeHandler(authorListHandler, name, attributes);
95 } else if (importListHandler.getStartTag().equals(name)) {
96 changeHandler(importListHandler, name, attributes);
97 } else if (usedbyListHandler.getStartTag().equals(name)) {
98 changeHandler(usedbyListHandler, name, attributes);
99 } else {
100 throw XmlSyntaxException.createUnexpectedTagException(name);
101 }
102 }
103
104 public final void endElement(final String name) throws XmlSyntaxException {
105 if (getStartTag().equals(name)) {
106
107 } else if (specificationHandler.getStartTag().equals(name)) {
108 header.setSpecification(specificationHandler.getSpecification());
109 } else if (titleHandler.getStartTag().equals(name)) {
110 header.setTitle(titleHandler.getLatexList());
111 } else if (abstractHandler.getStartTag().equals(name)) {
112 header.setSummary(abstractHandler.getLatexList());
113 } else if (authorListHandler.getStartTag().equals(name)) {
114 header.setAuthorList(authorListHandler.getAuthorList());
115 } else if (importListHandler.getStartTag().equals(name)) {
116 header.setImportList(importListHandler.getImportList());
117 } else if (usedbyListHandler.getStartTag().equals(name)) {
118 header.setUsedByList(usedbyListHandler.getUsedByList());
119 } else {
120 throw XmlSyntaxException.createUnexpectedTagException(name);
121 }
122 }
123
124 }