void setRuleMessage ( XmlModelWriter xw , ValidatorRule rule , Element element ) { String messageKey = rule . getMessageKey ( ) ; String message = rule . getMessage ( ) ; if ( messageKey != null || message != null ) { Element msgElementToUse = findChildElement ( xw , element , "msg" , "name" , rule . getRuleName ( ) , true , null ) ; setElementAttribute ( msgElementToUse , "resource" , true ) ; if ( messageKey != null ) { setElementAttribute ( msgElementToUse , "key" , messageKey ) ; if ( _isValidatorOneOne ) { setElementAttribute ( msgElementToUse , "bundle" , rule . getBundle ( ) ) ; } } else // message != null (it's a hardcoded message) { // Add our special constant as the message key, append the hardcoded message to it. setElementAttribute ( msgElementToUse , "key" , ValidatorConstants . EXPRESSION_KEY_PREFIX + message ) ; } } }
Set up the desired &lt ; msg&gt ; element and attributes for the given rule .