View Javadoc

1   /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">http://www.qedeq.org
2    *
3    * Copyright 2000-2014,  Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
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.LiteratureItemVo;
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   * Handle bibliography entry.
26   *
27   * @version $Revision: 1.1 $
28   * @author  Michael Meyling
29   */
30  public  class LiteratureItemHandler extends AbstractSimpleHandler {
31  
32      /** Tag for this handler. */
33      public static final String ITEM_TAG = "ITEM";
34  
35      /** Handle reference texts. */
36      private final LatexListHandler itemHandler;
37  
38      /** Value object. */
39      private LiteratureItemVo literatureItem;
40  
41  
42      /**
43       * Constructor.
44       *
45       * @param handler
46       *            Parent handler.
47       */
48      public LiteratureItemHandler(final AbstractSimpleHandler handler) {
49          super(handler, ITEM_TAG);
50          itemHandler = new LatexListHandler(this, ITEM_TAG);
51      }
52  
53      public final void init() {
54          literatureItem = null;
55      }
56  
57      /**
58       * Get section.
59       *
60       * @return  Section.
61       */
62      public final LiteratureItemVo getLiteratureItem() {
63          return literatureItem;
64      }
65  
66      public final void startElement(final String name, final SimpleAttributes attributes)
67              throws XmlSyntaxException {
68          if (getStartTag().equals(name)) {
69              literatureItem = new LiteratureItemVo();
70              literatureItem.setLabel(attributes.getString("label"));
71              changeHandler(itemHandler, name, attributes);
72          } else {
73              throw XmlSyntaxException.createUnexpectedTagException(name);
74          }
75      }
76  
77      public final void endElement(final String name) throws XmlSyntaxException {
78          if (getStartTag().equals(name)) {
79              literatureItem.setItem(itemHandler.getLatexList());
80          } else {
81              throw XmlSyntaxException.createUnexpectedTagException(name);
82          }
83      }
84  
85  
86  }