Search in sources :

Example 1 with ValidationWarnings

use of ezvcard.ValidationWarnings in project ez-vcard by mangstadt.

the class Agent method _validate.

@Override
protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard) {
    if (url == null && this.vcard == null) {
        warnings.add(new ValidationWarning(8));
    }
    if (this.vcard != null) {
        NumberFormat nf = NumberFormat.getIntegerInstance();
        nf.setMinimumIntegerDigits(2);
        ValidationWarnings validationWarnings = this.vcard.validate(version);
        for (Map.Entry<VCardProperty, List<ValidationWarning>> entry : validationWarnings) {
            VCardProperty property = entry.getKey();
            List<ValidationWarning> propViolations = entry.getValue();
            for (ValidationWarning propViolation : propViolations) {
                String className = (property == null) ? "" : property.getClass().getSimpleName();
                int code = propViolation.getCode();
                String codeStr = (code >= 0) ? "W" + nf.format(code) : "";
                String message = propViolation.getMessage();
                warnings.add(new ValidationWarning(10, className, codeStr, message));
            }
        }
    }
}
Also used : ValidationWarnings(ezvcard.ValidationWarnings) List(java.util.List) ValidationWarning(ezvcard.ValidationWarning) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) NumberFormat(java.text.NumberFormat)

Aggregations

ValidationWarning (ezvcard.ValidationWarning)1 ValidationWarnings (ezvcard.ValidationWarnings)1 NumberFormat (java.text.NumberFormat)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1