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.log4j.Logger;
|
12
|
import org.xml.sax.Attributes;
|
13
|
import org.xml.sax.SAXException;
|
14
|
|
15
|
import eu.etaxonomy.cdm.io.common.ImportHandlerBase;
|
16
|
|
17
|
|
18
|
/**
|
19
|
* Sax2 handler for the MarkupImport publication element
|
20
|
* @author a.mueller
|
21
|
\* @since 28.06.2011
|
22
|
*
|
23
|
*/
|
24
|
public class TreatmentHandler extends ImportHandlerBase{
|
25
|
@SuppressWarnings("unused")
|
26
|
private static final Logger logger = Logger.getLogger(TreatmentHandler.class);
|
27
|
|
28
|
private boolean isInTaxon;
|
29
|
|
30
|
public TreatmentHandler(ImportHandlerBase previousHandler) {
|
31
|
super(previousHandler);
|
32
|
}
|
33
|
|
34
|
/* (non-Javadoc)
|
35
|
* @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
36
|
*/
|
37
|
@Override
|
38
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
39
|
super.startElement(uri, localName, qName, attributes);
|
40
|
//publication
|
41
|
if ("taxon".equals(qName)){
|
42
|
this.isInTaxon = true;
|
43
|
//TODO check attributes
|
44
|
return;
|
45
|
}else if (this.isInTaxon == false){
|
46
|
handleUnexpectedStartElement(uri, localName, qName);
|
47
|
return;
|
48
|
}
|
49
|
//children
|
50
|
if ("heading".equalsIgnoreCase(qName)){
|
51
|
handleNotYetImplementedElement(uri, localName, qName);
|
52
|
}else if ("taxontitle".equalsIgnoreCase(qName)){
|
53
|
handleNotYetImplementedElement(uri, localName, qName);
|
54
|
}else if ("writer".equalsIgnoreCase(qName)){
|
55
|
handleNotYetImplementedElement(uri, localName, qName);
|
56
|
}else if ("textSection".equalsIgnoreCase(qName)){
|
57
|
handleNotYetImplementedElement(uri, localName, qName);
|
58
|
}else if ("key".equalsIgnoreCase(qName)){
|
59
|
handleNotYetImplementedElement(uri, localName, qName);
|
60
|
}else if ("nomenclature".equalsIgnoreCase(qName)){
|
61
|
handleNotYetImplementedElement(uri, localName, qName);
|
62
|
}else if ("feature".equalsIgnoreCase(qName)){
|
63
|
handleNotYetImplementedElement(uri, localName, qName);
|
64
|
}else if ("notes".equalsIgnoreCase(qName)){
|
65
|
handleNotYetImplementedElement(uri, localName, qName);
|
66
|
}else if ("references".equalsIgnoreCase(qName)){
|
67
|
handleNotYetImplementedElement(uri, localName, qName);
|
68
|
}else if ("figure".equalsIgnoreCase(qName)){
|
69
|
handleNotYetImplementedElement(uri, localName, qName);
|
70
|
}else if ("footnote".equalsIgnoreCase(qName)){
|
71
|
handleNotYetImplementedElement(uri, localName, qName);
|
72
|
}else{
|
73
|
handleUnexpectedStartElement(uri, localName, qName);
|
74
|
}
|
75
|
if (attributes.getLength() > 0){
|
76
|
handleUnexpectedAttributes(attributes);
|
77
|
}
|
78
|
}
|
79
|
|
80
|
/* (non-Javadoc)
|
81
|
* @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#endElement(java.lang.String, java.lang.String, java.lang.String)
|
82
|
*/
|
83
|
@Override
|
84
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
85
|
// super.endElement(uri, localName, qName);
|
86
|
if ("taxon".equalsIgnoreCase(qName)){
|
87
|
if (this.isInTaxon == true){
|
88
|
this.isInTaxon = false;
|
89
|
return;
|
90
|
}else{
|
91
|
fireUnexpectedEndElement(uri, localName, qName, 1);
|
92
|
}
|
93
|
}else{
|
94
|
if ("metaData".equalsIgnoreCase(qName)){
|
95
|
|
96
|
}else if ("treatment".equalsIgnoreCase(qName)){
|
97
|
|
98
|
}else if ("biographies".equalsIgnoreCase(qName)){
|
99
|
|
100
|
}else if ("references".equalsIgnoreCase(qName)){
|
101
|
}else if ("textSection".equalsIgnoreCase(qName)){
|
102
|
}else if ("addenda".equalsIgnoreCase(qName)){
|
103
|
}else{
|
104
|
handleUnexpectedEndElement(uri, localName, qName);
|
105
|
}
|
106
|
}
|
107
|
}
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
}
|