if (String.class.getName().equals(className)) {
return value;
} else {
Class aClass = loadAClass(className);
if (aClass == null) {
throw new LoggedRuntimeException("Cannot find a class with name : " + className,
log);
}
String mName = "valueOf";
try {
Method method = aClass.getMethod(mName, value.getClass());
if (log.isDebugEnabled()) {
log.debug("Invoking method "
+ mName + "(" + value + ")");
}
return method.invoke(null, value);
} catch (InvocationTargetException e) {
throw new LoggedRuntimeException("Error Invoking method : " + mName + "into " +
className + " with parameter " + value + ": " + e.getMessage(), e, log);
} catch (NoSuchMethodException e) {
throw new LoggedRuntimeException("Error locating a method : " + mName + " from " +
className + " with parameter " + value + ": " + e.getMessage(), e, log);
} catch (IllegalAccessException e) {
throw new LoggedRuntimeException("Error Invoking method : " + mName + "into " +
className + " with parameter " + value + ": " + e.getMessage(), e, log);
}
}
}