List of usage examples for java.util.regex Pattern matches
public static boolean matches(String regex, CharSequence input)
From source file:com.orange.clara.cloud.cf.servicebroker.dbaas.infrastructure.CredentialsGeneratorServiceDefaultImpl.java
/** * @return - a 8 characters password with at least one digit, one lower case character, one upper case character, without specials characters *//*from w w w .j a v a 2s. c o m*/ public String randomPassword() { while (true) { //because RandomStringUtils.randomAlphanumeric(8) may produce String with no digit or no upper case letter, we should iterate final String s = RandomStringUtils.randomAlphanumeric(8); if (Pattern.matches(PASSWORD_REGEX, s)) return s; } }
From source file:com.predic8.membrane.core.interceptor.rewrite.RegExURLRewriteInterceptor.java
private String findFirstMatchingRegEx(String uri) { for (String regex : mapping.keySet()) { if (Pattern.matches(regex, uri)) return regex; }// w ww .java2s.com return null; }
From source file:mobile.service.RNSService.java
/** * /*from ww w. j a v a 2 s.c om*/ * * @param title * @param industryId Id * @param info ?? * @param budget ??8?1?? * @param skillsTags * @param attachs Id?? * @return */ public static ServiceVOResult<CommonVO> createRequire(String title, Long industryId, String info, String budget, List<String> skillsTags, List<Long> attachs) { if (StringUtils.isBlank(title)) { return ServiceVOResult.error("100005", "?"); } SkillTag tag = SkillTag.getTagById(industryId); if (null == tag || tag.getTagType() != SkillTag.TagType.CATEGORY) { return ServiceVOResult.error("100005", "Id" + industryId); } if (!Pattern.matches("^\\d{0,8}(\\.\\d)?$", budget) && !"-1".equals(budget)) { return ServiceVOResult.error("100005", "??8?1??"); } if (null != attachs && attachs.size() > 5) { return ServiceVOResult.error("1006", "??"); } ObjectNode data = Json.newObject(); data.put("title", title); data.put("info", info); data.put("budget", budget); data.put("industry", industryId); data.set("tags", Json.toJson(skillsTags)); if (null != attachs) { ArrayNode attachsNode = Json.newObject().arrayNode(); for (Long attachId : attachs) { ObjectNode attachNode = Json.newObject(); attachNode.put("attachId", attachId); attachsNode.add(attachNode); } data.set("attachs", attachsNode); } ObjectNodeResult objectNodeResult = new ObjectNodeResult(); ServiceResult createResult = createOrUpdateRequire(data, objectNodeResult); if (!createResult.isSuccess()) { return ServiceVOResult.create(createResult); } CommonVO vo = CommonVO.create(); vo.set("requireId", objectNodeResult.getObjectNode().path("requireId").asLong(-1)); return ServiceVOResult.success(vo); }
From source file:org.xinta.eazycode.components.shiro.web.validator.SignupValidator.java
public void validate(Object o, Errors errors) { SignupVO command = (SignupVO) o;/*from ww w . j a va2 s.c om*/ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "loginName", "error.username.empty", "Please specify a loginName."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.username.empty", "Please specify a loginName."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "error.email.empty", "Please specify an email address."); if (StringUtils.hasText(command.getEmail()) && !Pattern.matches(SIMPLE_EMAIL_REGEX, command.getEmail().toUpperCase())) { errors.rejectValue("email", "error.email.invalid", "Please enter a valid email address."); } ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.password.empty", "Please specify a password."); }
From source file:com.tencent.wetest.common.util.DeviceUtil.java
/** * ?CPU//from w w w . java 2s. c o m * @return CPU */ public static int getCpuCoreNum() { class CpuFilter implements FileFilter { public boolean accept(File pathname) { if (Pattern.matches("cpu[0-9]", pathname.getName())) { return true; } return false; } } try { File dir = new File("/sys/devices/system/cpu/"); File[] files = dir.listFiles(new CpuFilter()); return files.length; } catch (Exception e) { return 1; } }
From source file:org.shredzone.cilla.web.tag.IfBrowserTag.java
@Override public int doStartTag() throws JspException { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); String ua = req.getHeader("User-Agent"); if (ua != null && Pattern.matches(agent, ua)) { return EVAL_BODY_INCLUDE; }/*ww w .ja v a 2 s . c om*/ return SKIP_BODY; }
From source file:com.cyclopsgroup.tornado.security.SimpleAsset.java
/** * Override method authorize in class SimpleAbstractAsset * * @see com.cyclopsgroup.tornado.security.Asset#authorize(com.cyclopsgroup.tornado.security.Permission) *///from w w w. j a v a 2s.c o m public boolean authorize(Permission permission) { if (!(permission instanceof SimplePermission)) { return false; } SimplePermission sp = (SimplePermission) permission; if (StringUtils.equals(expression, sp.getExpression())) { return true; } String pattern = '^' + sp.getExpression() + '$'; return Pattern.matches(pattern, expression); }
From source file:net.noday.d4c.service.LoginService.java
private int getLoginType(String loginName) { if (Pattern.matches("\\w+\\.\\w+\\.\\w+$", loginName)) { return 2; } else if (Pattern.matches("\\w+\\.\\w+$", loginName)) { return 1; }//from w w w . j a v a2 s.c o m return 0; }
From source file:com.baidu.rigel.biplatform.ac.util.MetaNameUtil.java
/** * ??UniqueName?//from w w w .ja v a 2 s . c o m * * @param uniqueName UniqueName * @return ?UniqueName */ public static boolean isUniqueName(String uniqueName) { if (StringUtils.isNotBlank(uniqueName) && Pattern.matches(UNIQUE_NAME_REGEX, uniqueName)) { return true; } return false; }
From source file:com.qualogy.qafe.bind.core.pattern.WildCardPattern.java
public boolean matches(String toMatch) { return Pattern.matches(toRegex(), toMatch); }