{
StreamSource source = new StreamSource(entityStream);
JAXBContext ctx = finder.findCachedContext(JaxbCollection.class, mediaType, annotations);
JAXBElement<JaxbCollection> ele = ctx.createUnmarshaller().unmarshal(source, JaxbCollection.class);
Wrapped wrapped = FindAnnotation.findAnnotation(annotations, Wrapped.class);
if (wrapped != null)
{
if (!wrapped.element().equals(ele.getName().getLocalPart()))
{
throw new JAXBUnmarshalException("Collection wrapping failed, expected root element name of " + wrapped.element() + " got " + ele.getName().getLocalPart());
}
if (!wrapped.namespace().equals(ele.getName().getNamespaceURI()))
{
throw new JAXBUnmarshalException("Collection wrapping failed, expect namespace of " + wrapped.namespace() + " got " + ele.getName().getNamespaceURI());
}
}
col = ele.getValue();
}