/** * 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; }
for (int j = 0; j < uids.size(); j++) { if (j != i) { assertFalse(uid.equals(uids.get(j)));
/** * 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 Component c : calendar.getComponents()) { for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } uid = (Uid) foundUid; } } if (uid == null) { throw new ConstraintViolationException("Calendar must specify a single unique identifier (UID)"); } return uid; }
/** * 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 Component c : calendar.getComponents()) { for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } uid = (Uid) foundUid; } } if (uid == null) { throw new ConstraintViolationException("Calendar must specify a single unique identifier (UID)"); } return uid; }
/** * 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 Component c : calendar.getComponents()) { for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } uid = (Uid) foundUid; } } if (uid == null) { throw new ConstraintViolationException("Calendar must specify a single unique identifier (UID)"); } return uid; }
/** * 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 Component c : calendar.getComponents()) { for (final Property foundUid : c.getProperties(Property.UID)) { if (uid != null && !uid.equals(foundUid)) { throw new ConstraintViolationException("More than one UID found in calendar"); } uid = (Uid) foundUid; } } if (uid == null) { throw new ConstraintViolationException("Calendar must specify a single unique identifier (UID)"); } return uid; }