Java 类javax.validation.constraints.Pattern.Flag 实例源码

项目:gwt-bean-validators    文件:PatternValidator.java   
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;
}
项目:gwt-bean-validators    文件:EmailValidator.java   
@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);
    }
  }
}
项目:gwt-bean-validators    文件:EmailValidator.java   
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;
}
项目:holon-core    文件:BeanPropertyBeanValidationPostProcessor.java   
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];
}
项目:gwt-bean-validators    文件:PatternValidator.java   
@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());
}