本文整理匯總了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);
}