class PatternValidator implements ConstraintValidator<Pattern, String> {

	public void initialize(Pattern parameters) {
		Pattern.Flag flags[] = parameters.flags();
		int intFlag = 0;
		for ( Pattern.Flag flag : flags ) {
			intFlag = intFlag | mapFlagToInt( flag );
		}

		try {
			pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
		}
		catch ( PatternSyntaxException e ) {
			throw new ValidationException( "Invalid regular expression.", e );
		}
	}

}