public class ValidationWarnings extends Object implements Iterable<ValidationWarnings.WarningsGroup>
Holds the validation warnings of an iCalendar object.
Examples:
//validate an iCalendar object
ValidationWarnings warnings = ical.validate();
//print all warnings to a string:
System.out.println(warnings.toString());
//sample output:
//[ICalendar]: ProductId is not set (it is a required property).
//[ICalendar > VEvent > DateStart]: DateStart must come before DateEnd.
//[ICalendar > VEvent > VAlarm]: The trigger must specify which date field its duration is relative to.
//iterate over each warnings group
//this gives you access to the property/component object and its parent components
for (WarningsGroup group : warnings) {
ICalProperty prop = group.getProperty();
if (prop == null) {
//then it was a component that caused the warnings
ICalComponent comp = group.getComponent();
}
//get parent components
List<ICalComponent> hierarchy = group.getComponentHierarchy();
//get warning messages
List<String> messages = group.getMessages();
}
//you can also get the warnings of specific properties/components
List<WarningsGroup> dtstartWarnings = warnings.getByProperty(DateStart.class);
List<WarningsGroup> veventWarnings = warnings.getByComponent(VEvent.class);
ICalendar.validate(ICalVersion)| Modifier and Type | Class and Description |
|---|---|
static class |
ValidationWarnings.WarningsGroup
Holds the validation warnings of a property or component.
|
| Constructor and Description |
|---|
ValidationWarnings(List<ValidationWarnings.WarningsGroup> warnings)
Creates a new validation warnings list.
|
| Modifier and Type | Method and Description |
|---|---|
List<ValidationWarnings.WarningsGroup> |
getByComponent(Class<? extends ICalComponent> componentClass)
Gets all validation warnings of a given component.
|
List<ValidationWarnings.WarningsGroup> |
getByProperty(Class<? extends ICalProperty> propertyClass)
Gets all validation warnings of a given property.
|
List<ValidationWarnings.WarningsGroup> |
getWarnings()
Gets all the validation warnings.
|
boolean |
isEmpty()
Determines whether there are any validation warnings.
|
Iterator<ValidationWarnings.WarningsGroup> |
iterator()
Iterates over each warning group (same as calling
getWarnings().iterator()). |
String |
toString()
Outputs all validation warnings as a newline-delimited string.
|
public ValidationWarnings(List<ValidationWarnings.WarningsGroup> warnings)
warnings - the validation warningspublic List<ValidationWarnings.WarningsGroup> getByProperty(Class<? extends ICalProperty> propertyClass)
propertyClass - the property (e.g. DateStart.class)public List<ValidationWarnings.WarningsGroup> getByComponent(Class<? extends ICalComponent> componentClass)
componentClass - the component (e.g. VEvent.class)public List<ValidationWarnings.WarningsGroup> getWarnings()
public boolean isEmpty()
public String toString()
Outputs all validation warnings as a newline-delimited string. For example:
[ICalendar]: ProductId is not set (it is a required property). [ICalendar > VEvent > DateStart]: DateStart must come before DateEnd. [ICalendar > VEvent > VAlarm]: The trigger must specify which date field its duration is relative to.
public Iterator<ValidationWarnings.WarningsGroup> iterator()
getWarnings().iterator()).iterator in interface Iterable<ValidationWarnings.WarningsGroup>Copyright © 2013-2015 Michael Angstadt. All Rights Reserved.