public boolean matchRule ( AuditEvent event , String ruleName , String expectedMessage , String expectedSeverity ) { if ( ! ruleName . equals ( RuleUtil . getName ( event ) ) ) { return false ; } // check message too, for those that have a specific one. // like GenericIllegalRegexp and Regexp if ( expectedMessage != null ) { // event.getMessage() uses java.text.MessageFormat in its implementation. // Read MessageFormat Javadoc about single quote: // http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html String msgWithoutSingleQuote = StringUtils . replace ( expectedMessage , "'" , "" ) ; return expectedMessage . equals ( event . getMessage ( ) ) || msgWithoutSingleQuote . equals ( event . getMessage ( ) ) ; } // Check the severity. This helps to distinguish between // different configurations for the same rule, where each // configuration has a different severity, like JavadocMetod. // See also http://jira.codehaus.org/browse/MCHECKSTYLE-41 if ( expectedSeverity != null ) { return expectedSeverity . equals ( event . getSeverityLevel ( ) . getName ( ) ) ; } return true ; }
Check if a violation matches a rule .