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


Java RangeConstraint类代码示例

本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint的典型用法代码示例。如果您正苦于以下问题:Java RangeConstraint类的具体用法?Java RangeConstraint怎么用?Java RangeConstraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RangeConstraint类属于org.kuali.rice.krad.datadictionary.validation.constraint包,在下文中一共展示了RangeConstraint类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateRange

import org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint; //导入依赖的package包/类
/**
 * validates the date value using the range constraint provided
 *
 * @param result - a holder for any already run validation results
 * @param value - the value to validate
 * @param constraint - the range constraint to use
 * @param attributeValueReader - provides access to the attribute being validated
 * @return the passed in result, updated with the results of the processing
 * @throws IllegalArgumentException
 */
protected ConstraintValidationResult validateRange(DictionaryValidationResult result, Date value,
        RangeConstraint constraint, AttributeValueReader attributeValueReader) throws IllegalArgumentException {

    Date date = value != null ? ValidationUtils.getDate(value, dateTimeService) : null;

    String inclusiveMaxText = constraint.getInclusiveMax();
    String exclusiveMinText = constraint.getExclusiveMin();

    Date inclusiveMax = inclusiveMaxText != null ? ValidationUtils.getDate(inclusiveMaxText, dateTimeService) :
            null;
    Date exclusiveMin = exclusiveMinText != null ? ValidationUtils.getDate(exclusiveMinText, dateTimeService) :
            null;

    return isInRange(result, date, inclusiveMax, inclusiveMaxText, exclusiveMin, exclusiveMinText,
            attributeValueReader);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:RangeConstraintProcessor.java

示例2: process

import org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#process(org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult,
 *      Object, org.kuali.rice.krad.datadictionary.validation.constraint.Constraint,
 *      org.kuali.rice.krad.datadictionary.validation.AttributeValueReader)
 */
@Override
public ProcessorResult process(DictionaryValidationResult result, Object value, RangeConstraint constraint,
        AttributeValueReader attributeValueReader) throws AttributeValidationException {

    // Since any given definition that is range constrained only expressed a single min and max, it means that there is only a single constraint to impose
    return new ProcessorResult(processSingleRangeConstraint(result, value, constraint, attributeValueReader));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:RangeConstraintProcessor.java

示例3: processSingleRangeConstraint

import org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint; //导入依赖的package包/类
/**
 * validates the value provided using {@code RangeConstraint}
 *
 * @param result - a holder for any already run validation results
 * @param value - the value to validate
 * @param constraint - the range constraint to use
 * @param attributeValueReader - provides access to the attribute being validated
 * @return the passed in result, updated with the results of the processing
 * @throws AttributeValidationException if validation fails
 */
protected ConstraintValidationResult processSingleRangeConstraint(DictionaryValidationResult result, Object value,
        RangeConstraint constraint, AttributeValueReader attributeValueReader) throws AttributeValidationException {
    // Can't process any range constraints on null values
    if (ValidationUtils.isNullOrEmpty(value) || (constraint.getExclusiveMin() == null
            && constraint.getInclusiveMax() == null)) {
        return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
    }

    // This is necessary because sometimes we'll be getting a string, for example, that represents a date.
    DataType dataType = constraint.getDataType();
    Object typedValue = value;

    if (dataType != null) {
        typedValue = ValidationUtils.convertToDataType(value, dataType, dateTimeService);
    } else if (value instanceof String) {
        //assume string is a number of type double
        try {
            Double d = Double.parseDouble((String) value);
            typedValue = d;
        } catch (NumberFormatException n) {
            //do nothing, typedValue is never reset
        }
    }

    // TODO: decide if there is any reason why the following would be insufficient - i.e. if something numeric could still be cast to String at this point
    if (typedValue instanceof Date) {
        return validateRange(result, (Date) typedValue, constraint, attributeValueReader);
    } else if (typedValue instanceof Number) {
        return validateRange(result, (Number) typedValue, constraint, attributeValueReader);
    }

    return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:44,代码来源:RangeConstraintProcessor.java

示例4: processSingleRangeConstraint

import org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint; //导入依赖的package包/类
/**
 * validates the value provided using {@code RangeConstraint}
 *
 * @param result - a holder for any already run validation results
 * @param value - the value to validate
 * @param constraint - the range constraint to use
 * @param attributeValueReader - provides access to the attribute being validated
 * @return the passed in result, updated with the results of the processing
 */
protected ConstraintValidationResult processSingleRangeConstraint(DictionaryValidationResult result, Object value,
        RangeConstraint constraint, AttributeValueReader attributeValueReader) throws AttributeValidationException {
    // Can't process any range constraints on null values
    if (ValidationUtils.isNullOrEmpty(value) || (constraint.getExclusiveMin() == null
            && constraint.getInclusiveMax() == null)) {
        return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
    }

    // This is necessary because sometimes we'll be getting a string, for example, that represents a date.
    DataType dataType = constraint.getDataType();
    Object typedValue = value;

    if (dataType != null) {
        typedValue = ValidationUtils.convertToDataType(value, dataType, dateTimeService);
    } else if (value instanceof String) {
        //assume string is a number of type double
        try {
            Double d = Double.parseDouble((String) value);
            typedValue = d;
        } catch (NumberFormatException n) {
            //do nothing, typedValue is never reset
        }
    }

    // TODO: decide if there is any reason why the following would be insufficient - i.e. if something numeric could still be cast to String at this point
    if (typedValue instanceof Date) {
        return validateRange(result, (Date) typedValue, constraint, attributeValueReader);
    } else if (typedValue instanceof Number) {
        return validateRange(result, (Number) typedValue, constraint, attributeValueReader);
    }

    return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:43,代码来源:RangeConstraintProcessor.java

示例5: getConstraintType

import org.kuali.rice.krad.datadictionary.validation.constraint.RangeConstraint; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#getConstraintType()
 */
@Override
public Class<? extends Constraint> getConstraintType() {
    return RangeConstraint.class;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:RangeConstraintProcessor.java


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