public void setIllegalCharacters ( final String illegalCharacters ) { // Create a simple sub-rule taking care of the check this . illegalCharacters = illegalCharacters ; delegatePattern = new NegateBooleanRule < String > ( new StringRegexRule ( "[" + Pattern . quote ( illegalCharacters ) + "]" ) ) ; // Create a nicely space-separated list of illegal characters final int illegalCharacterCount = illegalCharacters . length ( ) ; final StringBuilder illegalCharactersSeparatedBySpacesStringBuilder = new StringBuilder ( illegalCharacterCount * 2 ) ; for ( int i = 0 ; i < illegalCharacterCount ; i ++ ) { illegalCharactersSeparatedBySpacesStringBuilder . append ( illegalCharacters . toCharArray ( ) [ i ] ) ; if ( i < ( illegalCharacterCount - 1 ) ) { illegalCharactersSeparatedBySpacesStringBuilder . append ( ' ' ) ; } } illegalCharactersSeparatedBySpaces = illegalCharactersSeparatedBySpacesStringBuilder . toString ( ) ; }
Sets the list of illegal characters in a string .