List of usage examples for org.apache.commons.lang StringUtils length
public static int length(String str)
0
if the String is null
. From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.EmailValidator.java
@Override public void validate(final Object object, final Errors errors) { final UpdateEmailForm updateEmailForm = (UpdateEmailForm) object; final String email = updateEmailForm.getEmail(); final String chkEmail = updateEmailForm.getChkEmail(); final String password = updateEmailForm.getPassword(); if (StringUtils.isEmpty(email)) { errors.rejectValue("email", "profile.email.invalid"); } else if (StringUtils.length(email) > 255 || !EMAIL_REGEX.matcher(email).matches()) { errors.rejectValue("email", "profile.email.invalid"); }/*from w w w . j av a2 s .c o m*/ if (StringUtils.isEmpty(chkEmail)) { errors.rejectValue("chkEmail", "profile.checkEmail.invalid"); } if (StringUtils.isEmpty(password)) { errors.rejectValue("password", "profile.pwd.invalid"); } }
From source file:com.acc.validator.FieldNotEmptyOrTooLongValidator.java
@Override public void validate(final Object object, final Errors errors) { Assert.notNull(errors, "Errors object must not be null"); final String fieldValue = (String) errors.getFieldValue(fieldPath); final String resultErrorMessageId = errorMessageId != null ? errorMessageId : FIELD_REQUIRED_AND_NOT_TOO_LONG_MESSAGE_ID; if (StringUtils.isBlank(fieldValue) || StringUtils.length(fieldValue) > maxLength) { errors.rejectValue(fieldPath, resultErrorMessageId, new String[] { String.valueOf(maxLength) }, null); }/*from ww w.jav a2s .c o m*/ }
From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.PasswordValidator.java
@Override public void validate(final Object object, final Errors errors) { final UpdatePasswordForm passwordForm = (UpdatePasswordForm) object; final String currPasswd = passwordForm.getCurrentPassword(); final String newPasswd = passwordForm.getNewPassword(); final String checkPasswd = passwordForm.getCheckNewPassword(); if (StringUtils.isEmpty(currPasswd)) { errors.rejectValue("currentPassword", "profile.currentPassword.invalid"); }/*from w ww . j a va 2 s . co m*/ if (StringUtils.isEmpty(newPasswd)) { errors.rejectValue("newPassword", UPDATE_PWD_INVALID); } else if (StringUtils.length(newPasswd) < 6 || StringUtils.length(newPasswd) > 255) { errors.rejectValue("newPassword", UPDATE_PWD_INVALID); } if (StringUtils.isEmpty(checkPasswd)) { errors.rejectValue("checkNewPassword", UPDATE_PWD_INVALID); } else if (StringUtils.length(checkPasswd) < 6 || StringUtils.length(checkPasswd) > 255) { errors.rejectValue("checkNewPassword", UPDATE_PWD_INVALID); } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.GuestRegisterValidator.java
@Override public void validate(final Object object, final Errors errors) { final GuestRegisterForm guestRegisterForm = (GuestRegisterForm) object; final String newPasswd = guestRegisterForm.getPwd(); final String checkPasswd = guestRegisterForm.getCheckPwd(); if (StringUtils.isNotEmpty(newPasswd) && StringUtils.isNotEmpty(checkPasswd) && !StringUtils.equals(newPasswd, checkPasswd)) { errors.rejectValue(CHECK_PWD, "validation.checkPwd.equals"); } else {//from w w w. j a v a 2 s . c om if (StringUtils.isEmpty(newPasswd)) { errors.rejectValue("pwd", "register.pwd.invalid"); } else if (StringUtils.length(newPasswd) < 6 || StringUtils.length(newPasswd) > 255) { errors.rejectValue("pwd", "register.pwd.invalid"); } if (StringUtils.isEmpty(checkPasswd)) { errors.rejectValue(CHECK_PWD, "register.checkPwd.invalid"); } else if (StringUtils.length(checkPasswd) < 6 || StringUtils.length(checkPasswd) > 255) { errors.rejectValue(CHECK_PWD, "register.checkPwd.invalid"); } } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.RestoreSaveCartFormValidator.java
@Override public void validate(final Object object, final Errors errors) { final RestoreSaveCartForm restoreSaveCartForm = (RestoreSaveCartForm) object; if (restoreSaveCartForm.getCartName() != null && !restoreSaveCartForm.isPreventSaveActiveCart()) { final String cartName = restoreSaveCartForm.getCartName(); if (StringUtils.isBlank(cartName)) { errors.rejectValue("cartName", "basket.save.cart.validation.name.notBlank"); return; }/*from www. ja v a 2s .c om*/ if (!StringUtils.isAlphanumericSpace(cartName)) { errors.rejectValue("cartName", "basket.save.cart.validation.name.charset"); return; } if (StringUtils.length(cartName) > 255) { errors.rejectValue("cartName", "basket.save.cart.validation.name.size"); return; } } }
From source file:com.pedra.storefront.forms.validation.RegistrationValidator.java
@Override public void validate(final Object object, final Errors errors) { final RegisterForm registerForm = (RegisterForm) object; final String titleCode = registerForm.getTitleCode(); final String firstName = registerForm.getFirstName(); final String lastName = registerForm.getLastName(); final String email = registerForm.getEmail(); final String pwd = registerForm.getPwd(); final String checkPwd = registerForm.getCheckPwd(); if (StringUtils.isEmpty(titleCode)) { errors.rejectValue("titleCode", "register.title.invalid"); } else if (StringUtils.length(titleCode) > 255) { errors.rejectValue("titleCode", "register.title.invalid"); }//from w ww . j av a2 s. c o m if (StringUtils.isEmpty(firstName)) { errors.rejectValue("firstName", "register.firstName.invalid"); } else if (StringUtils.length(firstName) > 255) { errors.rejectValue("firstName", "register.firstName.invalid"); } if (StringUtils.isEmpty(lastName)) { errors.rejectValue("lastName", "register.lastName.invalid"); } else if (StringUtils.length(lastName) > 255) { errors.rejectValue("lastName", "register.lastName.invalid"); } if (StringUtils.length(firstName) + StringUtils.length(lastName) > 255) { errors.rejectValue("lastName", "register.name.invalid"); errors.rejectValue("firstName", "register.name.invalid"); } if (StringUtils.isEmpty(email)) { errors.rejectValue("email", "register.email.invalid"); } else if (StringUtils.length(email) > 255 || !validateEmailAddress(email)) { errors.rejectValue("email", "register.email.invalid"); } if (StringUtils.isEmpty(pwd)) { errors.rejectValue("pwd", "register.pwd.invalid"); } else if (StringUtils.length(pwd) < 6 || StringUtils.length(pwd) > 255) { errors.rejectValue("pwd", "register.pwd.invalid"); } if (StringUtils.isNotEmpty(pwd) && StringUtils.isNotEmpty(checkPwd) && !StringUtils.equals(pwd, checkPwd)) { errors.rejectValue("checkPwd", "validation.checkPwd.equals"); } else { if (StringUtils.isEmpty(checkPwd)) { errors.rejectValue("checkPwd", "register.checkPwd.invalid"); } } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.RegistrationValidator.java
@Override public void validate(final Object object, final Errors errors) { final RegisterForm registerForm = (RegisterForm) object; final String titleCode = registerForm.getTitleCode(); final String firstName = registerForm.getFirstName(); final String lastName = registerForm.getLastName(); final String email = registerForm.getEmail(); final String pwd = registerForm.getPwd(); final String checkPwd = registerForm.getCheckPwd(); validateTitleCode(errors, titleCode); validateName(errors, firstName, "firstName", "register.firstName.invalid"); validateName(errors, lastName, "lastName", "register.lastName.invalid"); if (StringUtils.length(firstName) + StringUtils.length(lastName) > 255) { errors.rejectValue("lastName", "register.name.invalid"); errors.rejectValue("firstName", "register.name.invalid"); }/*from ww w. j a v a2 s. c om*/ validateEmail(errors, email); validatePassword(errors, pwd); comparePasswords(errors, pwd, checkPwd); }
From source file:herddb.cli.TextTableBuilder.java
private int[] colWidths() { int cols = -1; for (String[] row : rows) cols = Math.max(cols, row.length); int[] widths = new int[cols]; for (String[] row : rows) { for (int colNum = 0; colNum < row.length; colNum++) { widths[colNum] = Math.max(widths[colNum], StringUtils.length(row[colNum])); }// ww w .j a v a2 s . c o m } return widths; }
From source file:hr.fer.zemris.vhdllab.entity.FileInfo.java
@Override public String toString() { return new ToStringBuilder(this).appendSuper(super.toString()).append("type", type) .append("dataLength", StringUtils.length(data)).toString(); }
From source file:hr.fer.zemris.vhdllab.entity.PreferencesFile.java
@Override public String toString() { return new ToStringBuilder(this).appendSuper(super.toString()) .append("dataLength", StringUtils.length(data)).toString(); }