Revision a897c436
Added by Andreas Müller almost 6 years ago
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/bci/BciSchemaAdapter.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
37 | 37 |
* @since 25.08.2010 |
38 | 38 |
*/ |
39 | 39 |
public class BciSchemaAdapter extends SchemaAdapterBase<Reference>{ |
40 |
|
|
40 |
|
|
41 | 41 |
|
42 | 42 |
|
43 | 43 |
static URI identifier = null; |
44 |
|
|
44 |
|
|
45 | 45 |
static String nameSpace = "http://purl.org/dc/elements/1.1/"; |
46 |
|
|
46 |
|
|
47 | 47 |
static { |
48 | 48 |
try { |
49 | 49 |
identifier = new URI("info:srw/schema/1/dc-v1.1"); |
... | ... | |
67 | 67 |
public String getShortName() { |
68 | 68 |
return "dc"; |
69 | 69 |
} |
70 |
|
|
70 |
|
|
71 | 71 |
/* (non-Javadoc) |
72 | 72 |
* @see eu.etaxonomy.cdm.ext.schema.SchemaAdapter#getCmdEntities(java.io.Reader) |
73 | 73 |
*/ |
... | ... | |
85 | 85 |
logger.error(e); |
86 | 86 |
} |
87 | 87 |
|
88 |
|
|
88 |
|
|
89 | 89 |
DcSaxHandler handler = new DcSaxHandler(); |
90 |
|
|
90 |
|
|
91 | 91 |
try { |
92 | 92 |
if(parser != null){ |
93 | 93 |
parser.parse(inputStream, handler); |
... | ... | |
100 | 100 |
logger.error(e); |
101 | 101 |
} |
102 | 102 |
|
103 |
|
|
103 |
|
|
104 | 104 |
return handler.referenceList; |
105 | 105 |
} |
106 |
|
|
106 |
|
|
107 | 107 |
class DcSaxHandler extends DefaultHandler { |
108 |
|
|
108 |
|
|
109 | 109 |
private static final String DC_DC = "dc:dc"; |
110 |
|
|
110 |
|
|
111 | 111 |
private static final String DC_TITLE = "dc:title"; |
112 | 112 |
private static final String DC_CREATOR = "dc:creator"; |
113 | 113 |
private static final String DC_PUBLISHER = "dc:publisher"; |
114 | 114 |
private static final String DC_DATE = "dc:date"; |
115 |
|
|
115 |
|
|
116 | 116 |
List<Reference> referenceList = new ArrayList<Reference>(); |
117 | 117 |
|
118 | 118 |
Reference reference = null; |
119 |
|
|
119 |
|
|
120 | 120 |
String dcFieldName = null; |
121 |
|
|
122 |
|
|
121 |
|
|
122 |
|
|
123 | 123 |
|
124 | 124 |
@Override |
125 |
public void startElement(String uri, String localName,
|
|
125 |
public void startElement(String uri, String localName, |
|
126 | 126 |
String qName, Attributes attributes) throws SAXException { |
127 | 127 |
|
128 | 128 |
if (uri.equals(nameSpace)) { |
129 | 129 |
logger.debug("Start Element :" + qName + "; " + uri); |
130 |
|
|
130 |
|
|
131 | 131 |
if (qName.equals(DC_DC)) { |
132 | 132 |
reference = ReferenceFactory.newGeneric(); |
133 | 133 |
} else { |
... | ... | |
143 | 143 |
if (uri.equals(nameSpace)) { |
144 | 144 |
if(reference != null) { |
145 | 145 |
logger.debug("End Element :" + qName + "; " + uri); |
146 |
|
|
146 |
|
|
147 | 147 |
if (qName.equals(DC_DC)) { |
148 | 148 |
referenceList.add(reference); |
149 | 149 |
reference = null; |
150 | 150 |
} else { |
151 | 151 |
dcFieldName = null; |
152 | 152 |
} |
153 |
}
|
|
153 |
} |
|
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
} |
... | ... | |
176 | 176 |
authorship.setTitleCache(text, true); |
177 | 177 |
reference.setAuthorship(authorship); |
178 | 178 |
} |
179 |
|
|
179 |
|
|
180 | 180 |
} |
181 | 181 |
} |
182 |
|
|
182 |
|
|
183 | 183 |
} |
184 |
|
|
184 |
|
|
185 | 185 |
} |
Also available in: Unified diff
cleanup