@Override public Entry<String, String> unmarshall(StaxUnmarshallerContext context) throws Exception { int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; MapEntry<String, String> entry = new MapEntry<String, String>(); while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return entry; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("key", targetDepth)) { entry.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("value", targetDepth)) { entry.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) return entry; } } }
@Override public Entry<String, String> unmarshall(StaxUnmarshallerContext context) throws Exception { int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; MapEntry<String, String> entry = new MapEntry<String, String>(); while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return entry; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("key", targetDepth)) { entry.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("value", targetDepth)) { entry.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) return entry; } } }