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.AuthorVo; |
22 |
| import org.qedeq.kernel.xml.parser.AbstractSimpleHandler; |
23 |
| import org.qedeq.kernel.xml.parser.SimpleAttributes; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public class AuthorHandler extends AbstractSimpleHandler { |
32 |
| |
33 |
| |
34 |
| private AuthorVo author; |
35 |
| |
36 |
| |
37 |
| private String email; |
38 |
| |
39 |
| |
40 |
| private final LatexHandler authorNameHandler; |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
46
| public AuthorHandler(final AbstractSimpleHandler handler) {
|
49 |
46
| super(handler, "AUTHOR");
|
50 |
46
| authorNameHandler = new LatexHandler(this, "NAME");
|
51 |
| } |
52 |
| |
53 |
41
| public final void init() {
|
54 |
41
| author = null;
|
55 |
41
| email = null;
|
56 |
| } |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
41
| public final AuthorVo getAuthor() {
|
64 |
41
| return author;
|
65 |
| } |
66 |
| |
67 |
82
| public final void startElement(final String name, final SimpleAttributes attributes)
|
68 |
| throws SyntaxException { |
69 |
82
| if (getStartTag().equals(name)) {
|
70 |
41
| email = attributes.getString("email");
|
71 |
41
| } else if (authorNameHandler.getStartTag().equals(name)) {
|
72 |
41
| changeHandler(authorNameHandler, name, attributes);
|
73 |
| } else { |
74 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
75 |
| } |
76 |
| } |
77 |
| |
78 |
82
| public final void endElement(final String name) throws SyntaxException {
|
79 |
82
| if (getStartTag().equals(name)) {
|
80 |
| |
81 |
41
| } else if (authorNameHandler.getStartTag().equals(name)) {
|
82 |
41
| author = new AuthorVo(authorNameHandler.getLatex(), email);
|
83 |
| } else { |
84 |
0
| throw SyntaxException.createUnexpectedTagException(name);
|
85 |
| } |
86 |
| } |
87 |
| } |