3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.markup
.handler
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.xml
.sax
.Attributes
;
14 import org
.xml
.sax
.SAXException
;
16 import eu
.etaxonomy
.cdm
.io
.common
.ImportHandlerBase
;
17 import eu
.etaxonomy
.cdm
.io
.common
.XmlImportBase
;
22 * Sax2 handler for the MarkupImport publication element
27 public class PublicationHandler
extends ImportHandlerBase
{
28 @SuppressWarnings("unused")
29 private static final Logger logger
= Logger
.getLogger(PublicationHandler
.class);
31 private boolean isInPublication
;
32 private ImportHandlerBase currentHandler
= null;
34 public PublicationHandler(XmlImportBase importBase
) {
39 * @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
42 public void startElement(String uri
, String localName
, String qName
, Attributes attributes
) throws SAXException
{
43 super.startElement(uri
, localName
, qName
, attributes
);
44 if (currentHandler
!= null){
45 currentHandler
.startElement(uri
, localName
, qName
, attributes
);
48 if ("publication".equalsIgnoreCase(qName
)){
49 this.isInPublication
= true;
50 //TODO check attributes
52 }else if (this.isInPublication
== false){
53 handleUnexpectedStartElement(uri
, localName
, qName
);
57 if ("metaData".equalsIgnoreCase(qName
)){
58 handleNotYetImplementedElement(uri
, localName
, qName
);
59 }else if ("treatment".equalsIgnoreCase(qName
)){
60 currentHandler
= new TreatmentHandler(this);
61 }else if ("biographies".equalsIgnoreCase(qName
)){
62 handleNotYetImplementedElement(uri
, localName
, qName
);
63 }else if ("references".equalsIgnoreCase(qName
)){
64 handleNotYetImplementedElement(uri
, localName
, qName
);
65 }else if ("textSection".equalsIgnoreCase(qName
)){
66 handleNotYetImplementedElement(uri
, localName
, qName
);
67 }else if ("addenda".equalsIgnoreCase(qName
)){
68 handleNotYetImplementedElement(uri
, localName
, qName
);
70 handleUnexpectedStartElement(uri
, localName
, qName
);
72 if (attributes
.getLength() > 0){
73 handleUnexpectedAttributes(attributes
);
79 * @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#endElement(java.lang.String, java.lang.String, java.lang.String)
82 public void endElement(String uri
, String localName
, String qName
) throws SAXException
{
83 // super.endElement(uri, localName, qName);
84 if (currentHandler
!= null){
85 currentHandler
.endElement(uri
, localName
, qName
);
87 if ("publication".equalsIgnoreCase(qName
)){
88 if (this.isInPublication
== true){
89 this.isInPublication
= false;
92 fireUnexpectedEndElement(uri
, localName
, qName
, 1);
95 if ("metaData".equalsIgnoreCase(qName
)){
96 System
.out
.println("Hallo");
97 }else if ("treatment".equalsIgnoreCase(qName
)){
100 }else if ("biographies".equalsIgnoreCase(qName
)){
102 }else if ("references".equalsIgnoreCase(qName
)){
103 }else if ("textSection".equalsIgnoreCase(qName
)){
104 }else if ("addenda".equalsIgnoreCase(qName
)){
106 handleUnexpectedEndElement(uri
, localName
, qName
);