Object readObject = null;
IBindingFactory bfact = BindingDirectory.getFactory(expectedClass);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
ContentStyle contentStyle = content.getContentStyle();
if (contentStyle == ContentStyle.BINARY) {
readObject = uctx.unmarshalDocument(content.getInputStream(), name,
null); // null encoding means auto-detect
} else if (contentStyle == ContentStyle.TEXT) {
readObject = uctx.unmarshalDocument(content.getReader(), name);