当前位置: 首页>>代码示例>>Java>>正文


Java GenericValidator.isInRange方法代码示例

本文整理汇总了Java中org.apache.commons.validator.GenericValidator.isInRange方法的典型用法代码示例。如果您正苦于以下问题:Java GenericValidator.isInRange方法的具体用法?Java GenericValidator.isInRange怎么用?Java GenericValidator.isInRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.validator.GenericValidator的用法示例。


在下文中一共展示了GenericValidator.isInRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public boolean isInRange(Double dMax, Double dMin, String inputValue){

        boolean validation = true;
        
        if ((dMax != null && dMax!=0) || (dMin != null && dMin!=0)){
            if(GenericValidator.isDouble(inputValue)){
                double dValue = Double.parseDouble(inputValue);
                
                if (!GenericValidator.isInRange(dValue, dMin, dMax)){                                       
                    validation=false;
                }
            }
            else if(!GenericValidator.isBlankOrNull(inputValue)){                                
                validation=false;
            }
        }
        return validation;
    }
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:19,代码来源:EctValidation.java

示例2: validateInteger

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private List<? extends ErrorReport> validateInteger( Class<?> klass, Object propertyObject, Property property )
{
    List<ErrorReport> errorReports = new ArrayList<>();

    if ( !Integer.class.isInstance( propertyObject ) )
    {
        return errorReports;
    }

    Integer value = (Integer) propertyObject;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        errorReports.add( new ErrorReport( klass, ErrorCode.E4008, property.getName(), property.getMin(), property.getMax(), value )
            .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) );
    }

    return errorReports;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:20,代码来源:DefaultSchemaValidator.java

示例3: validateFloat

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private List<? extends ErrorReport> validateFloat( Class<?> klass, Object propertyObject, Property property )
{
    List<ErrorReport> errorReports = new ArrayList<>();

    if ( !Float.class.isInstance( propertyObject ) )
    {
        return errorReports;
    }

    Float value = (Float) propertyObject;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        errorReports.add( new ErrorReport( klass, ErrorCode.E4008, property.getName(), property.getMin(), property.getMax(), value )
            .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) );
    }

    return errorReports;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:20,代码来源:DefaultSchemaValidator.java

示例4: validateDouble

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private List<? extends ErrorReport> validateDouble( Class<?> klass, Object propertyObject, Property property )
{
    List<ErrorReport> errorReports = new ArrayList<>();

    if ( !Double.class.isInstance( propertyObject ) )
    {
        return errorReports;
    }

    Double value = (Double) propertyObject;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        errorReports.add( new ErrorReport( klass, ErrorCode.E4008, property.getName(), property.getMin(), property.getMax(), value )
            .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) );
    }

    return errorReports;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:20,代码来源:DefaultSchemaValidator.java

示例5: validateInteger

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private Collection<? extends ValidationViolation> validateInteger( Object object, Property property )
{
    List<ValidationViolation> validationViolations = new ArrayList<>();

    if ( !Integer.class.isInstance( object ) )
    {
        return validationViolations;
    }

    Integer value = (Integer) object;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
            + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
    }

    return validationViolations;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:20,代码来源:DefaultSchemaValidator.java

示例6: validateFloat

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private Collection<? extends ValidationViolation> validateFloat( Object object, Property property )
{
    List<ValidationViolation> validationViolations = new ArrayList<>();

    if ( !Float.class.isInstance( object ) )
    {
        return validationViolations;
    }

    Float value = (Float) object;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
            + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
    }

    return validationViolations;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:20,代码来源:DefaultSchemaValidator.java

