if (source instanceof XMLStreamReader) {
reader = (XMLStreamReader)source;
} else if (source instanceof Element) {
reader = StaxUtils.createXMLStreamReader((Element)source);
} else {
throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
}
while (reader.getName().equals(elName)) {
JAXBElement<?> type = u.unmarshal(reader, clazz);
if (type != null) {
ret.add(type.getValue());
}
while (reader.getEventType() != XMLStreamConstants.START_ELEMENT
&& reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
reader.nextTag();
}
}
return ret;
} catch (Fault ex) {
throw ex;
} catch (Exception ex) {
if (ex instanceof javax.xml.bind.UnmarshalException) {
javax.xml.bind.UnmarshalException unmarshalEx = (javax.xml.bind.UnmarshalException)ex;
throw new Fault(new Message("UNMARSHAL_ERROR", LOG, unmarshalEx.getLinkedException()
.getMessage()), ex);
} else {
throw new Fault(new Message("UNMARSHAL_ERROR", LOG, ex.getMessage()), ex);
}
}
}