本文整理汇总了Java中org.kuali.rice.krad.datadictionary.validation.capability.Formatable类的典型用法代码示例。如果您正苦于以下问题:Java Formatable类的具体用法?Java Formatable怎么用?Java Formatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Formatable类属于org.kuali.rice.krad.datadictionary.validation.capability包,在下文中一共展示了Formatable类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processSingleValidCharacterConstraint
import org.kuali.rice.krad.datadictionary.validation.capability.Formatable; //导入依赖的package包/类
protected ConstraintValidationResult processSingleValidCharacterConstraint(DictionaryValidationResult result,
Object value, ValidCharactersConstraint constraint,
AttributeValueReader attributeValueReader) throws AttributeValidationException {
if (constraint == null) {
return result.addNoConstraint(attributeValueReader, CONSTRAINT_NAME);
}
if (ValidationUtils.isNullOrEmpty(value)) {
return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
}
// This mix-in interface is here to allow some definitions to avoid the extra processing that goes on in KNS
// to decipher and validate things like date range strings -- something that looks like "02/02/2002..03/03/2003"
Constrainable definition = attributeValueReader.getDefinition(attributeValueReader.getAttributeName());
if (definition instanceof Formatable) {
return doProcessFormattableValidCharConstraint(result, constraint, (Formatable) definition, value,
attributeValueReader);
}
ConstraintValidationResult constraintValidationResult = doProcessValidCharConstraint(constraint, value);
if (constraintValidationResult == null) {
return result.addSuccess(attributeValueReader, CONSTRAINT_NAME);
}
result.addConstraintValidationResult(attributeValueReader, constraintValidationResult);
constraintValidationResult.setConstraintLabelKey(constraint.getMessageKey());
constraintValidationResult.setErrorParameters(constraint.getValidationMessageParamsArray());
return constraintValidationResult;
}
示例2: doProcessFormattableValidCharConstraint
import org.kuali.rice.krad.datadictionary.validation.capability.Formatable; //导入依赖的package包/类
protected ConstraintValidationResult doProcessFormattableValidCharConstraint(DictionaryValidationResult result,
ValidCharactersConstraint validCharsConstraint, Formatable definition, Object value,
AttributeValueReader attributeValueReader) throws AttributeValidationException {
String entryName = attributeValueReader.getEntryName();
String attributeName = attributeValueReader.getAttributeName();
// This is a strange KNS thing for validating searchable fields -- they sometimes come in a date range format, for example 2/12/2010..2/14/2010, and need to be split up
List<String> parsedAttributeValues = attributeValueReader.getCleanSearchableValues(attributeName);
if (parsedAttributeValues != null) {
Class<?> formatterClass = null;
Boolean doValidateDateRangeOrder = null;
// It can't be a date range if it's more than two fields, for example "a .. b | c" is not a date range -- this saves us a tiny bit of processing later
if (parsedAttributeValues.size() != 2) {
doValidateDateRangeOrder = Boolean.FALSE;
}
// Use integer to iterate since we need to track which field we're looking at
for (int i = 0; i < parsedAttributeValues.size(); i++) {
String parsedAttributeValue = parsedAttributeValues.get(i);
ConstraintValidationResult constraintValidationResult = doProcessValidCharConstraint(
validCharsConstraint, parsedAttributeValue);
// If this is an error then some non-null validation result will be returned
if (constraintValidationResult != null) {
constraintValidationResult.setConstraintLabelKey(validCharsConstraint.getMessageKey());
constraintValidationResult.setErrorParameters(
validCharsConstraint.getValidationMessageParamsArray());
// Another strange KNS thing -- if the validation fails (not sure why only in that case) then some further error checking is done using the formatter, if one exists
if (formatterClass == null) {
String formatterClassName = definition.getFormatterClass();
if (formatterClassName != null) {
formatterClass = ClassLoaderUtils.getClass(formatterClassName);
}
}
if (formatterClass != null) {
// Use the Boolean value being null to ensure we only do this once
if (doValidateDateRangeOrder == null) {
// We only want to validate a date range if we're dealing with something that has a date formatter on it and that looks like an actual range (is made up of 2 values with a between operator between them)
doValidateDateRangeOrder = Boolean.valueOf(DateFormatter.class.isAssignableFrom(
formatterClass) && StringUtils.contains(ValidationUtils.getString(value),
SearchOperator.BETWEEN.toString()));
}
constraintValidationResult = processFormatterValidation(result, formatterClass, entryName,
attributeName, parsedAttributeValue, DATE_RANGE_ERROR_PREFIXES[i]);
if (constraintValidationResult != null) {
result.addConstraintValidationResult(attributeValueReader, constraintValidationResult);
return constraintValidationResult;
}
} else {
// Otherwise, just report the validation result (apparently the formatter can't provide any fall-through validation because it doesn't exist)
result.addConstraintValidationResult(attributeValueReader, constraintValidationResult);
return constraintValidationResult;
}
}
}
if (doValidateDateRangeOrder != null && doValidateDateRangeOrder.booleanValue()) {
ConstraintValidationResult dateOrderValidationResult = validateDateOrder(parsedAttributeValues.get(0),
parsedAttributeValues.get(1), entryName, attributeName);
if (dateOrderValidationResult != null) {
result.addConstraintValidationResult(attributeValueReader, dateOrderValidationResult);
return dateOrderValidationResult;
}
}
return result.addSuccess(attributeValueReader, CONSTRAINT_NAME);
}
return result.addSkipped(attributeValueReader, CONSTRAINT_NAME);
}