Unmarshaller u, InputStream entityStream)
throws JAXBException, IOException {
final Charset c = getCharset(mediaType);
if (type.isAnnotationPresent(XmlRootElement.class)) {
if (u instanceof JSONUnmarshaller) {
JSONUnmarshaller ju = (JSONUnmarshaller)u;
ju.setJsonEnabled(true);
JAXBElement jaxbElem = (JAXBElement)ju.
unmarshal(new InputStreamReader(entityStream, c),
type);
return jaxbElem.getValue();
} else {
return u.unmarshal(
new JsonXmlStreamReader(
new InputStreamReader(entityStream, c),
JSONHelper.getRootElementName(type)));
}
} else {
if (u instanceof JSONUnmarshaller) {
// TODO what about the charset ?
JSONUnmarshaller ju = (JSONUnmarshaller)u;
ju.setJsonEnabled(true);
return ju.unmarshal(new StreamSource(entityStream), type).getValue();
} else {
return u.unmarshal(
new JsonXmlStreamReader(
new InputStreamReader(entityStream, c),
JSONHelper.getRootElementName(type)), type).getValue();