/** * Add a component to the list. * @param component the component to add * @return true * @see List#add(java.lang.Object) */ public final boolean add(final Component component) { return add((Object) component); }
/** * {@inheritDoc} */ public final boolean useDaylightTime() { final ComponentList<Observance> daylights = vTimeZone.getObservances().getComponents(Observance.DAYLIGHT); return (!daylights.isEmpty()); }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
/** * Wraps a component in a calendar. * @param component the component to wrap with a calendar * @return a calendar containing the specified component */ public static Calendar wrap(final CalendarComponent component) { final ComponentList<CalendarComponent> components = new ComponentList<CalendarComponent>(); components.add(component); return new Calendar(components); }
if (calendar.getComponents().size() <= 1 || calendar.getComponents(Component.VTIMEZONE).size() == calendar.getComponents().size()) { return new Calendar[] {calendar}; for (final Iterator i = calendar.getComponents().iterator(); i.hasNext();) { final Component c = (Component) i.next(); if (c instanceof VTimeZone) { uidCal = new Calendar(calendar.getProperties(), new ComponentList()); if (tzid != null) { final VTimeZone timezone = (VTimeZone) timezones.getComponent(tzid.getValue()); if (!uidCal.getComponents().contains(timezone)) { uidCal.getComponents().add(timezone); uidCal.getComponents().add(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; }
if (masterCal.getComponents(Component.VEVENT).isEmpty()) { return masterCal; VEvent masterEvent = (VEvent) masterCal.getComponents(Component.VEVENT).get(0); VAlarm masterAlarm = getDisplayAlarm(masterEvent); String masterLocation = stamp.getLocation(); if(tz!=null) { VTimeZone vtz = tz.getVTimeZone(); masterCal.getComponents().add(0, vtz); tzMap.put(tzid, vtz); if(tz!=null) { VTimeZone vtz = tz.getVTimeZone(); masterCal.getComponents().add(0, vtz); tzMap.put(tzid, vtz); masterEvent.getAlarms().remove(masterAlarm); masterAlarm = null; exceptionEvent.getAlarms().remove(displayAlarm); if (masterAlarm != null) { exceptionEvent.getAlarms().add(masterAlarm); if(tz!=null) { VTimeZone vtz = tz.getVTimeZone(); masterCal.getComponents().add(0, vtz); tzMap.put(tzid, vtz);
cl = new ComponentList<>(); componentMap.put(uid.getValue(), cl); cl.add(comp); Component firstComp = (Component) entry.getValue().get(0); cal.getComponents().addAll(entry.getValue()); addTimezones(cal);
/** * Returns a list containing all components with specified name. * @param name name of components to return * @return a list of components with the matching name */ public final ComponentList getComponents(final String name) { final ComponentList components = new ComponentList(); for (final Iterator i = iterator(); i.hasNext();) { final Component c = (Component) i.next(); if (c.getName().equals(name)) { components.add(c); } } return components; }
/** * 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; }
private static VTimeZone generateTimezoneForId(String timezoneId) throws ParseException { if (!TIMEZONE_DEFINITIONS.contains(timezoneId)) { return null; } TimeZone javaTz = TimeZone.getTimeZone(timezoneId); ZoneId zoneId = ZoneId.of(javaTz.getID(), ZoneId.SHORT_IDS); int rawTimeZoneOffsetInSeconds = javaTz.getRawOffset() / 1000; VTimeZone timezone = new VTimeZone(); timezone.getProperties().add(new TzId(timezoneId)); addTransitions(zoneId, timezone, rawTimeZoneOffsetInSeconds); addTransitionRules(zoneId, rawTimeZoneOffsetInSeconds, timezone); if (timezone.getObservances() == null || timezone.getObservances().isEmpty()) { timezone.getObservances().add(NO_TRANSITIONS); } return timezone; }
/** * Creates a deep copy of the specified component list. * @param components a component list to copy * @throws IOException where an error occurs reading component data * @throws ParseException where component data cannot be parsed * @throws URISyntaxException where component data contains an invalid URI */ public ComponentList(ComponentList components) throws ParseException, IOException, URISyntaxException { for (final Iterator i = components.iterator(); i.hasNext();) { final Component c = (Component) i.next(); add(c.copy()); } }
public void setExceptionEvent(VEvent event) { if(getEventCalendar()==null) { createCalendar(); } // remove all events getEventCalendar().getComponents().removeAll( getEventCalendar().getComponents().getComponents(Component.VEVENT)); // add event exception getEventCalendar().getComponents().add(event); }
public VEvent getMasterEvent() { if(getEventCalendar()==null) { return null; } ComponentList<VEvent> events = getEventCalendar().getComponents().getComponents( Component.VEVENT); if(events.size()==0) { return null; } return (VEvent) events.get(0); }
/** * Convenience method for retrieving a named component. * @param name name of the component to retrieve * @return the first matching component in the component list with the specified name */ public final CalendarComponent getComponent(final String name) { return getComponents().getComponent(name); }
/** * Returns the first component containing a property with the specified * value. * @param propertyValue the value of the property identified in the returned * component * @return a component or null if no component is found containing a property * with the specified value */ public Component getComponent(final String propertyValue) { final ComponentList components = getComponents(propertyValue); if (!components.isEmpty()) { return (Component) components.iterator().next(); } return null; } }
/** * Constructor. * @param properties a list of properties */ public VEvent(final PropertyList properties) { super(VEVENT, properties); this.alarms = new ComponentList<VAlarm>(); }
public void run() { if (mCalendar == null) { mInsertDeleteLayout.setVisibility(View.GONE); return; } Resources res = getResources(); final int n = mCalendar.getComponents(VEvent.VEVENT).size(); mInsertButton.setText(get(res, R.plurals.insert_n_entries, n)); mDeleteButton.setText(get(res, R.plurals.delete_n_entries, n)); mInsertDeleteLayout.setVisibility(View.VISIBLE); mScrollViewMain.post(new Runnable() { @Override public void run() { mScrollViewMain.fullScroll(ScrollView.FOCUS_DOWN); } }); } private String get(Resources res, int id, int n) {
/** * Returns the first component containing a property with the specified * value. * @param propertyValue the value of the property identified in the returned * component * @return a component or null if no component is found containing a property * with the specified value */ public T getComponent(final String propertyValue) { final ComponentList<T> components = getComponents(propertyValue); if (!components.isEmpty()) { return components.get(0); } return null; } }
/** * {@inheritDoc} */ public final String toString() { final StringBuffer buffer = new StringBuffer(); for (final Iterator i = iterator(); i.hasNext();) { buffer.append(i.next().toString()); } return buffer.toString(); }