use of org.apache.cayenne.validation.ValidationFailure in project cayenne by apache.
the class ValidationResultBrowser method buildValidationText.
/**
* Creates validation text for the validation result.
*/
protected String buildValidationText(ValidationResult validationResult) {
StringBuffer buffer = new StringBuffer();
String separator = System.getProperty("line.separator");
for (ValidationFailure failure : validationResult.getFailures()) {
if (buffer.length() > 0) {
buffer.append(separator);
}
if (failure.getSource() != null) {
buffer.append("[SQL: ").append(failure.getSource()).append("] - ");
}
if (failure.getDescription() != null) {
buffer.append(failure.getDescription());
}
}
return buffer.toString();
}
use of org.apache.cayenne.validation.ValidationFailure in project cayenne by apache.
the class CodeValidationUtil method validateJavaIdentifier.
public static ValidationFailure validateJavaIdentifier(Object bean, String attribute, String identifier) {
ValidationFailure emptyFailure = BeanValidationFailure.validateNotEmpty(bean, attribute, identifier);
if (emptyFailure != null) {
return emptyFailure;
}
char c = identifier.charAt(0);
if (!Character.isJavaIdentifierStart(c)) {
return new BeanValidationFailure(bean, attribute, validationMessage(attribute, " starts with invalid character: " + c));
}
for (int i = 1; i < identifier.length(); i++) {
c = identifier.charAt(i);
if (!Character.isJavaIdentifierPart(c)) {
return new BeanValidationFailure(bean, attribute, validationMessage(attribute, " contains invalid character: " + c));
}
}
return null;
}
Aggregations