);
}
}
else
{
AddMethodMetaData addMethodMetaData = element.getAddMethodMetaData();
PropertyMetaData propertyMetaData = null;
if(addMethodMetaData == null)
{
if(parentElement != null && parentElement.getType().isWildcardElement(qName))
{
propertyMetaData = parentElement.getType().getWildcardPropertyMetaData();
}
if(propertyMetaData == null)
{
propertyMetaData = element.getPropertyMetaData();
}
/*
if(propertyMetaData == null)
{
propertyMetaData = element.getType().getPropertyMetaData();
}
*/
}
if(addMethodMetaData != null)
{
Class valueType = Object.class;
if(addMethodMetaData.getValueType() != null)
{
try
{
valueType = Thread.currentThread().getContextClassLoader().
loadClass(addMethodMetaData.getValueType());
}
catch(ClassNotFoundException e)
{
throw new JBossXBRuntimeException("Failed to load value type for addMethod.name=" +
addMethodMetaData.getMethodName() +
", valueType=" +
addMethodMetaData.getValueType() +
": " + e.getMessage(), e
);
}
}
else if(addMethodMetaData.isChildType())
{
if(o == null)
{
throw new JBossXBRuntimeException(
"addMethod=" +
addMethodMetaData.getMethodName() +
" for element " + qName +
" is configured with valueType='child'. The valueType cannot be determined because" +
" the child is null"
);
}
valueType = o.getClass();
}
Class ownerClass = owner.getClass();
Method addMethod;
try
{
addMethod = ownerClass.getMethod(addMethodMetaData.getMethodName(), new Class[]{valueType});
}
catch(NoSuchMethodException e)
{
throw new JBossXBRuntimeException("Failed to find addMethod.name=" +
addMethodMetaData.getMethodName() +
", addMethod.valueType=" +
valueType.getName() +
" in class " +
ownerClass.getName() +
": " +
e.getMessage(), e
);
}
try
{
addMethod.invoke(owner, new Object[]{o});
}
catch(Exception e)
{
throw new JBossXBRuntimeException("setParent failed for " +
qName +
"=" +
o +
": addMethod=" +
addMethodMetaData.getMethodName() +
" threw an exception for owner=" +
owner +
", value=" +
o +
": " +