for (int i = 0; i < in.getAttributeCount(); i++) {
QName attributeName = in.getAttributeName(i);
XmlMapping mapping = getAttributeMapping(attributeName);
if (mapping == null)
throw new UnmarshalException(L.l("Attribute {0} not found in {1}",
attributeName, getType()));
mapping.readAttribute(in, i, ret);
}
int i = 0;
in.nextTag();
while (in.getEventType() == in.START_ELEMENT) {
XmlMapping mapping = getElementMapping(in.getName());
if (mapping == null) {
throw new UnmarshalException(L.l("Child <{0}> not found in {1}",
in.getName(), getType()));
}
if (! mapping.getAccessor().checkOrder(i++, u.getEventHandler())) {
throw new UnmarshalException(L.l("Child <{0}> misordered in {1}",
in.getName(), getType()));
}
mapping.read(u, in, ret);
}
// essentially a nextTag() that handles end of document gracefully
while (in.hasNext()) {
in.next();
if (in.getEventType() == in.START_ELEMENT ||
in.getEventType() == in.END_ELEMENT)
break;
}
}
if (_afterUnmarshal != null)
_afterUnmarshal.invoke(ret, u, null);
if (u.getListener() != null)
u.getListener().afterUnmarshal(ret, null);
return ret;
}
catch (InvocationTargetException e) {
if (e.getTargetException() != null)
throw new UnmarshalException(e.getTargetException());
throw new UnmarshalException(e);
}
catch (IllegalAccessException e) {
throw new UnmarshalException(e);
}
}