*/
public JAXBElement unmarshal(XMLStreamReader streamReader, TypeMappingInfo type) throws JAXBException {
if(jaxbContext.getTypeMappingInfoToGeneratedType() == null) {
return unmarshal(streamReader, type.getType());
}
RootLevelXmlAdapter adapter = jaxbContext.getTypeMappingInfoToJavaTypeAdapters().get(type);
Class unmarshalClass = jaxbContext.getTypeMappingInfoToGeneratedType().get(type);
if(unmarshalClass != null){
JAXBElement unmarshalled = unmarshal(streamReader, unmarshalClass);
Class declaredClass = null;
if(type.getType() instanceof Class){
declaredClass = (Class)type.getType();
}else{
declaredClass = Object.class;
}
Object value = unmarshalled.getValue();
if(adapter != null) {
try {
value = adapter.getXmlAdapter().unmarshal(value);
} catch(Exception ex) {
throw new JAXBException(XMLMarshalException.marshalException(ex));
}
}
JAXBElement returnVal = new JAXBElement(unmarshalled.getName(), declaredClass, unmarshalled.getScope(), value);
return returnVal;
}else if(type.getType() instanceof Class){
if(adapter != null) {
JAXBElement element = unmarshal(streamReader, adapter.getBoundType());
try {
Object value = adapter.getXmlAdapter().unmarshal(element.getValue());
element.setValue(value);
return element;
} catch(Exception ex) {
throw new JAXBException(XMLMarshalException.marshalException(ex));
}