List of usage examples for org.apache.commons.lang StringUtils isAlphanumeric
public static boolean isAlphanumeric(String str)
Checks if the String contains only unicode letters or digits.
From source file:hr.fer.spocc.export.DotExporter.java
public static String toDotString(ParseTree parseTree, String graphName) { Validate.isTrue(!graphName.isEmpty() && StringUtils.isAlphanumeric(graphName) && Character.isLetter(graphName.charAt(0))); StringBuilder dotString = new StringBuilder(); dotString.append("digraph ").append(graphName).append(" {\n"); Map<ParseTreeNode, String> nodePrefixMap = new LinkedHashMap<ParseTreeNode, String>(); toDotNodes(parseTree.getRoot(), new StringBuilder(), nodePrefixMap, dotString); toDotEdges(parseTree.getRoot(), nodePrefixMap, dotString); dotString.append("}\n"); return dotString.toString(); }
From source file:com.smartitengineering.util.opensearch.impl.RelImpl.java
public RelImpl(String value) { if (StringUtils.isBlank(value) || !StringUtils.isAlphanumeric(value)) { throw new IllegalArgumentException("Rel value must be alphanumeric non-blank"); }//from w w w . jav a 2 s .c om this.value = value.toLowerCase(); }
From source file:de.tudarmstadt.ukp.dkpro.tc.api.features.util.FeatureUtil.java
/** * Escapes the names, as Weka does not seem to like special characters in attribute names. * @param name// w ww. ja v a 2s . c om * @return */ public static String escapeFeatureName(String name) { // TODO Issue 120: improve the escaping // the fix was necessary due to Issue 32 // http://code.google.com/p/dkpro-tc/issues/detail?id=32 StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); i++) { String c = name.substring(i, i + 1); if (StringUtils.isAlphanumeric(c) || c.equals("_")) { sb.append(c); } else { sb.append("u"); sb.append(c.codePointAt(0)); } } return sb.toString(); }
From source file:GestoreAccountLocale.GestoreAccountLocale.java
private static void checkUsername(String username) throws VincoliInputException { if (username == null) { throw new VincoliInputException(ErrorLabels.USER_NOT_SPECIFICIED_ITA); }//from w w w .j ava 2s . c o m if (!(username.length() >= 4 && username.length() <= 20)) { throw new VincoliInputException(ErrorLabels.USER_LENGTH_ERROR_ITA); } if (!StringUtils.isAlphanumeric(username)) { throw new VincoliInputException(ErrorLabels.USER_IS_NOT_ALPHANUMERIC_ITA); } }
From source file:internal.analyzers.filters.AlphaNumericFilter.java
@Override protected boolean accept() throws IOException { String token = this.input.getAttribute(CharTermAttribute.class).toString().trim(); return StringUtils.isAlphanumeric(token); }
From source file:net.sf.sail.webapp.presentation.validators.UserDetailsValidator.java
public void validate(Object userDetailsIn, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.password.not-specified"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.not-specified"); if (errors.getFieldErrorCount("username") > 0) { return;//from ww w.j av a 2 s. com } MutableUserDetails userDetails = (MutableUserDetails) userDetailsIn; if (!StringUtils.isAlphanumeric(userDetails.getUsername())) { errors.rejectValue("username", "error.username.illegal-characters"); } if (userDetails.getUsername().length() > MAX_USERNAME_LENGTH) { errors.rejectValue("username", "error.username.too-long"); } if (errors.hasErrors()) userDetails.setPassword(""); }
From source file:net.sf.sail.webapp.presentation.validators.GroupParametersValidator.java
/** * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors) *///from www . j a v a 2 s . c o m public void validate(Object groupParametersIn, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.groupname.not-specified"); if (errors.getFieldErrorCount("name") > 0) { return; } GroupParameters groupParameters = (GroupParameters) groupParametersIn; if (!StringUtils.isAlphanumeric(groupParameters.getName())) { errors.rejectValue("name", "error.groupname.illegal-characters"); } if (groupParameters.getName().length() > MAX_GROUP_NAME_LENGTH) { errors.rejectValue("name", "error.groupname.too-long"); } if (groupParameters.getParentId() < 0) { errors.rejectValue("parentId", "error.groupparent.must-be-non-negative"); } }
From source file:fr.treeptik.cloudunit.utils.CheckUtils.java
/** * Valid Classic + Syntax input/* ww w .j av a 2s .c o m*/ * * @param field * @param message * @throws CheckException */ public static void validateSyntaxInput(String field, String message) throws CheckException { if (field == null || field.trim().length() == 0 || "undefined".equals(field) || field.length() > 15 || !StringUtils.isAlphanumeric(field)) { String messageTranslated = messageSource.getMessage(message, null, Locale.ENGLISH); throw new CheckException(messageTranslated); } }
From source file:GestoreAccountLocale.GestoreAccountLocale.java
private static void checkPassword(String password) throws VincoliInputException { if (password == null) { throw new VincoliInputException(ErrorLabels.PASSWORD_NOT_SPECIFIED_ITA); }/*from w w w . jav a 2 s . c o m*/ if (!(password.length() >= 8 && password.length() <= 20)) { throw new VincoliInputException(ErrorLabels.PASSWORD_LENGTH_ERROR_ITA); } if (!StringUtils.isAlphanumeric(password)) { throw new VincoliInputException(ErrorLabels.PASSWORD_IS_NOT_ALPHANUMERIC_ITA); } }
From source file:GestoreAccountLocale.GestoreAccountLocale.java
private static void checkNome(String nome) throws VincoliInputException { if (nome == null) { throw new VincoliInputException(ErrorLabels.NOME_NOT_SPECIFICIED_ITA); }//from w w w .j a va 2 s . co m if (!(nome.length() >= 1 && nome.length() <= 50)) { throw new VincoliInputException(ErrorLabels.NOME_LENGTH_ERROR_ITA); } if (!StringUtils.isAlphanumeric(nome)) { throw new VincoliInputException(ErrorLabels.NOME_IS_NOT_ALPHANUMERIC_ITA); } }