Example usage for org.apache.commons.validator Field getProperty

List of usage examples for org.apache.commons.validator Field getProperty

Introduction

In this page you can find the example usage for org.apache.commons.validator Field getProperty.

Prototype

public String getProperty() 

Source Link

Document

Gets the property name of the field.

Usage

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if field is positive assuming it is an integer
 * //www .  jav  a 2 s.  c  o m
 * @param    value       The value validation is being performed on.
 * @param    field       Description of the field to be evaluated
 * @return   boolean     If the integer field is greater than zero, returns
 *                        true, otherwise returns false.
 */
public static boolean validatePositive(Object bean, Field field) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatInt(value).intValue() > 0;
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>long</code>.
 *
 * @param    value       The value validation is being performed on.
 * @return   boolean      If the field can be successfully converted 
 *                           to a <code>long</code> <code>true</code> is returned.  
 *                           Otherwise <code>false</code>.
 *//*from   ww w  .ja v a2  s .  c o m*/
public static boolean validateLong(Object bean, Field field) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericValidator.isLong(value);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>float</code>.
 *
 * @param    value       The value validation is being performed on.
 * @return   boolean      If the field can be successfully converted 
 *                           to a <code>float</code> <code>true</code> is returned.  
 *                           Otherwise <code>false</code>.
 *//*w ww.j  a  v  a2 s .  c o m*/
public static boolean validateFloat(Object bean, Field field) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericValidator.isFloat(value);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>double</code>.
 *
 * @param    value       The value validation is being performed on.
 * @return   boolean      If the field can be successfully converted 
 *                           to a <code>double</code> <code>true</code> is returned.  
 *                           Otherwise <code>false</code>.
 *//*w w  w. j av  a  2s .c  o  m*/
public static boolean validateDouble(Object bean, Field field) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericValidator.isDouble(value);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>date</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>date</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *//*from   w  w w  . j  ava 2 s .  co  m*/
public static Date validateDate(Object bean, Field field) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
    String datePattern = field.getVarValue("datePattern");
    String datePatternStrict = field.getVarValue("datePatternStrict");

    Date result = null;
    if (datePattern != null && datePattern.length() > 0) {
        result = GenericTypeValidator.formatDate(value, datePattern, false);
    } else if (datePatternStrict != null && datePatternStrict.length() > 0) {
        result = GenericTypeValidator.formatDate(value, datePatternStrict, true);
    }

    return result;
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>byte</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>byte</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *//* ww  w .  j av a2 s . c  om*/
public static Byte validateByte(Object bean, Field field, Locale locale) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatByte(value, locale);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>short</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>short</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *///from   w w  w .  j ava2s.c  o m
public static Short validateShort(Object bean, Field field, Locale locale) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatShort(value, locale);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>int</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>int</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *///from w  w  w .ja va2  s.c o m
public static Integer validateInt(Object bean, Field field, Locale locale) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatInt(value, locale);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>long</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>long</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *//*from  w w w.  j ava2s. c om*/
public static Long validateLong(Object bean, Field field, Locale locale) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatLong(value, locale);
}

From source file:com.core.validators.CommonValidator.java

/**
 * Checks if the field can be successfully converted to a <code>float</code>.
 *
 * @param value The value validation is being performed on.
 * @return boolean If the field can be successfully converted 
 * to a <code>float</code> <code>true</code> is returned.  
 * Otherwise <code>false</code>.
 *//*from www  . j  a va  2 s . c o  m*/
public static Float validateFloat(Object bean, Field field, Locale locale) {
    String value = ValidatorUtils.getValueAsString(bean, field.getProperty());

    return GenericTypeValidator.formatFloat(value, locale);
}