/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Iterator i = components.getComponents(Component.VEVENT).iterator(); i.hasNext();) { final Component component = (Component) i.next(); periods.addAll(((VEvent) component).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * A convenience method that combines all the periods in the specified list to * this list. The result returned is a new PeriodList instance, except where * no periods are specified in the arguments. In such cases this instance is returned. * * Normalisation is also performed automatically after all periods have been added. * * @param periods a list of periods to add * @return a period list instance */ public final PeriodList add(final PeriodList periods) { if (periods != null) { final PeriodList newList = new PeriodList(); newList.addAll(this); for (final Iterator i = periods.iterator(); i.hasNext();) { newList.add((Period) i.next()); } return newList.normalise(); } return this; }
/** * A convenience method that combines all the periods in the specified list to * this list. The result returned is a new PeriodList instance, except where * no periods are specified in the arguments. In such cases this instance is returned. * * Normalisation is also performed automatically after all periods have been added. * * @param periods a list of periods to add * @return a period list instance */ public final PeriodList add(final PeriodList periods) { if (periods != null) { final PeriodList newList = new PeriodList(); newList.addAll(this); newList.addAll(periods); return newList.normalise(); } return this; }
/** * A convenience method that combines all the periods in the specified list to * this list. The result returned is a new PeriodList instance, except where * no periods are specified in the arguments. In such cases this instance is returned. * * Normalisation is also performed automatically after all periods have been added. * * @param periods a list of periods to add * @return a period list instance */ public final PeriodList add(final PeriodList periods) { if (periods != null) { final PeriodList newList = new PeriodList(); newList.addAll(this); newList.addAll(periods); return newList.normalise(); } return this; }
/** * A convenience method that combines all the periods in the specified list to * this list. The result returned is a new PeriodList instance, except where * no periods are specified in the arguments. In such cases this instance is returned. * * Normalisation is also performed automatically after all periods have been added. * * @param periods a list of periods to add * @return a period list instance */ public final PeriodList add(final PeriodList periods) { if (periods != null) { final PeriodList newList = new PeriodList(); newList.addAll(this); for (final Period p : periods) { newList.add(p); } return newList.normalise(); } return this; }
/** * A convenience method that combines all the periods in the specified list to * this list. The result returned is a new PeriodList instance, except where * no periods are specified in the arguments. In such cases this instance is returned. * * Normalisation is also performed automatically after all periods have been added. * * @param periods a list of periods to add * @return a period list instance */ public final PeriodList add(final PeriodList periods) { if (periods != null) { final PeriodList newList = new PeriodList(); newList.addAll(this); for (final Period p : periods) { newList.add(p); } return newList.normalise(); } return this; }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
periods = periods.normalise();
periods = periods.normalise();
periods = periods.normalise();
periods = periods.normalise();
periods = periods.normalise();
/** * Unit tests for {@link PeriodList#normalise()}. */ public void testNormalise() { // test a list of periods consuming no time.. PeriodList periods = new PeriodList(); DateTime start = new DateTime(); periods.add(new Period(start, start)); DateTime start2 = new DateTime(); periods.add(new Period(start2, start2)); assertTrue(periods.normalise().isEmpty()); } }