当前位置: 首页>>代码示例>>Java>>正文


Java Pattern.Flag方法代码示例

本文整理汇总了Java中javax.validation.constraints.Pattern.Flag方法的典型用法代码示例。如果您正苦于以下问题:Java Pattern.Flag方法的具体用法?Java Pattern.Flag怎么用?Java Pattern.Flag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.validation.constraints.Pattern的用法示例。


在下文中一共展示了Pattern.Flag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import javax.validation.constraints.Pattern; //导入方法依赖的package包/类
@Override
public void validate(Pattern patternAnnotation, String name, ValidationContext validationCtx, Errors e) {
    Object value = validationCtx.value(name);

    if (value == null || Str.isEmpty(patternAnnotation.regexp()))
        return;

    String pattern = patternAnnotation.regexp();
    Pattern.Flag[] flags = patternAnnotation.flags();

    int flagBits = 0;
    for (Pattern.Flag flag : flags) {
        flagBits |= flag.getValue();
    }

    java.util.regex.Pattern regexPattern = java.util.regex.Pattern.compile(pattern, flagBits);
    Matcher m = regexPattern.matcher(String.valueOf(value));

    if (!m.matches())
        e.add(name, patternAnnotation.message());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:22,代码来源:PatternValidationAdapter.java

示例2: initialize

import javax.validation.constraints.Pattern; //导入方法依赖的package包/类
@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);
    }
  }
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:20,代码来源:EmailValidator.java

示例3: initialize

import javax.validation.constraints.Pattern; //导入方法依赖的package包/类
public void initialize(PatternMatchIfNotNullNotEmpty parameters) {
	Pattern.Flag flags[] = parameters.flags();
	int intFlag = 0;
	for ( Pattern.Flag flag : flags ) {
		intFlag = intFlag | flag.getValue();
	}
	
	String regexp = resolveRegexp(parameters);	
	messageSource = parameters.messageSource();
	messageKey = parameters.messageKey();

	try {
		pattern = java.util.regex.Pattern.compile(regexp, intFlag );
	}
	catch ( PatternSyntaxException e ) {
		throw new IllegalArgumentException( "Invalid regular expression.", e );
	}
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:19,代码来源:CustomPatternValidator.java

示例4: combineFlags

import javax.validation.constraints.Pattern; //导入方法依赖的package包/类
/**
 * Combines a given set of javax.validation.constraints.Pattern.Flag instances into one bitmask suitable for
 * java.util.regex.Pattern consumption.
 *
 * @param flags - list of javax.validation.constraints.Pattern.Flag instances to combine
 * @return combined bitmask for regex flags
 */
private int combineFlags(final Pattern.Flag[] flags) {
    int combined = 0;
    for (Pattern.Flag f : flags) {
        combined |= f.getValue();
    }
    return combined;
}
 
开发者ID:canoo,项目名称:dolphin-platform,代码行数:15,代码来源:PatternPropertyValidator.java

示例5: initialize

import javax.validation.constraints.Pattern; //导入方法依赖的package包/类
@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());
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:15,代码来源:PatternValidator.java


注:本文中的javax.validation.constraints.Pattern.Flag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。