|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectezvcard.ValidationWarnings
public class ValidationWarnings
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 Summary | |
|---|---|
ValidationWarnings()
|
|
| Method Summary | |
|---|---|
void |
add(VCardProperty property,
List<Warning> warnings)
Adds a property's validation warnings. |
void |
add(VCardProperty property,
Warning warning)
Adds a validation warning. |
List<Warning> |
getByProperty(Class<? extends VCardProperty> propertyClass)
Gets all validation warnings that belong to a property of a specific class. |
ListMultimap<VCardProperty,Warning> |
getWarnings()
Gets all of the validation warnings. |
boolean |
isEmpty()
Determines whether or not the warnings list is empty. |
Iterator<Map.Entry<VCardProperty,List<Warning>>> |
iterator()
|
String |
toString()
Outputs all validation warnings as a newline-delimited string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ValidationWarnings()
| Method Detail |
|---|
public void add(VCardProperty property,
Warning warning)
property - the property that caused the warningwarning - the warning
public void add(VCardProperty property,
List<Warning> warnings)
property - the property that caused the warningswarnings - the warningspublic ListMultimap<VCardProperty,Warning> getWarnings()
public boolean isEmpty()
public List<Warning> 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 whole
public 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]
toString in class Objectpublic Iterator<Map.Entry<VCardProperty,List<Warning>>> iterator()
iterator in interface Iterable<Map.Entry<VCardProperty,List<Warning>>>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||