/** * @param parser a custom calendar parser * @param tzRegistry a custom timezone registry */ public CalendarBuilder(CalendarParser parser, Supplier<List<ParameterFactory>> parameterFactorySupplier, Supplier<List<PropertyFactory>> propertyFactorySupplier, Supplier<List<ComponentFactory>> componentFactorySupplier, TimeZoneRegistry tzRegistry) { this.parser = parser; this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry, parameterFactorySupplier, propertyFactorySupplier, componentFactorySupplier); }
@Override public void parameter(String name, String value) throws URISyntaxException { assertProperty(propertyBuilder); Parameter parameter = new ParameterBuilder().factories(parameterFactorySupplier.get()) .name(name).value(value).build(); if (parameter instanceof TzId && tzRegistry != null) { // VTIMEZONE may be defined later, so so keep // track of dates until all components have been // parsed, and then try again later propertiesWithTzId.add((TzId) parameter); } propertyBuilder.parameter(parameter); }
@Override public void endComponent(String name) { assertComponent(componentBuilder); if (subComponentBuilder != null) { Component subComponent = subComponentBuilder.build(); componentBuilder.subComponent(subComponent); subComponentBuilder = null; } else { CalendarComponent component = componentBuilder.build(); calendar.getComponents().add(component); if (component instanceof VTimeZone && tzRegistry != null) { // register the timezone for use with iCalendar objects.. tzRegistry.register(new TimeZone((VTimeZone) component)); } componentBuilder = null; } }
@Override public void endCalendar() throws IOException { if (propertiesWithTzId.size() > 0 && tzRegistry != null) { for (CalendarComponent component : calendar.getComponents()) { resolveTimezones(component.getProperties()); if (component instanceof VAvailability) { for (Component available : ((VAvailability) component).getAvailable()) { resolveTimezones(available.getProperties()); } } else if (component instanceof VEvent) { for (Component alarm : ((VEvent) component).getAlarms()) { resolveTimezones(alarm.getProperties()); } } else if (component instanceof VToDo) { for (Component todo : ((VToDo) component).getAlarms()) { resolveTimezones(todo.getProperties()); } } } } consumer.accept(calendar); }
@Override public void parameter(String name, String value) throws URISyntaxException { assertProperty(propertyBuilder); Parameter parameter = new ParameterBuilder().factories(parameterFactorySupplier.get()) .name(name).value(value).build(); if (parameter instanceof TzId && tzRegistry != null) { // VTIMEZONE may be defined later, so so keep // track of dates until all components have been // parsed, and then try again later propertiesWithTzId.add((TzId) parameter); } propertyBuilder.parameter(parameter); }
@Override public void endComponent(String name) { assertComponent(componentBuilder); if (subComponentBuilder != null) { Component subComponent = subComponentBuilder.build(); componentBuilder.subComponent(subComponent); subComponentBuilder = null; } else { CalendarComponent component = componentBuilder.build(); calendar.getComponents().add(component); if (component instanceof VTimeZone && tzRegistry != null) { // register the timezone for use with iCalendar objects.. tzRegistry.register(new TimeZone((VTimeZone) component)); } componentBuilder = null; } }
@Override public void endCalendar() throws IOException { if (propertiesWithTzId.size() > 0 && tzRegistry != null) { for (CalendarComponent component : calendar.getComponents()) { resolveTimezones(component.getProperties()); if (component instanceof VAvailability) { for (Component available : ((VAvailability) component).getAvailable()) { resolveTimezones(available.getProperties()); } } else if (component instanceof VEvent) { for (Component alarm : ((VEvent) component).getAlarms()) { resolveTimezones(alarm.getProperties()); } } else if (component instanceof VToDo) { for (Component todo : ((VToDo) component).getAlarms()) { resolveTimezones(todo.getProperties()); } } } } consumer.accept(calendar); }
/** * Constructs a new instance using the specified parser and registry. * * @param parser a calendar parser used to construct the calendar * @param tzRegistry a timezone registry used to retrieve {@link TimeZone}s and * register additional timezone information found * in the calendar */ public CalendarBuilder(CalendarParser parser, TimeZoneRegistry tzRegistry) { this.parser = parser; this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
@Override public void endProperty(String name) throws URISyntaxException, ParseException, IOException { assertProperty(propertyBuilder); Property property = propertyBuilder.build(); // replace with a constant instance if applicable.. property = Constants.forProperty(property); if (componentBuilder != null) { if (subComponentBuilder != null) { subComponentBuilder.property(property); } else { componentBuilder.property(property); } } else if (calendar != null) { calendar.getProperties().add(property); } property = null; }
/** * @param parser a custom calendar parser * @param tzRegistry a custom timezone registry */ public CalendarBuilder(CalendarParser parser, Supplier<List<ParameterFactory>> parameterFactorySupplier, Supplier<List<PropertyFactory>> propertyFactorySupplier, Supplier<List<ComponentFactory>> componentFactorySupplier, TimeZoneRegistry tzRegistry) { this.parser = parser; this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry, parameterFactorySupplier, propertyFactorySupplier, componentFactorySupplier); }
@Override public void endProperty(String name) throws URISyntaxException, ParseException, IOException { assertProperty(propertyBuilder); Property property = propertyBuilder.build(); // replace with a constant instance if applicable.. property = Constants.forProperty(property); if (componentBuilder != null) { if (subComponentBuilder != null) { subComponentBuilder.property(property); } else { componentBuilder.property(property); } } else if (calendar != null) { calendar.getProperties().add(property); } property = null; }
/** * Constructs a new instance using the specified parser and registry. * * @param parser a calendar parser used to construct the calendar * @param tzRegistry a timezone registry used to retrieve {@link TimeZone}s and * register additional timezone information found * in the calendar */ public CalendarBuilder(CalendarParser parser, TimeZoneRegistry tzRegistry) { this.parser = parser; this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Constructs a new calendar builder using the specified timezone registry. * * @param tzRegistry a timezone registry to populate with discovered timezones */ public CalendarBuilder(final TimeZoneRegistry tzRegistry) { this.parser = CalendarParserFactory.getInstance().get(); this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Constructs a new calendar builder using the specified timezone registry. * * @param tzRegistry a timezone registry to populate with discovered timezones */ public CalendarBuilder(final TimeZoneRegistry tzRegistry) { this.parser = CalendarParserFactory.getInstance().get(); this.tzRegistry = tzRegistry; this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Constructs a new calendar builder using the specified calendar parser. * * @param parser a calendar parser used to parse calendar files */ public CalendarBuilder(final CalendarParser parser) { this.parser = parser; this.tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Constructs a new calendar builder using the specified calendar parser. * * @param parser a calendar parser used to parse calendar files */ public CalendarBuilder(final CalendarParser parser) { this.parser = parser; this.tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Default constructor. */ public CalendarBuilder() { this.parser = CalendarParserFactory.getInstance().get(); this.tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); this.contentHandler = new DefaultContentHandler(this, tzRegistry); }
/** * Default constructor. */ public CalendarBuilder() { this.parser = CalendarParserFactory.getInstance().get(); this.tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); this.contentHandler = new DefaultContentHandler(this, tzRegistry); }