@Override public Component transform(Component object) { PropertyList<Property> props = object.getProperties(); Organizer oldOrganizer = props.getProperty(Property.ORGANIZER); if (oldOrganizer != null) { props.remove(oldOrganizer); } props.add(organizer); return object; } }
@Override public Component transform(Component object) { PropertyList<Attendee> attendees = object.getProperties().getProperties(Property.ATTENDEE); if (attendees.contains(attendee)) { attendees.remove(attendee); } attendees.add(attendee); object.getProperties().addAll(attendees); return object; } }
/** * @param c Component * @param propName Property to check in Component. * @return Returns true if Component contains the property */ public static boolean hasProperty(Component c, String propName){ PropertyList l = c.getProperties().getProperties(propName); return l != null && l.size() > 0; }
protected void limitApparitionsNumberIn(Component component){ PropertyList<? extends Property> propertyList = component.getProperties(name); if(propertyList.size() <= maxApparitionNumber){ return; } int toRemove = propertyList.size() - maxApparitionNumber; for(int i = 0; i < toRemove; i++){ component.getProperties().remove(propertyList.get(i)); } }
@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); }
/** * 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; }
public void setRecurrenceRules(List<Recur> recurs) { if (recurs == null) { return; } PropertyList<Property> properties = getEvent().getProperties(); for (Property rrule : properties.getProperties(Property.RRULE)) { properties.remove(rrule); } for (Recur recur : recurs) { properties.add(new RRule(recur)); } }
/** * Constructs a new VALARM instance that will trigger at the specified time. * @param trigger the time the alarm will trigger */ public VAlarm(final DateTime trigger) { this(); getProperties().add(new Trigger(trigger)); }
/** * Returns a list of properties with the specified name. * @param name name of properties to return * @return a property list */ public final PropertyList getProperties(final String name) { final PropertyList list = new PropertyList(); for (final Iterator i = iterator(); i.hasNext();) { final Property p = (Property) i.next(); if (p.getName().equalsIgnoreCase(name)) { list.add(p); } } return list; }
/** * 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; }
@Override public Component transform(Component object) { Uid uid = object.getProperties().getProperty(Property.UID); if (uid == null) { object.getProperties().add(uidGenerator.generateUid()); } return object; } }
cc.getProperties().removeAll(attendees); while (attendees.size()>numAttendees) { Attendee a = (Attendee) attendees.get(numAttendees); if (! a.getValue().equals(user.getValue())) { attendees.remove(numAttendees); } else { a.getParameters().remove(a.getParameter(Parameter.PARTSTAT)); cc.getProperties().addAll(attendees);
(dateAfter(end, rangeStart) || dateEquals(end, rangeStart)) && comp.getProperties(Property.RRULE).isEmpty()) { Instance instance = new Instance(comp, start, end); put(instance.getRid().toString(), instance); .getProperties(Property.RDATE); for (RDate rdate : rDates) { PropertyList<RRule> rRules = comp.getProperties().getProperties(Property.RRULE); Date ajustedRangeEnd = null; if (rRules.size() > 0) { adjustedRangeStart = adjustStartRangeIfNecessary(rangeStart, start, duration); ajustedRangeEnd = adjustEndRangeIfNecessary(rangeEnd, start); PropertyList<ExDate> exDates = comp.getProperties().getProperties(Property.EXDATE); for (ExDate exDate : exDates) { for (Date sd : exDate.getDates()) { PropertyList<ExRule> exRules = comp.getProperties().getProperties(Property.EXRULE); if (exRules.size() > 0 && adjustedRangeStart == null) { adjustedRangeStart = adjustStartRangeIfNecessary(rangeStart, start, duration); ajustedRangeEnd = adjustEndRangeIfNecessary(rangeEnd, start);
/** * Convenience method for retrieving a named property. * @param name name of the property to retrieve * @return the first matching property in the property list with the specified name */ public final Property getProperty(final String name) { return getProperties().getProperty(name); }
/** Return an Iterator over required String attributes * * @param pl * @param name * @return Iterator over required String attributes * @throws Throwable */ public static Iterator<?> getReqStrs(final PropertyList pl, final String name) throws Throwable { PropertyList props = pl.getProperties(name); if ((props == null) || props.isEmpty()) { throw new IcalMalformedException("Missing required property " + name); } return props.iterator(); }
/** * Creates a deep copy of the specified property list. * @param properties a property list * @throws ParseException where property data cannot be parsed * @throws IOException where property data cannot be read * @throws URISyntaxException where a property contains an invalid URI */ public PropertyList(PropertyList properties) throws ParseException, IOException, URISyntaxException { super(); for (final Iterator i = properties.iterator(); i.hasNext();) { final Property p = (Property) i.next(); add(p.copy()); } }
/** * Constructs a new calendar with no properties and the specified components. * @param components a list of components to add to the calendar */ public Calendar(final ComponentList<CalendarComponent> components) { this(new PropertyList<Property>(), components); }
/** * Returns the first property containing a parameter with the specified * value. * @param paramValue the value of the parameter identified in the returned * property * @return a property or null if no property is found containing a parameter * with the specified value */ public Property getProperty(final String paramValue) { final PropertyList<Property> properties = getProperties(paramValue); if (!properties.isEmpty()) { return properties.iterator().next(); } return null; } }
newCal.getProperties().addAll(calendar.getProperties()); getProperty(Property.RECURRENCE_ID) == null) { newCal.getComponents().add(comp);
/** * Convenience method for retrieving a list of named properties. * * @param name name of properties to retrieve * @return a property list containing only properties with the specified name */ public final <C extends Property> PropertyList<C> getProperties(final String name) { return getProperties().getProperties(name); }