Revision 52044
Added by Claudio Atzori almost 6 years ago
StreamingRecordParser.java | ||
---|---|---|
10 | 10 |
import javax.xml.stream.XMLStreamException; |
11 | 11 |
import javax.xml.stream.XMLStreamReader; |
12 | 12 |
|
13 |
import static eu.dnetlib.data.mdstore.modular.MDStoreConstants.*; |
|
14 |
|
|
13 | 15 |
/** |
14 | 16 |
* This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the |
15 | 17 |
* header. |
... | ... | |
29 | 31 |
XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes())); |
30 | 32 |
|
31 | 33 |
HashMap<String, String> res = new HashMap<String, String>(); |
32 |
res.put("timestamp", String.valueOf(getTimestamp()));
|
|
34 |
res.put(TIMESTAMP, String.valueOf(getTimestamp()));
|
|
33 | 35 |
|
34 | 36 |
Stack<String> elementStack = new Stack<String>(); |
35 | 37 |
elementStack.push("/"); |
... | ... | |
43 | 45 |
final String localName = parser.getLocalName(); |
44 | 46 |
elementStack.push(localName); |
45 | 47 |
|
46 |
if ("objIdentifier".equals(localName)) {
|
|
48 |
if (OBJIDENTIFIER.equals(localName)) {
|
|
47 | 49 |
parser.next(); |
48 | 50 |
|
49 |
res.put("id", parser.getText().trim());
|
|
51 |
res.put(ID, parser.getText().trim());
|
|
50 | 52 |
|
51 | 53 |
} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) { |
52 | 54 |
if (!res.containsKey("originalId")) { |
... | ... | |
61 | 63 |
// log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack)); |
62 | 64 |
} |
63 | 65 |
|
64 |
if (res.containsKey("id") && res.containsKey("originalId"))
|
|
66 |
if (res.containsKey(ID) && res.containsKey("originalId"))
|
|
65 | 67 |
return res; |
66 | 68 |
} |
67 | 69 |
} |
Also available in: Unified diff
long, not string!