private String toString(final Flag pflag) { String value; switch (pflag) { case CASE_INSENSITIVE: case UNICODE_CASE: value = "i"; break; case MULTILINE: value = "m"; break; default: throw LOG .getIllegalArgumentException(pflag + " is not a suppoted gwt Pattern (RegExp) flag"); } return value; }
@Override public void initialize(final Email emailAnnotation) { super.initialize(emailAnnotation); final Pattern.Flag[] flags = emailAnnotation.flags(); final StringBuilder flagString = new StringBuilder(); for (final Pattern.Flag flag : flags) { flagString.append(this.toString(flag)); } // we only apply the regexp if there is one to apply if (!".*".equals(emailAnnotation.regexp()) || emailAnnotation.flags().length > 0) { try { this.pattern = RegExp.compile(emailAnnotation.regexp(), flagString.toString()); } catch (final RuntimeException e) { throw LOG.getInvalidRegularExpressionException(e); } } }
private static PatternFlag[] convertPatternFlags(Flag[] flags) { if (flags != null && flags.length > 0) { PatternFlag[] pfs = new PatternFlag[flags.length]; for (int i = 0; i < flags.length; i++) { pfs[i] = PatternFlag.fromFlag(flags[i].getValue()); } } return new PatternFlag[0]; }
@Override public void initialize(final Pattern parameters) { final Pattern.Flag[] flags = parameters.flags(); final StringBuilder flagString = new StringBuilder(); for (final Pattern.Flag flag : flags) { flagString.append(this.toString(flag)); } try { this.pattern = RegExp.compile(parameters.regexp(), flagString.toString()); } catch (final RuntimeException e) { throw LOG.getInvalidRegularExpressionException(e); } this.escapedRegexp = InterpolationHelper.escapeMessageParameter(parameters.regexp()); }