diff --git a/src/main/java/net/fortuna/ical4j/model/Calendar.java b/src/main/java/net/fortuna/ical4j/model/Calendar.java index a3f3ecc43..7475d39ce 100644 --- a/src/main/java/net/fortuna/ical4j/model/Calendar.java +++ b/src/main/java/net/fortuna/ical4j/model/Calendar.java @@ -33,11 +33,8 @@ import net.fortuna.ical4j.model.component.CalendarComponent; import net.fortuna.ical4j.model.property.*; -import net.fortuna.ical4j.util.CompatibilityHints; import net.fortuna.ical4j.util.Strings; -import net.fortuna.ical4j.validate.ComponentValidator; -import net.fortuna.ical4j.validate.PropertyValidator; -import net.fortuna.ical4j.validate.ValidationException; +import net.fortuna.ical4j.validate.*; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -132,9 +129,11 @@ public class Calendar implements Serializable { */ public static final String END = "END"; - private PropertyList properties; + private final PropertyList properties; - private ComponentList components; + private final ComponentList components; + + private final Validator validator; /** * Default constructor. @@ -151,14 +150,25 @@ public Calendar(final ComponentList components) { this(new PropertyList(), components); } + /** + * Initialise a Calendar object using the default configured validator. + * @param properties a list of initial calendar properties + * @param components a list of initial calendar components + */ + public Calendar(PropertyList properties, ComponentList components) { + this(properties, components, AbstractCalendarValidatorFactory.getInstance().newInstance()); + } + /** * Constructor. * @param p a list of properties * @param c a list of components + * @param validator used to ensure the validity of the calendar instance */ - public Calendar(final PropertyList p, final ComponentList c) { + public Calendar(PropertyList p, ComponentList c, Validator validator) { this.properties = p; this.components = c; + this.validator = validator; } /** @@ -258,205 +268,7 @@ public final void validate() throws ValidationException { * @throws ValidationException where the calendar is not in a valid state */ public void validate(final boolean recurse) throws ValidationException { - // 'prodid' and 'version' are both REQUIRED, - // but MUST NOT occur more than once - PropertyValidator.getInstance().assertOne(Property.PRODID, properties); - PropertyValidator.getInstance().assertOne(Property.VERSION, properties); - - if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { - // require VERSION:2.0 for RFC2445.. - if (!Version.VERSION_2_0.equals(getProperty(Property.VERSION))) { - throw new ValidationException("Unsupported Version: " + getProperty(Property.VERSION).getValue()); - } - } - - // 'calscale' and 'method' are optional, - // but MUST NOT occur more than once - PropertyValidator.getInstance().assertOneOrLess(Property.CALSCALE, - properties); - PropertyValidator.getInstance().assertOneOrLess(Property.METHOD, - properties); - - // must contain at least one component - if (getComponents().isEmpty()) { - throw new ValidationException( - "Calendar must contain at least one component"); - } - - // validate properties.. - for (final Property property : getProperties()) { - if (!(property instanceof XProperty) - && !(property instanceof CalendarProperty)) { - throw new ValidationException("Invalid property: " - + property.getName()); - } - } - -// if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { - // validate method.. - final Method method = (Method) getProperty(Property.METHOD); - if (Method.PUBLISH.equals(method)) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - - if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - } - else if (getComponent(Component.VFREEBUSY) != null) { - ComponentValidator.assertNone(Component.VTODO, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); - ComponentValidator.assertNone(Component.VALARM, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { -// ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } -// else if (getComponent(Component.VJOURNAL) != null) { -// ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); -// ComponentValidator.assertNone(Component.VTODO, getComponents()); -// } - } - else if (Method.REQUEST.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VFREEBUSY) != null) { - ComponentValidator.assertNone(Component.VTODO, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); - ComponentValidator.assertNone(Component.VALARM, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { -// ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - } - else if (Method.REPLY.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); - - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VFREEBUSY) != null) { - ComponentValidator.assertNone(Component.VTODO, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); - ComponentValidator.assertNone(Component.VALARM, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); - - ComponentValidator.assertNone(Component.VALARM, getComponents()); -// ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - } - else if (Method.ADD.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - else if (getComponent(Component.VJOURNAL) != null) { - ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); - - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); -// ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - } - else if (Method.CANCEL.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); - - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - else if (getComponent(Component.VJOURNAL) != null) { - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); -// ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - } - else if (Method.REFRESH.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); - } - } - else if (Method.COUNTER.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); - - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - } - else if (Method.DECLINE_COUNTER.equals(getProperty(Property.METHOD))) { - if (getComponent(Component.VEVENT) != null) { - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - ComponentValidator.assertNone(Component.VTODO, getComponents()); - ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); - ComponentValidator.assertNone(Component.VALARM, getComponents()); - } - else if (getComponent(Component.VTODO) != null) { - ComponentValidator.assertNone(Component.VALARM, getComponents()); - ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); -// ComponentValidator.assertNone(Component.VEVENT, getComponents()); - ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); - } - } -// } - - // perform ITIP validation on components.. - if (method != null) { - for (CalendarComponent component : getComponents()) { - component.validate(method); - } - } - + validator.validate(this); if (recurse) { validateProperties(); validateComponents(); diff --git a/src/main/java/net/fortuna/ical4j/validate/AbstractCalendarValidatorFactory.java b/src/main/java/net/fortuna/ical4j/validate/AbstractCalendarValidatorFactory.java new file mode 100644 index 000000000..5ea4e9605 --- /dev/null +++ b/src/main/java/net/fortuna/ical4j/validate/AbstractCalendarValidatorFactory.java @@ -0,0 +1,18 @@ +package net.fortuna.ical4j.validate; + +import java.util.ServiceLoader; + +/** + * Created by fortuna on 13/09/15. + */ +public abstract class AbstractCalendarValidatorFactory { + + private static CalendarValidatorFactory instance; + static { + instance = ServiceLoader.load(CalendarValidatorFactory.class).iterator().next(); + } + + public static CalendarValidatorFactory getInstance() { + return instance; + } +} diff --git a/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorFactory.java b/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorFactory.java new file mode 100644 index 000000000..09c928958 --- /dev/null +++ b/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorFactory.java @@ -0,0 +1,15 @@ +package net.fortuna.ical4j.validate; + +import net.fortuna.ical4j.model.Calendar; + +/** + * Created by fortuna on 13/09/15. + */ +public interface CalendarValidatorFactory { + + /** + * Provides a validator implementation specific to the factory. + * @return a new validator instance + */ + Validator newInstance(); +} diff --git a/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorImpl.java b/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorImpl.java new file mode 100644 index 000000000..947d183d7 --- /dev/null +++ b/src/main/java/net/fortuna/ical4j/validate/CalendarValidatorImpl.java @@ -0,0 +1,218 @@ +package net.fortuna.ical4j.validate; + +import net.fortuna.ical4j.model.Calendar; +import net.fortuna.ical4j.model.Component; +import net.fortuna.ical4j.model.Property; +import net.fortuna.ical4j.model.component.CalendarComponent; +import net.fortuna.ical4j.model.property.CalendarProperty; +import net.fortuna.ical4j.model.property.Method; +import net.fortuna.ical4j.model.property.Version; +import net.fortuna.ical4j.model.property.XProperty; +import net.fortuna.ical4j.util.CompatibilityHints; + +/** + * Created by fortuna on 13/09/15. + */ +public class CalendarValidatorImpl implements Validator { + @Override + public void validate(Calendar target) throws ValidationException { + // 'prodid' and 'version' are both REQUIRED, + // but MUST NOT occur more than once + PropertyValidator.getInstance().assertOne(Property.PRODID, target.getProperties()); + PropertyValidator.getInstance().assertOne(Property.VERSION, target.getProperties()); + + if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { + // require VERSION:2.0 for RFC2445.. + if (!Version.VERSION_2_0.equals(target.getProperty(Property.VERSION))) { + throw new ValidationException("Unsupported Version: " + target.getProperty(Property.VERSION).getValue()); + } + } + + // 'calscale' and 'method' are optional, + // but MUST NOT occur more than once + PropertyValidator.getInstance().assertOneOrLess(Property.CALSCALE, + target.getProperties()); + PropertyValidator.getInstance().assertOneOrLess(Property.METHOD, + target.getProperties()); + + // must contain at least one component + if (target.getComponents().isEmpty()) { + throw new ValidationException( + "Calendar must contain at least one component"); + } + + // validate properties.. + for (final Property property : target.getProperties()) { + if (!(property instanceof XProperty) + && !(property instanceof CalendarProperty)) { + throw new ValidationException("Invalid property: " + + property.getName()); + } + } + +// if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { + // validate method.. + final Method method = (Method) target.getProperty(Property.METHOD); + if (Method.PUBLISH.equals(method)) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + + if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + } + else if (target.getComponent(Component.VFREEBUSY) != null) { + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTIMEZONE, target.getComponents()); + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { +// ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } +// else if (target.getComponent(Component.VJOURNAL) != null) { +// ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); +// ComponentValidator.assertNone(Component.VTODO, target.getComponents()); +// } + } + else if (Method.REQUEST.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VFREEBUSY) != null) { + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTIMEZONE, target.getComponents()); + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { +// ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + } + else if (Method.REPLY.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertOneOrLess(Component.VTIMEZONE, target.getComponents()); + + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VFREEBUSY) != null) { + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTIMEZONE, target.getComponents()); + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertOneOrLess(Component.VTIMEZONE, target.getComponents()); + + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); +// ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + } + else if (Method.ADD.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + else if (target.getComponent(Component.VJOURNAL) != null) { + ComponentValidator.assertOneOrLess(Component.VTIMEZONE, target.getComponents()); + + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); +// ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + } + else if (Method.CANCEL.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertOneOrLess(Component.VTIMEZONE, target.getComponents()); + + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + else if (target.getComponent(Component.VJOURNAL) != null) { + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); +// ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + } + else if (Method.REFRESH.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTIMEZONE, target.getComponents()); + } + } + else if (Method.COUNTER.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertOneOrLess(Component.VTIMEZONE, target.getComponents()); + + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + } + else if (Method.DECLINE_COUNTER.equals(target.getProperty(Property.METHOD))) { + if (target.getComponent(Component.VEVENT) != null) { + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + ComponentValidator.assertNone(Component.VTODO, target.getComponents()); + ComponentValidator.assertNone(Component.VTIMEZONE, target.getComponents()); + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + } + else if (target.getComponent(Component.VTODO) != null) { + ComponentValidator.assertNone(Component.VALARM, target.getComponents()); + ComponentValidator.assertNone(Component.VFREEBUSY, target.getComponents()); +// ComponentValidator.assertNone(Component.VEVENT, target.getComponents()); + ComponentValidator.assertNone(Component.VJOURNAL, target.getComponents()); + } + } +// } + + // perform ITIP validation on components.. + if (method != null) { + for (CalendarComponent component : target.getComponents()) { + component.validate(method); + } + } + } +} diff --git a/src/main/java/net/fortuna/ical4j/validate/DefaultCalendarValidatorFactory.java b/src/main/java/net/fortuna/ical4j/validate/DefaultCalendarValidatorFactory.java new file mode 100644 index 000000000..67af4042a --- /dev/null +++ b/src/main/java/net/fortuna/ical4j/validate/DefaultCalendarValidatorFactory.java @@ -0,0 +1,13 @@ +package net.fortuna.ical4j.validate; + +import net.fortuna.ical4j.model.Calendar; + +/** + * Created by fortuna on 13/09/15. + */ +public class DefaultCalendarValidatorFactory implements CalendarValidatorFactory { + @Override + public Validator newInstance() { + return new CalendarValidatorImpl(); + } +} diff --git a/src/main/resources/META-INF/services/net.fortuna.ical4j.validate.CalendarValidatorFactory b/src/main/resources/META-INF/services/net.fortuna.ical4j.validate.CalendarValidatorFactory new file mode 100644 index 000000000..33852e438 --- /dev/null +++ b/src/main/resources/META-INF/services/net.fortuna.ical4j.validate.CalendarValidatorFactory @@ -0,0 +1 @@ +net.fortuna.ical4j.validate.DefaultCalendarValidatorFactory