if (tzid != null) { final VTimeZone timezone = (VTimeZone) timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone);
/** * Merge all properties and components from two specified calendars into one instance. * Note that the merge process is not very sophisticated, and may result in invalid calendar * data (e.g. multiple properties of a type that should only be specified once). * @param c1 the first calendar to merge * @param c2 the second calendar to merge * @return a Calendar instance containing all properties and components from both of the specified calendars */ public static Calendar merge(final Calendar c1, final Calendar c2) { final Calendar result = new Calendar(); result.getProperties().addAll(c1.getProperties()); for (final Iterator i = c2.getProperties().iterator(); i.hasNext();) { final Property p = (Property) i.next(); if (!result.getProperties().contains(p)) { result.getProperties().add(p); } } result.getComponents().addAll(c1.getComponents()); for (final Iterator i = c2.getComponents().iterator(); i.hasNext();) { final Component c = (Component) i.next(); if (!result.getComponents().contains(c)) { result.getComponents().add(c); } } return result; }
if (tzid != null) { final VTimeZone timezone = timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone);
if (tzid != null) { final VTimeZone timezone = timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone);
if (tzid != null) { final VTimeZone timezone = timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone);
if (tzid != null) { final VTimeZone timezone = timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone);
/** * Merge all properties and components from two specified calendars into one instance. * Note that the merge process is not very sophisticated, and may result in invalid calendar * data (e.g. multiple properties of a type that should only be specified once). * @param c1 the first calendar to merge * @param c2 the second calendar to merge * @return a Calendar instance containing all properties and components from both of the specified calendars */ public static Calendar merge(final Calendar c1, final Calendar c2) { final Calendar result = new Calendar(); result.getProperties().addAll(c1.getProperties()); for (final Property p : c2.getProperties()) { if (!result.getProperties().contains(p)) { result.getProperties().add(p); } } result.getComponents().addAll(c1.getComponents()); for (final CalendarComponent c : c2.getComponents()) { if (!result.getComponents().contains(c)) { result.getComponents().add(c); } } return result; }
/** * Test merging of calendars. */ public void testMerge() throws IOException, ParserException { Calendar result = calendars[0]; for (int i = 1; i < calendars.length; i++) { result = Calendars.merge(result, calendars[i]); } for (int i = 0; i < calendars.length; i++) { for (Property p : calendars[i].getProperties()) { assertTrue("Property [" + p + "] not found in merged calendar", result.getProperties().contains(p)); } for (Component c : calendars[i].getComponents()) { assertTrue("Component [" + c + "] not found in merged calendar", result.getComponents().contains(c)); } } }
/** * Merge all properties and components from two specified calendars into one instance. * Note that the merge process is not very sophisticated, and may result in invalid calendar * data (e.g. multiple properties of a type that should only be specified once). * @param c1 the first calendar to merge * @param c2 the second calendar to merge * @return a Calendar instance containing all properties and components from both of the specified calendars */ public static Calendar merge(final Calendar c1, final Calendar c2) { final Calendar result = new Calendar(); result.getProperties().addAll(c1.getProperties()); for (final Property p : c2.getProperties()) { if (!result.getProperties().contains(p)) { result.getProperties().add(p); } } result.getComponents().addAll(c1.getComponents()); for (final CalendarComponent c : c2.getComponents()) { if (!result.getComponents().contains(c)) { result.getComponents().add(c); } } return result; }
/** * Merge all properties and components from two specified calendars into one instance. * Note that the merge process is not very sophisticated, and may result in invalid calendar * data (e.g. multiple properties of a type that should only be specified once). * @param c1 the first calendar to merge * @param c2 the second calendar to merge * @return a Calendar instance containing all properties and components from both of the specified calendars */ public static Calendar merge(final Calendar c1, final Calendar c2) { final Calendar result = new Calendar(); result.getProperties().addAll(c1.getProperties()); for (final Property p : c2.getProperties()) { if (!result.getProperties().contains(p)) { result.getProperties().add(p); } } result.getComponents().addAll(c1.getComponents()); for (final CalendarComponent c : c2.getComponents()) { if (!result.getComponents().contains(c)) { result.getComponents().add(c); } } return result; }
/** * Merge all properties and components from two specified calendars into one instance. * Note that the merge process is not very sophisticated, and may result in invalid calendar * data (e.g. multiple properties of a type that should only be specified once). * @param c1 the first calendar to merge * @param c2 the second calendar to merge * @return a Calendar instance containing all properties and components from both of the specified calendars */ public static Calendar merge(final Calendar c1, final Calendar c2) { final Calendar result = new Calendar(); result.getProperties().addAll(c1.getProperties()); for (final Property p : c2.getProperties()) { if (!result.getProperties().contains(p)) { result.getProperties().add(p); } } result.getComponents().addAll(c1.getComponents()); for (final CalendarComponent c : c2.getComponents()) { if (!result.getComponents().contains(c)) { result.getComponents().add(c); } } return result; }