public class ValidationWarnings extends Object implements Iterable<Map.Entry<VCardProperty,List<ValidationWarning>>>
Holds the validation warnings of a vCard.
Examples:
//validate a vCard object according to the rules of a specific version
ValidationWarnings warnings = vcard.validate(VCardVersion.V3_0);
//print all warnings to a string:
System.out.println(warnings.toString());
//sample output:
//W01: A FormattedName property is required for vCard versions 3.0 and 4.0.
//[Gender] | W02: Property is not supported in this vCard version. Supported versions are: [4.0]
//iterate over the warnings
for (Map.Entry<VCardProperty, List<Warning>> entry : warnings) {
//the property that caused the warning(s)
VCardProperty property = entry.getKey();
//the list of warnings that belong to this property
List<Warning> propWarnings = entry.getValue();
if (property == null) {
//it's a warning about the vCard as a whole
}
//each warning message has a numeric code
//this allows you to programmatically respond to specific warning messages
List<Warning> propWarnings = entry.getValue();
for (Warning w : propWarnings) {
System.out.println("Code: " + w.getCode());
System.out.printkn("Message: " + w.getMessage());
}
}
//you can also get the warnings of specific property classes
List<Warnings> telWarnings = warnings.getByProperty(Telephone.class);
VCard.validate(ezvcard.VCardVersion)| Constructor and Description |
|---|
ValidationWarnings() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(VCardProperty property,
List<ValidationWarning> warnings)
Adds a property's validation warnings.
|
void |
add(VCardProperty property,
ValidationWarning warning)
Adds a validation warning.
|
List<ValidationWarning> |
getByProperty(Class<? extends VCardProperty> propertyClass)
Gets all validation warnings that belong to a property of a specific
class.
|
ListMultimap<VCardProperty,ValidationWarning> |
getWarnings()
Gets all of the validation warnings.
|
boolean |
isEmpty()
Determines whether or not the warnings list is empty.
|
Iterator<Map.Entry<VCardProperty,List<ValidationWarning>>> |
iterator() |
String |
toString()
Outputs all validation warnings as a newline-delimited string.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic ValidationWarnings()
public void add(VCardProperty property, ValidationWarning warning)
property - the property that caused the warningwarning - the warningpublic void add(VCardProperty property, List<ValidationWarning> warnings)
property - the property that caused the warningswarnings - the warningspublic ListMultimap<VCardProperty,ValidationWarning> getWarnings()
public boolean isEmpty()
public List<ValidationWarning> getByProperty(Class<? extends VCardProperty> propertyClass)
propertyClass - the property class (e.g. Telephone.class) or
null to get the warnings that apply to the vCard as a wholepublic String toString()
Outputs all validation warnings as a newline-delimited string. For example:
W01: A FormattedName property is required for vCard versions 3.0 and 4.0. [Gender] | W02: Property is not supported in this vCard version. Supported versions are: [4.0]
public Iterator<Map.Entry<VCardProperty,List<ValidationWarning>>> iterator()
iterator in interface Iterable<Map.Entry<VCardProperty,List<ValidationWarning>>>Copyright © 2012–2023 Michael Angstadt. All rights reserved.