java类javax.validation.constraints.Pattern.Flag的实例源码

PatternValidator.java 文件源码 项目:gwt-bean-validators 阅读 28 收藏 0 点赞 0 评论 0
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;
}
EmailValidator.java 文件源码 项目:gwt-bean-validators 阅读 27 收藏 0 点赞 0 评论 0
@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);
    }
  }
}
EmailValidator.java 文件源码 项目:gwt-bean-validators 阅读 32 收藏 0 点赞 0 评论 0
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;
}
BeanPropertyBeanValidationPostProcessor.java 文件源码 项目:holon-core 阅读 20 收藏 0 点赞 0 评论 0
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];
}
PatternValidator.java 文件源码 项目:gwt-bean-validators 阅读 31 收藏 0 点赞 0 评论 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());
}


问题


面经


文章

微信
公众号

扫码关注公众号