biweekly
Class ValidationWarnings

java.lang.Object
  extended by biweekly.ValidationWarnings
All Implemented Interfaces:
Iterable<ValidationWarnings.WarningsGroup>

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);
 

Author:
Michael Angstadt
See Also:
ICalendar.validate()

Nested Class Summary
static class ValidationWarnings.WarningsGroup
          Holds the validation warnings of a property or component.
 
Constructor Summary
ValidationWarnings(List<ValidationWarnings.WarningsGroup> warnings)
          Creates a new validation warnings list.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValidationWarnings

public ValidationWarnings(List<ValidationWarnings.WarningsGroup> warnings)
Creates a new validation warnings list.

Parameters:
warnings - the validation warnings
Method Detail

getByProperty

public List<ValidationWarnings.WarningsGroup> getByProperty(Class<? extends ICalProperty> propertyClass)
Gets all validation warnings of a given property.

Parameters:
propertyClass - the property (e.g. DateStart.class)
Returns:
the validation warnings

getByComponent

public List<ValidationWarnings.WarningsGroup> getByComponent(Class<? extends ICalComponent> componentClass)
Gets all validation warnings of a given component.

Parameters:
componentClass - the component (e.g. VEvent.class)
Returns:
the validation warnings

getWarnings

public List<ValidationWarnings.WarningsGroup> getWarnings()
Gets all the validation warnings.

Returns:
the validation warnings

isEmpty

public boolean isEmpty()
Determines whether there are any validation warnings.

Returns:
true if there are none, false if there are one or more

toString

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.
 

Overrides:
toString in class Object

iterator

public Iterator<ValidationWarnings.WarningsGroup> iterator()
Iterates over each warning group (same as calling getWarnings().iterator()).

Specified by:
iterator in interface Iterable<ValidationWarnings.WarningsGroup>
Returns:
the iterator


Copyright © 2013 Michael Angstadt. All Rights Reserved.