1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.io.markup.handler;
|
10
|
|
11
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
12
|
import org.xml.sax.Attributes;
|
13
|
import org.xml.sax.SAXException;
|
14
|
|
15
|
import eu.etaxonomy.cdm.io.common.ImportHandlerBase;
|
16
|
import eu.etaxonomy.cdm.io.common.XmlImportBase;
|
17
|
|
18
|
|
19
|
|
20
|
/**
|
21
|
* Sax2 handler for the MarkupImport publication element
|
22
|
* @author a.mueller
|
23
|
* @since 28.06.2011
|
24
|
*
|
25
|
*/
|
26
|
public class PublicationHandler extends ImportHandlerBase{
|
27
|
@SuppressWarnings("unused")
|
28
|
private static final Logger logger = LogManager.getLogger(PublicationHandler.class);
|
29
|
|
30
|
private boolean isInPublication;
|
31
|
private ImportHandlerBase currentHandler = null;
|
32
|
|
33
|
public PublicationHandler(XmlImportBase importBase) {
|
34
|
super(importBase);
|
35
|
}
|
36
|
|
37
|
/* (non-Javadoc)
|
38
|
* @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
39
|
*/
|
40
|
@Override
|
41
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
42
|
super.startElement(uri, localName, qName, attributes);
|
43
|
if (currentHandler != null){
|
44
|
currentHandler.startElement(uri, localName, qName, attributes);
|
45
|
}else{
|
46
|
//publication
|
47
|
if ("publication".equalsIgnoreCase(qName)){
|
48
|
this.isInPublication = true;
|
49
|
//TODO check attributes
|
50
|
return;
|
51
|
}else if (this.isInPublication == false){
|
52
|
handleUnexpectedStartElement(uri, localName, qName);
|
53
|
return;
|
54
|
}
|
55
|
//children
|
56
|
if ("metaData".equalsIgnoreCase(qName)){
|
57
|
handleNotYetImplementedElement(uri, localName, qName);
|
58
|
}else if ("treatment".equalsIgnoreCase(qName)){
|
59
|
currentHandler = new TreatmentHandler(this);
|
60
|
}else if ("biographies".equalsIgnoreCase(qName)){
|
61
|
handleNotYetImplementedElement(uri, localName, qName);
|
62
|
}else if ("references".equalsIgnoreCase(qName)){
|
63
|
handleNotYetImplementedElement(uri, localName, qName);
|
64
|
}else if ("textSection".equalsIgnoreCase(qName)){
|
65
|
handleNotYetImplementedElement(uri, localName, qName);
|
66
|
}else if ("addenda".equalsIgnoreCase(qName)){
|
67
|
handleNotYetImplementedElement(uri, localName, qName);
|
68
|
}else{
|
69
|
handleUnexpectedStartElement(uri, localName, qName);
|
70
|
}
|
71
|
if (attributes.getLength() > 0){
|
72
|
handleUnexpectedAttributes(attributes);
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#endElement(java.lang.String, java.lang.String, java.lang.String)
|
79
|
*/
|
80
|
@Override
|
81
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
82
|
// super.endElement(uri, localName, qName);
|
83
|
if (currentHandler != null){
|
84
|
currentHandler.endElement(uri, localName, qName);
|
85
|
}else{
|
86
|
if ("publication".equalsIgnoreCase(qName)){
|
87
|
if (this.isInPublication == true){
|
88
|
this.isInPublication = false;
|
89
|
return;
|
90
|
}else{
|
91
|
fireUnexpectedEndElement(uri, localName, qName, 1);
|
92
|
}
|
93
|
}else{
|
94
|
if ("metaData".equalsIgnoreCase(qName)){
|
95
|
System.out.println("Hallo");
|
96
|
}else if ("treatment".equalsIgnoreCase(qName)){
|
97
|
|
98
|
|
99
|
}else if ("biographies".equalsIgnoreCase(qName)){
|
100
|
|
101
|
}else if ("references".equalsIgnoreCase(qName)){
|
102
|
}else if ("textSection".equalsIgnoreCase(qName)){
|
103
|
}else if ("addenda".equalsIgnoreCase(qName)){
|
104
|
}else{
|
105
|
handleUnexpectedEndElement(uri, localName, qName);
|
106
|
}
|
107
|
}
|
108
|
}
|
109
|
}
|
110
|
|
111
|
|
112
|
|
113
|
|
114
|
}
|