Project

General

Profile

« Previous | Next » 

Revision 34593

added indexing field

View differences:

StreamingRecordParser.java
11 11
import javax.xml.stream.XMLStreamReader;
12 12

  
13 13
/**
14
 * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
15
 * header.
16
 * 
14
 * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the header.
15
 *
17 16
 * @author marko
18
 * 
17
 *
19 18
 */
20 19
public class StreamingRecordParser implements RecordParser {
21 20

  
22 21
	@Override
23
	public Map<String, String> parseRecord(String record) {
22
	public Map<String, String> parseRecord(final String record) {
24 23

  
25 24
		try {
26 25
			XMLInputFactory factory = XMLInputFactory.newInstance();
......
33 32

  
34 33
			while (parser.hasNext()) {
35 34
				int event = parser.next();
36

  
37 35
				if (event == XMLStreamConstants.END_ELEMENT) {
38 36
					elementStack.pop();
39 37
				} else if (event == XMLStreamConstants.START_ELEMENT) {
......
48 46
					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
49 47
						if (!res.containsKey("originalId")) {
50 48
							parser.next();
51
//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
49
							// log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
52 50
							res.put("originalId", parser.getText().trim());
53 51
						}
54 52
					}
55 53

  
56 54
					else if ("identifier".equals(localName)) {
57 55

  
58
//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
56
						// log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " +
57
						// grandParent(elementStack));
59 58
					}
60 59

  
61
					if (res.containsKey("id") && res.containsKey("originalId"))
62
						return res;
60
					if (res.containsKey("id") && res.containsKey("originalId")) { return res; }
63 61
				}
64 62
			}
65 63
			return res;
......
69 67

  
70 68
	}
71 69

  
72
	private String grandParent(Stack<String> elementStack) {
73
		if (elementStack.size() <= 3)
74
			return "";
70
	private String grandParent(final Stack<String> elementStack) {
71
		if (elementStack.size() <= 3) { return ""; }
75 72
		return elementStack.get(elementStack.size() - 3);
76 73
	}
77 74

  

Also available in: Unified diff