本文整理汇总了Java中org.apache.commons.validator.GenericTypeValidator类的典型用法代码示例。如果您正苦于以下问题:Java GenericTypeValidator类的具体用法?Java GenericTypeValidator怎么用?Java GenericTypeValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericTypeValidator类属于org.apache.commons.validator包,在下文中一共展示了GenericTypeValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateShort
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to a short 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 validateShort(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.formatShort(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例2: validateInteger
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例3: validateLong
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例4: validateFloat
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例5: validateDouble
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例6: validateByte
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例7: validateByteLocale
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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 validateByteLocale(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.formatByte(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例8: validateShort
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to a short 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 validateShort(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.formatShort(value);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例9: validateShortLocale
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的package包/类
/**
* Checks if the field can safely be converted to a short 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 validateShortLocale(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.formatShort(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例10: validateInteger
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
value = evaluateBean(bean, field);
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;
}
示例11: validateIntegerLocale
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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 validateIntegerLocale(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.formatInt(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}
示例12: validateLong
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
value = evaluateBean(bean, field);
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;
}
示例13: validateLongLocale
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例14: validateFloat
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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;
}
示例15: validateFloatLocale
import org.apache.commons.validator.GenericTypeValidator; //导入依赖的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 validateFloatLocale(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.formatFloat(value, locale);
if (result == null) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va, field));
}
return (result == null) ? Boolean.FALSE : result;
}