|| QName.class == clazz) {
// Immutable classes
return data;
}
DataBinding javaBeansDataBinding = dataBindings.getDataBinding(JavaBeansDataBinding.NAME);
// FIXME: The JAXB databinding is hard-coded here
DataBinding jaxbDataBinding = dataBindings.getDataBinding("javax.xml.bind.JAXBElement");
DataBinding dataBinding = dataBindings.getDataBinding(sourceDataType.getDataBinding());
// If no databinding was specified, introspect the given arg to
// determine its databinding
if (dataBinding == null) {
if (!"java:array".equals(sourceDataType.getDataBinding())) {
sourceDataType = dataBindings.introspectType(data, sourceOperation);
if (sourceDataType != null) {
String db = sourceDataType.getDataBinding();
dataBinding = dataBindings.getDataBinding(db);
if (dataBinding == null && db != null) {
return data;
}
}
}
if (dataBinding == null) {
// Default to the JavaBean databinding
dataBinding = dataBindings.getDataBinding(JavaBeansDataBinding.NAME);
}
}
// Use the JAXB databinding to copy non-Serializable data
if (dataBinding == javaBeansDataBinding) {
// If the input data is an array containing non Serializable elements
// use JAXB
clazz = data.getClass();
if (clazz.isArray()) {
if (Array.getLength(data) != 0) {
Object element = Array.get(data, 0);
if (element != null && !(element instanceof Serializable)) {
dataBinding = jaxbDataBinding;
}
}
} else {
// If the input data is not Serializable use JAXB
if (!((data instanceof Serializable) || (data instanceof Cloneable))) {
dataBinding = jaxbDataBinding;
}
}
}
if (dataBinding == null) {
return data;
}
return dataBinding.copy(data, sourceDataType, targetDataType, sourceOperation, targetOperation);
}