public Property createProperty(final String name, final ParameterList parameters, final String value) throws IOException, URISyntaxException, ParseException { return new ExDate(parameters, value); }
@Override public void emitValue(final JsonGenerator jgen, final Property prop) throws Throwable { final ExDate p = (ExDate)prop; jgen.writeStartArray(); final DateList dl = p.getDates(); for (final Object o: dl) { jgen.writeString(XcalUtil.getXmlFormatDateTime(o.toString())); } jgen.writeEndArray(); } }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws ParseException where the specified value string is not a valid date-time/date representation */ public ExDate(final ParameterList aList, final String aValue) throws ParseException { super(EXDATE, aList, PropertyFactoryImpl.getInstance()); setValue(aValue); }
@SuppressWarnings("unchecked") public static void convert(TemporalExpression expr, PropertyList eventProps) { ICalRecurConverter converter = new ICalRecurConverter(); expr.accept(converter); DtStart dateStart = (DtStart) eventProps.getProperty(Property.DTSTART); if (converter.dateStart != null) { if (dateStart != null) { eventProps.remove(dateStart); } dateStart = converter.dateStart; eventProps.add(dateStart); } if (dateStart != null && converter.exRuleList.size() > 0) { // iCalendar quirk - if exclusions exist, then the start date must be excluded also ExDate exdate = new ExDate(); exdate.getDates().add(dateStart.getDate()); converter.exDateList.add(exdate); } eventProps.addAll(converter.incDateList); eventProps.addAll(converter.incRuleList); eventProps.addAll(converter.exDateList); eventProps.addAll(converter.exRuleList); }
/** * @return */ public static TestSuite suite() throws ParseException { TimeZoneRegistry tzReg = DefaultTimeZoneRegistryFactory.getInstance() .createRegistry(); TestSuite suite = new TestSuite(); ExDate exZulu = new ExDate(); exZulu.setValue("20111212T000000Z"); suite.addTest(new DateListPropertyTest("testCopy", exZulu)); ExDate exMelbourne = new ExDate(); exMelbourne.setTimeZone(tzReg.getTimeZone("Australia/Melbourne")); exMelbourne.setValue("20111212T000000"); suite.addTest(new DateListPropertyTest("testCopy", exMelbourne)); return suite; } }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / * (";" tzidparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE, getParameters()); final Parameter valueParam = getParameter(Parameter.VALUE); if (valueParam != null && !Value.DATE_TIME.equals(valueParam) && !Value.DATE.equals(valueParam)) { throw new ValidationException("Parameter [" + Parameter.VALUE + "] is invalid"); } ParameterValidator.getInstance().assertOneOrLess(Parameter.TZID, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ }
public DateList getExceptionDates() { DateList dateList = null; PropertyList<ExDate> exDatesProperties = getEvent().getProperties().getProperties(Property.EXDATE); for (ExDate exdate : exDatesProperties) { if(dateList==null) { if(Value.DATE.equals(exdate.getParameter(Parameter.VALUE))) { dateList = new DateList(Value.DATE); } else { dateList = new DateList(Value.DATE_TIME, exdate.getDates().getTimeZone()); } } dateList.addAll(exdate.getDates()); } return dateList; }
private void fixExDates(Component comp) throws Exception { PropertyList<ExDate> exDates = comp.getProperties(Property.EXDATE); List<Property> toAdd = new ArrayList<>(); List<Property> toRemove = new ArrayList<>(); for(ExDate exDate : exDates) { // ical likes a single exdate if(exDate.getDates().size()==1) { continue; } // remove exdate with multiple dates toRemove.add(exDate); // create single dates instead for(Date date : exDate.getDates()) { ExDate singleEx = (ExDate) exDate.copy(); singleEx.getDates().clear(); singleEx.getDates().add(date); toAdd.add(singleEx); } } // remove exdates with multiple dates comp.getProperties().removeAll(toRemove); // Add all single exdates comp.getProperties().addAll(toAdd); }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / * (";" tzidparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE, getParameters()); final Parameter valueParam = getParameter(Parameter.VALUE); if (valueParam != null && !Value.DATE_TIME.equals(valueParam) && !Value.DATE.equals(valueParam)) { throw new ValidationException("Parameter [" + Parameter.VALUE + "] is invalid"); } ParameterValidator.getInstance().assertOneOrLess(Parameter.TZID, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ }
public DateList getExceptionDates() { DateList dateList = null; PropertyList<ExDate> exDatesProperties = getEvent().getProperties().getProperties(Property.EXDATE); for (ExDate exdate : exDatesProperties) { if(dateList==null) { if(Value.DATE.equals(exdate.getParameter(Parameter.VALUE))) { dateList = new DateList(Value.DATE); } else { dateList = new DateList(Value.DATE_TIME, exdate.getDates().getTimeZone()); } } dateList.addAll(exdate.getDates()); } return dateList; }
private void fixExDates(Component comp) throws Exception { PropertyList<ExDate> exDates = comp.getProperties(Property.EXDATE); List<Property> toAdd = new ArrayList<>(); List<Property> toRemove = new ArrayList<>(); for(ExDate exDate : exDates) { // ical likes a single exdate if(exDate.getDates().size()==1) { continue; } // remove exdate with multiple dates toRemove.add(exDate); // create single dates instead for(Date date : exDate.getDates()) { ExDate singleEx = (ExDate) exDate.copy(); singleEx.getDates().clear(); singleEx.getDates().add(date); toAdd.add(singleEx); } } // remove exdates with multiple dates comp.getProperties().removeAll(toRemove); // Add all single exdates comp.getProperties().addAll(toAdd); }
public Property createProperty() { return new ExDate(); } }
/** * Ensure timezones are correctly parsed for this property. * @throws Exception */ public void testTimeZones() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE.ics")); Component event = calendar.getComponent(Component.VEVENT); List<ExDate> exdates = event.getProperties(Property.EXDATE); for (ExDate exDate : exdates) { assertNotNull("This EXDATE should have a timezone", exDate.getDates().getTimeZone()); } }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / * (";" tzidparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE, getParameters()); final Parameter valueParam = getParameter(Parameter.VALUE); if (valueParam != null && !Value.DATE_TIME.equals(valueParam) && !Value.DATE.equals(valueParam)) { throw new ValidationException("Parameter [" + Parameter.VALUE + "] is invalid"); } ParameterValidator.getInstance().assertOneOrLess(Parameter.TZID, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws ParseException where the specified value string is not a valid date-time/date representation */ public ExDate(final ParameterList aList, final String aValue) throws ParseException { super(EXDATE, aList, new Factory()); setValue(aValue); }
public Property createProperty(final ParameterList parameters, final String value) throws IOException, URISyntaxException, ParseException { return new ExDate(parameters, value); }
public void testShouldPreserveUtcTimezoneForExDate() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE-IN-UTC.ics")); Component event = calendar.getComponent(Component.VEVENT); List<ExDate> exdates = event.getProperties(Property.EXDATE); for (ExDate exDate : exdates) { for (Date dateEx : exDate.getDates()) { DateTime dateTimeEx = (DateTime) dateEx; assertNotNull(dateTimeEx); assertTrue("This exception date should be in UTC", dateTimeEx.isUtc()); } } }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / * (";" tzidparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE, getParameters()); final Parameter valueParam = getParameter(Parameter.VALUE); if (valueParam != null && !Value.DATE_TIME.equals(valueParam) && !Value.DATE.equals(valueParam)) { throw new ValidationException("Parameter [" + Parameter.VALUE + "] is invalid"); } ParameterValidator.getInstance().assertOneOrLess(Parameter.TZID, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws ParseException where the specified value string is not a valid date-time/date representation */ public ExDate(final ParameterList aList, final String aValue) throws ParseException { super(EXDATE, aList, PropertyFactoryImpl.getInstance()); setValue(aValue); }