String msg = "";
try{
msg = (String)c.getMethod("message").invoke(parameters);
}
catch(Exception e){
throw new ValidateException("cannot find message property for " + parameters.toString(), e);
}
if (validatorResource == null){
return msg;
}
try{
String resourceMsg = validatorResource.getString(msg.trim());
msg = resourceMsg;
for(Method method: c.getDeclaredMethods()){
if (method.getParameterTypes().length == 0){
String key = "\\{"+method.getName()+"\\}";
String value = method.invoke(parameters).toString();
msg = msg.replaceAll(key, value);
}
}
}
catch(MissingResourceException e1){
throw new ValidateException("cannot find validation resource.", e1);
}
catch(Exception e2){
throw new ValidateException(e2);
}
return msg;
}