toSet = coerce(builder, xsrVar, value, toClass(mapping.getComponentType()));
} else {
// adapted type
JVar adapterVar = builder.getAdapter(property.getAdapterType());
block.add(new JBlankLine());
// convert raw value into bound type
Class targetType = toClass(mapping.getComponentType());
JVar valueVar = block.decl(context.toJClass(targetType), propertyName);
JTryBlock tryBlock = block._try();
tryBlock.body().assign(valueVar, adapterVar.invoke("unmarshal").arg(value));
JCatchBlock catchException = tryBlock._catch(context.toJClass(Exception.class));
JBlock catchBody = catchException.body();
catchBody.invoke(builder.getReadContextVar(), "xmlAdapterError")
.arg(xsrVar)
.arg(context.dotclass(property.getAdapterType()))
.arg(context.dotclass(targetType))
.arg(context.dotclass(targetType))
.arg(catchException.param("e"));
catchBody._continue();
block.add(new JBlankLine());
toSet = valueVar;
}
// JaxB refs need to be wrapped with a JAXBElement
if (toClass(property.getComponentType()).equals(JAXBElement.class)) {
toSet = newJaxBElement(xsrVar, toClass(mapping.getComponentType()), toSet);
}
doSet(builder, block, property, parentVar, toSet, collectionVar);
}
}
if (property.isXmlAny()) {
// create element block
JBlock block = elementBuilder.expectAnyElement();
// add comment for readability
block.add(new JLineComment(property.getXmlStyle() + ": " + property.getName()));
// read and set
JInvocation toSet = builder.getReadContextVar().invoke("readXmlAny")
.arg(builder.getChildElementVar())
.arg(context.dotclass(property.getComponentType()))
.arg(property.isLax() ? JExpr.TRUE : JExpr.FALSE);
doSet(builder, block, property, parentVar, toSet, collectionVar);
}
if (property.isMixed()) {
// create element block
JBlock block = elementBuilder.expectMixedElement();
// add comment for readability
block.add(new JLineComment(property.getXmlStyle() + " (Mixed): " + property.getName()));
// read and set
JInvocation toSet = builder.getChildElementVar().invoke("getText");
doSet(builder, block, property, parentVar, toSet, collectionVar);
}
}
break;
case VALUE: {
// value is read in class block
JBlock block = builder.expectValue();
// add comment for readability
block.add(new JBlankLine());
block.add(new JLineComment(property.getXmlStyle() + ": " + property.getName()));
// read and set value
handleValue(builder, builder.getXSR(), block, property, beanVar);
}