當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。