本文整理汇总了Java中org.apache.commons.validator.GenericValidator.isBlankOrNull方法的典型用法代码示例。如果您正苦于以下问题:Java GenericValidator.isBlankOrNull方法的具体用法?Java GenericValidator.isBlankOrNull怎么用?Java GenericValidator.isBlankOrNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.validator.GenericValidator
的用法示例。
在下文中一共展示了GenericValidator.isBlankOrNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateEmail
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if a field has a valid e-mail address.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return True if valid, false otherwise.
*/
public static boolean validateEmail(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (!GenericValidator.isBlankOrNull(value) && !GenericValidator.isEmail(value)) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
return false;
} else {
return true;
}
}
示例2: isValidAuthorityHostNoDot
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Check if the authority contains a valid hostname without "."
* characters and an optional port number
*
* @param authority
* @return <code>true</code> if the authority is valid
*/
private boolean isValidAuthorityHostNoDot(String authority) {
Perl5Util authorityMatcher = new Perl5Util();
if (authority != null
&& authorityMatcher.match(
"/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
String hostIP = authorityMatcher.group(1);
if (hostIP.indexOf('.') < 0) {
// the hostname contains no dot, add domain validation to check invalid hostname like "g08fnstd110825-"
DomainValidator domainValidator = DomainValidator.getInstance(true);
if(!domainValidator.isValid(hostIP)) {
return false;
}
String port = authorityMatcher.group(2);
if (!isValidPort(port)) {
return false;
}
String extra = authorityMatcher.group(3);
return GenericValidator.isBlankOrNull(extra);
} else {
return false;
}
} else {
return false;
}
}
示例3: isSecurityInfo
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Either question and answer are not set or both must be set.
*
* @param question
* the security question.
* @param answer
* the security answer.
*/
public static void isSecurityInfo(String question, String answer)
throws ValidationException {
BLValidator.isDescription("securityQuestion", question, false);
BLValidator.isDescription("securityAnswer", answer, false);
if (!GenericValidator.isBlankOrNull(question)
|| !GenericValidator.isBlankOrNull(answer)) {
if (GenericValidator.isBlankOrNull(question)
|| GenericValidator.isBlankOrNull(answer)) {
ValidationException vf = new ValidationException(
ReasonEnum.SECURITY_INFO, null, null);
logValidationFailure(vf);
throw vf;
}
}
}
示例4: updatePlatformUser
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Updates all fields in the platform user object for which a LDAP attribute
* is configured. <br>
* The filed "userid", will not be updated since it's possible that the new
* LDAP user id is not unique in BES. For this reason the field
* "realmuserid" will be updated to be in sync with LDAP.
*
* @param userDetails
* The value object containing the values to be set.
* @param settingList
* The list with the configured LDAP attributes.
* @param userToBeUpdated
* The platform user object to be updated.
* @return The updated platform user object.
* @throws ValidationException
* Thrown if the validation of the value objects failed.
*/
public static PlatformUser updatePlatformUser(VOUserDetails userDetails,
List<SettingType> settingList, PlatformUser userToBeUpdated) {
for (int i = 0; i < settingList.size(); i++) {
if (settingList.get(i) == SettingType.LDAP_ATTR_ADDITIONAL_NAME) {
userToBeUpdated.setAdditionalName(userDetails
.getAdditionalName());
} else if (settingList.get(i) == SettingType.LDAP_ATTR_EMAIL) {
if (!GenericValidator.isBlankOrNull(userDetails.getEMail())) {
userToBeUpdated.setEmail(userDetails.getEMail());
}
} else if (settingList.get(i) == SettingType.LDAP_ATTR_FIRST_NAME) {
userToBeUpdated.setFirstName(userDetails.getFirstName());
} else if (settingList.get(i) == SettingType.LDAP_ATTR_LAST_NAME) {
userToBeUpdated.setLastName(userDetails.getLastName());
} else if (settingList.get(i) == SettingType.LDAP_ATTR_UID) {
// Do not update the userid here because a update can violate
// the unique constraint in BES.
userToBeUpdated.setRealmUserId((userDetails.getRealmUserId()));
}
}
return userToBeUpdated;
}
示例5: validateRequired
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field isn't null and length of the field is greater than zero not
* including whitespace.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if
* any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if meets stated requirements, false otherwise.
*/
public static boolean validateRequired(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
return false;
} else {
return true;
}
}
示例6: validateInteger
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to an int primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateInteger(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatInt(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例7: validateLong
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a long primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateLong(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatLong(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例8: validateFloat
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a float primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateFloat(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatFloat(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例9: validateDouble
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a double primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateDouble(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatDouble(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例10: validateDoubleLocale
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a double primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateDoubleLocale(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
Locale locale = RequestUtils.getUserLocale(request, null);
result = GenericTypeValidator.formatDouble(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例11: matchRegExp
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public boolean matchRegExp(String regExp, String inputValue){
boolean validation = true;
MiscUtils.getLogger().debug("matchRegExp function is called.");
if (!GenericValidator.isBlankOrNull(regExp) && !GenericValidator.isBlankOrNull(inputValue)){
MiscUtils.getLogger().debug("both the regExp and inputValue is not blank nor null.");
if(!inputValue.matches(regExp)){
MiscUtils.getLogger().debug("Regexp not matched");
validation=false;
}
}
return validation;
}
示例12: validateRequired
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field is required.
*
* @return boolean If the field isn't <code>null</code> and
* has a length greater than zero, <code>true</code> is returned.
* Otherwise <code>false</code>.
*/
public static boolean validateRequired(Object bean, Field field) {
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
String labelName = field.getProperty() + "Label";
try {
JLabel label = (JLabel)PropertyUtils.getProperty(bean, labelName);
String text = label.getText();
int ind = text.indexOf("*");
if (ind == -1){
label.setText(text + "*");
}
} catch (Exception e) {
}
return !GenericValidator.isBlankOrNull(value);
}
示例13: validateFloat
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a float primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateFloat(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatFloat(value);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例14: validateLongLocale
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a long primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateLongLocale(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
Locale locale = RequestUtils.getUserLocale(request, null);
result = GenericTypeValidator.formatLong(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例15: validateByte
import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
* Checks if the field can safely be converted to a byte primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently
* being performed.
* @param field The <code>Field</code> object associated with the
* current field being validated.
* @param errors The <code>ActionMessages</code> object to add errors
* to if any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateByte(Object bean, ValidatorAction va,
Field field, ActionMessages errors, Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
value = evaluateBean(bean, field);
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatByte(value);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}