示例7: validateDouble

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
private Collection<? extends ValidationViolation> validateDouble( Object object, Property property )
{
    List<ValidationViolation> validationViolations = new ArrayList<>();

    if ( !Double.class.isInstance( object ) )
    {
        return validationViolations;
    }

    Double value = (Double) object;

    if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
    {
        validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
            + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
    }

    return validationViolations;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:20,代码来源:DefaultSchemaValidator.java

示例8: isInRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
public boolean isInRange(double dMax, double dMin, String inputValue){

        boolean validation = true;
        org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator();
        
        if ((dMax!=0) || (dMin!=0)){
            if(GenericValidator.isDouble(inputValue)){
                double dValue = Double.parseDouble(inputValue);
                
                if (!GenericValidator.isInRange(dValue, dMin, dMax)){                                       
                    validation=false;
                }
            }
            else if(!GenericValidator.isBlankOrNull(inputValue)){                                
                validation=false;
            }
        }
        return validation;
    }
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:20,代码来源:EctValidation.java

示例9: validateLongRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 * 長整数が指定した範囲内かどうかをチェックします。
 * 
 * @param bean
 *            JavaBeans
 * @param validatorAction
 *            バリデータアクション
 * @param field
 *            フィールド定義
 * @param errors
 *            エラーメッセージの入れ物
 * @param validator
 *            バリデータ
 * @param request
 *            リクエスト
 * @return 検証結果がOKかどうか
 */
public static boolean validateLongRange(Object bean,
        ValidatorAction validatorAction, Field field,
        ActionMessages errors, Validator validator,
        HttpServletRequest request) {
    String value = getValueAsString(bean, field);
    if (!GenericValidator.isBlankOrNull(value)) {
        try {
            long longValue = Long.parseLong(value);
            long min = Long.parseLong(field.getVarValue("min"));
            long max = Long.parseLong(field.getVarValue("max"));
            if (!GenericValidator.isInRange(longValue, min, max)) {
                addError(errors, field, validator, validatorAction, request);
                return false;
            }
        } catch (Exception e) {
            addError(errors, field, validator, validatorAction, request);
            return false;
        }
    }
    return true;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:39,代码来源:S2FieldChecks.java

示例10: isNonNegativeNumber

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 * Validates that the given input is not a negative number.
 * 
 * @param member
 *            The indicator of the field to be validated.
 * @param inputValue
 *            The value to be validated.
 * @throws ValidationException
 *             Thrown in case the value is negative.
 */
public static void isNonNegativeNumber(String member, long inputValue)
        throws ValidationException {
    if (!GenericValidator.isInRange(inputValue, 0L, Long.MAX_VALUE)) {
        ValidationException vf = new ValidationException(
                ReasonEnum.POSITIVE_NUMBER, member,
                new Object[] { Long.valueOf(inputValue) });
        logValidationFailure(vf);
        throw vf;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:BLValidator.java

示例11: validateIntRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 * Checks if a fields value is within a range (min &amp; max specified in the
 * vars attribute).
 *
 * @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 in range, false otherwise.
 */
public static boolean validateIntRange(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)) {
        try {
            int intValue = Integer.parseInt(value);
            int min = Integer.parseInt(field.getVarValue("min"));
            int max = Integer.parseInt(field.getVarValue("max"));

            if (!GenericValidator.isInRange(intValue, min, max)) {
                errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));

                return false;
            }
        } catch (Exception e) {
            errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
            return false;
        }
    }

    return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:FieldChecks.java

示例12: validateDoubleRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 *  Checks if a fields value is within a range (min &amp; max specified in the
 *  vars attribute).
 *
 * @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 in range, false otherwise.
 */
public static boolean validateDoubleRange(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)) {
        try {
            double doubleValue = Double.parseDouble(value);
            double min = Double.parseDouble(field.getVarValue("min"));
            double max = Double.parseDouble(field.getVarValue("max"));

            if (!GenericValidator.isInRange(doubleValue, min, max)) {
                errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));

                return false;
            }
        } catch (Exception e) {
            errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
            return false;
        }
    }

    return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:FieldChecks.java

示例13: validateFloatRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 *  Checks if a fields value is within a range (min &amp; max specified in the
 *  vars attribute).
 *
 * @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 in range, false otherwise.
 */
public static boolean validateFloatRange(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)) {
        try {
            float floatValue = Float.parseFloat(value);
            float min = Float.parseFloat(field.getVarValue("min"));
            float max = Float.parseFloat(field.getVarValue("max"));

            if (!GenericValidator.isInRange(floatValue, min, max)) {
                errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));

                return false;
            }
        } catch (Exception e) {
            errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
            return false;
        }
    }

    return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:FieldChecks.java

示例14: validateLongRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 * Checks if a fields value is within a range (min &amp; max specified in
 * the vars attribute).
 *
 * @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 in range, false otherwise.
 */
public static boolean validateLongRange(Object bean, ValidatorAction va,
    Field field, ActionMessages errors, Validator validator,
    HttpServletRequest request) {
    String value = null;

    value = evaluateBean(bean, field);

    if (!GenericValidator.isBlankOrNull(value)) {
        try {
            String minVar =
                Resources.getVarValue("min", field, validator, request, true);
            String maxVar =
                Resources.getVarValue("max", field, validator, request, true);
            long longValue = Long.parseLong(value);
            long min = Long.parseLong(minVar);
            long max = Long.parseLong(maxVar);

            if (min > max) {
                throw new IllegalArgumentException(sysmsgs.getMessage(
                        "invalid.range", minVar, maxVar));
            }

            if (!GenericValidator.isInRange(longValue, min, max)) {
                errors.add(field.getKey(),
                    Resources.getActionMessage(validator, request, va, field));

                return false;
            }
        } catch (Exception e) {
            processFailure(errors, field, "longRange", e);

            return false;
        }
    }

    return true;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:54,代码来源:FieldChecks.java

示例15: validateIntRange

import org.apache.commons.validator.GenericValidator; //导入方法依赖的package包/类
/**
 * Checks if a fields value is within a range (min &amp; max specified in
 * the vars attribute).
 *
 * @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 in range, false otherwise.
 */
public static boolean validateIntRange(Object bean, ValidatorAction va,
    Field field, ActionMessages errors, Validator validator,
    HttpServletRequest request) {
    String value = null;

    value = evaluateBean(bean, field);

    if (!GenericValidator.isBlankOrNull(value)) {
        try {
            String minVar =
                Resources.getVarValue("min", field, validator, request, true);
            String maxVar =
                Resources.getVarValue("max", field, validator, request, true);
            int min = Integer.parseInt(minVar);
            int max = Integer.parseInt(maxVar);
            int intValue = Integer.parseInt(value);

            if (min > max) {
                throw new IllegalArgumentException(sysmsgs.getMessage(
                        "invalid.range", minVar, maxVar));
            }

            if (!GenericValidator.isInRange(intValue, min, max)) {
                errors.add(field.getKey(),
                    Resources.getActionMessage(validator, request, va, field));

                return false;
            }
        } catch (Exception e) {
            processFailure(errors, field, "intRange", e);

            return false;
        }
    }

    return true;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:54,代码来源:FieldChecks.java


注:本文中的org.apache.commons.validator.GenericValidator.isInRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。