}
}
// We've got the type, figure out what converter to use
Converter converter = pmap.getConverter();
if (converter == null)
converter = config.getConverter(paramClassName);
// else
// {
// if (!pmap.getPropertyType().equals(paramClassName))
// {
// pmap.setPropertyType(paramClass);
// converter = config.getConverter(paramClassName);
// pmap.setConverter(converter);
// }
// }
// If no converter is found, make sure we are not processing a text
// node, we must be processing a subtag (an object).
if (converter == null)
{
if (value instanceof java.lang.String)
{
logger.info("Warning, processing text but no converter found for "
+ paramClassName);
return;
}
}
// Found a setter so now lets make sure the attribute value is of the
// correct type and then call the setter.
Object[] params = null;
if (value != null && paramClassName != null)
{
params = new Object[1];
// Converter converter = config.getConverter(paramClass);
if (converter == null)
{
params[0] = value;
}
else
{
Object converterImpl = null;
if (converter.getClass().getName().equals(converter.getClassname()))
converterImpl = converter;
else
{
ObjectFactory factory = config.getObjectFactory();
converterImpl = factory.getInstance(converter.getClassname());
}
try
{
Class[] convTypes = new Class[1];
convTypes[0] = value.getClass();
Method parseMethod =
converterImpl.getClass().getMethod(converter.getParseMethod(),
convTypes);
Object[] convParams = new Object[1];
convParams[0] = value;
params[0] = parseMethod.invoke(converterImpl, convParams);
}
catch(NoSuchMethodException nsme)
{
logger.info("No such method " + converter.getParseMethod());
}
catch (InvocationTargetException ite)
{
logger.info("Called method threw an exception.");
}