Java Code Examples for org.apache.commons.lang3.StringUtils.length()

The following are Jave code examples for showing how to use length() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: fat-lining   File: ValidationUtils.java   View Source Code Vote up 5 votes
/**
 * Validate passwords input
 * <ul>
 *  <li>password is not empty</li>
 *  <li>password has appropriate length</li>
 *  <li>password and repeated password match</li>
 * </ul>
 * @param password to validate
 * @param repeatedPassword to validate
 * @param errors resulting to validation
 */
public void validatePasswords(String password, String repeatedPassword, Errors errors) {
	String cleanPassword = StringUtils.trimToEmpty(password);
	if (StringUtils.isBlank(cleanPassword)) {
		errors.rejectValue("password", "validation.error.password.blank");
	} else if (StringUtils.length(cleanPassword) < config.getPasswordLength()) {
		errors.rejectValue("password", "validation.error.password.tooShort", new Object[]{config.getPasswordLength()}, StringUtils.EMPTY);
	} else {
		String cleanRepeatedPassword = StringUtils.trimToEmpty(repeatedPassword);
		if (!StringUtils.equals(cleanPassword, cleanRepeatedPassword)) {
			errors.rejectValue("repeatedPassword", "validation.error.password.noMatch");
		}
	}
	
}
 
Example 2
Project: cyberduck   File: InfoController.java   View Source Code Vote up 5 votes
/**
 * Permission value from input field.
 *
 * @return Null if invalid string has been entered entered,
 */
private Permission getPermissionFromOctalField() {
    if(StringUtils.isNotBlank(octalField.stringValue())) {
        if(StringUtils.length(octalField.stringValue()) >= 3) {
            if(StringUtils.isNumeric(octalField.stringValue())) {
                return new Permission(Integer.valueOf(octalField.stringValue()).intValue());
            }
        }
    }
    log.warn(String.format("Invalid octal field input %s", octalField.stringValue()));
    return null;
}
 
Example 3
Project: cyberduck   File: PermissionOverwrite.java   View Source Code Vote up 5 votes
public PermissionOverwrite fromOctal(final String input) {
    if(StringUtils.isBlank(input)) {
        return null;
    }
    if(StringUtils.length(input) != 3) {
        return null;
    }
    if(!StringUtils.isNumeric(input)) {
        return null;
    }
    this.user.parse(input.charAt(0));
    this.group.parse(input.charAt(1));
    this.other.parse(input.charAt(2));
    return this;
}
 
Example 4
Project: vscrawler   File: Length.java   View Source Code Vote up 4 votes
@Override
protected Integer handle(String input) {
    return StringUtils.length(input);
}