/** * {@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(); }
/** * {@inheritDoc} */ public final String toString() { final StringBuilder sb = new StringBuilder(); for (final Iterator<T> i = iterator(); i.hasNext();) { sb.append(i.next().toString()); } return sb.toString(); }
/** * Returns the first property of specified name. * @param aName name of property to return * @return a property or null if no matching property found */ public final Property getProperty(final String aName) { for (final Iterator i = iterator(); i.hasNext();) { final Property p = (Property) i.next(); if (p.getName().equalsIgnoreCase(aName)) { return p; } } return null; }
/** * Invoke validation on the component properties in its current state. * @throws ValidationException where any of the component properties is not in a valid state */ protected final void validateProperties() throws ValidationException { for (final Iterator i = getProperties().iterator(); i.hasNext();) { final Property property = (Property) i.next(); property.validate(); } }
/** * Invoke validation on the calendar properties in its current state. * @throws ValidationException where any of the calendar properties is not in a valid state */ private void validateProperties() throws ValidationException { for (final Iterator i = getProperties().iterator(); i.hasNext();) { final Property property = (Property) i.next(); property.validate(); } }
/** * 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()); } }
/** * 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; } }
/** * 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; }
/** * 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 (Property) properties.iterator().next(); } return null; } }
/** * 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; } }
/** * 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 properties = getProperties(paramValue); if (!properties.isEmpty()) { return (Property) properties.iterator().next(); } return null; } }
/** * Creates a new instance indexed on properties with the specified name. * @param list a list of components * @param propertyName the name of the properties to index on */ public IndexedComponentList(final ComponentList list, final String propertyName) { final Map indexedComponents = new HashMap(); for (final Iterator i = list.iterator(); i.hasNext();) { final Component component = (Component) i.next(); for (final Iterator j = component.getProperties(propertyName).iterator(); j.hasNext();) { final Property property = (Property) j.next(); ComponentList components = (ComponentList) indexedComponents.get(property.getValue()); if (components == null) { components = new ComponentList(); indexedComponents.put(property.getValue(), components); } components.add(component); } } this.index = Collections.unmodifiableMap(indexedComponents); }
/** * Creates a new instance indexed on the parameters with the specified name. * @param list a list of properties * @param parameterName the name of parameters on which to index */ public IndexedPropertyList(final PropertyList list, final String parameterName) { final Map indexedProperties = new HashMap(); for (final Iterator i = list.iterator(); i.hasNext();) { final Property property = (Property) i.next(); for (final Iterator j = property.getParameters(parameterName).iterator(); j.hasNext();) { final Parameter parameter = (Parameter) j.next(); PropertyList properties = (PropertyList) indexedProperties.get(parameter.getValue()); if (properties == null) { properties = new PropertyList(); indexedProperties.put(parameter.getValue(), properties); } properties.add(property); } } this.index = Collections.unmodifiableMap(indexedProperties); }
/** * Creates a new instance indexed on the parameters with the specified name. * @param list a list of properties * @param parameterName the name of parameters on which to index */ public IndexedPropertyList(final PropertyList<Property> list, final String parameterName) { final Map<String, PropertyList<Property>> indexedProperties = new HashMap<String, PropertyList<Property>>(); for (final Iterator<Property> i = list.iterator(); i.hasNext();) { final Property property = (Property) i.next(); for (final Iterator<Parameter> j = property.getParameters(parameterName).iterator(); j.hasNext();) { final Parameter parameter = (Parameter) j.next(); PropertyList<Property> properties = indexedProperties.get(parameter.getValue()); if (properties == null) { properties = new PropertyList<Property>(); indexedProperties.put(parameter.getValue(), properties); } properties.add(property); } } this.index = Collections.unmodifiableMap(indexedProperties); }
/** 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(); }
/** * {@inheritDoc} */ public final boolean match(final Component component) { boolean match = false; final PropertyList properties = component.getProperties(property.getName()); for (final Iterator i = properties.iterator(); i.hasNext();) { final Property p = (Property) i.next(); if (matchEquals && property.equals(p)) { match = true; } else if (property.getValue().equals(p.getValue())) { match = true; } } return match; } }
/** * Returns a unique identifier as specified by components in the provided calendar. * @param calendar a calendar instance * @return the UID property * @throws ConstraintViolationException if zero or more than one unique identifer is found in the specified calendar */ public static Uid getUid(final Calendar calendar) throws ConstraintViolationException { Uid uid = null; for (final Iterator i = calendar.getComponents().iterator(); i.hasNext();) { final Component c = (Component) i.next(); for (final Iterator j = c.getProperties(Property.UID).iterator(); j.hasNext();) { final Uid foundUid = (Uid) j.next(); if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } uid = foundUid; } } if (uid == null) { throw new ConstraintViolationException("Calendar must specify a single unique identifier (UID)"); } return uid; }
protected static void loadRelatedParties(List<GenericValue> relatedParties, PropertyList componentProps, Map<String, Object> context) { PropertyList attendees = componentProps.getProperties("ATTENDEE"); for (GenericValue partyValue : relatedParties) { if ("CAL_ORGANIZER~CAL_OWNER".contains(partyValue.getString("roleTypeId"))) { // RFC 2445 4.6.1, 4.6.2, and 4.6.3 ORGANIZER can appear only once replaceProperty(componentProps, createOrganizer(partyValue, context)); } else { String partyId = partyValue.getString("partyId"); boolean newAttendee = true; Attendee attendee = null; Iterator<Attendee> i = UtilGenerics.cast(attendees.iterator()); while (i.hasNext()) { attendee = i.next(); Parameter xParameter = attendee.getParameter(partyIdXParamName); if (xParameter != null && partyId.equals(xParameter.getValue())) { loadPartyAssignment(attendee, partyValue, context); newAttendee = false; break; } } if (newAttendee) { attendee = createAttendee(partyValue, context); componentProps.add(attendee); } } } }
uidCal = new Calendar(calendar.getProperties(), new ComponentList()); for (final Iterator mp = uidCal.getProperties(Property.METHOD).iterator(); mp.hasNext();) { uidCal.getProperties().remove(mp.next()); for (final Iterator j = c.getProperties().iterator(); j.hasNext();) { final Property p = (Property) j.next(); final TzId tzid = (TzId) p.getParameter(Parameter.TZID);
/** * 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; }