01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.kernel.xml.handler.module;
17
18 import org.qedeq.kernel.se.dto.module.AuthorListVo;
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 * Parse author list.
25 *
26 * @version $Revision: 1.1 $
27 * @author Michael Meyling
28 */
29 public class AuthorListHandler extends AbstractSimpleHandler {
30
31 /** List of authors. */
32 private AuthorListVo list;
33
34 /** Parses an author. */
35 private final AuthorHandler authorHandler;
36
37
38 /**
39 * Handles list of authors.
40 *
41 * @param handler Parent handler.
42 */
43 public AuthorListHandler(final AbstractSimpleHandler handler) {
44 super(handler, "AUTHORS");
45 authorHandler = new AuthorHandler(this);
46 }
47
48 public final void init() {
49 list = new AuthorListVo();
50 }
51
52 /**
53 * Get list of authors.
54 *
55 * @return Author list.
56 */
57 public final AuthorListVo getAuthorList() {
58 return list;
59 }
60
61 public final void startElement(final String name, final SimpleAttributes attributes)
62 throws XmlSyntaxException {
63 if (getStartTag().equals(name)) {
64 // nothing to do
65 } else if (authorHandler.getStartTag().equals(name)) {
66 changeHandler(authorHandler, name, attributes);
67 } else {
68 throw XmlSyntaxException.createUnexpectedTagException(name);
69 }
70 }
71
72 public final void endElement(final String name) throws XmlSyntaxException {
73 if (getStartTag().equals(name)) {
74 // nothing to do
75 } else if (authorHandler.getStartTag().equals(name)) {
76 list.add(authorHandler.getAuthor());
77 } else {
78 throw XmlSyntaxException.createUnexpectedTagException(name);
79 }
80 }
81 }
|