本文整理汇总了Java中net.fortuna.ical4j.model.PeriodList类的典型用法代码示例。如果您正苦于以下问题:Java PeriodList类的具体用法?Java PeriodList怎么用?Java PeriodList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PeriodList类属于net.fortuna.ical4j.model包,在下文中一共展示了PeriodList类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEventsInPeriod
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
public static List<Event> getEventsInPeriod(final Calendar cal, final Period period) {
final Filter filter = new Filter(new Rule[] {new PeriodRule(period)}, Filter.MATCH_ALL);
final List<Component> filtered = (List<Component>) filter.filter(cal.getComponents());
final List<Event> ret = new ArrayList<>();
for (final Component comp : filtered) {
if (!(comp instanceof VEvent)) {
continue;
}
final PeriodList recurrenceSet = comp.calculateRecurrenceSet(period);
for (final Object p : recurrenceSet) {
ret.add(new Event(
getValueIfExists(comp, Property.SUMMARY),
getValueIfExists(comp, Property.URL),
(Period) p));
}
}
Collections.sort(ret);
return ret;
}
示例2: freeBusyQuery
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
* VFreeBusy query.
* @param user The user.
* @param period The period.
* @return VFreeBusy.
*/
public VFreeBusy freeBusyQuery(User user, Period period) {
PeriodList busyPeriods = new PeriodList();
PeriodList busyTentativePeriods = new PeriodList();
PeriodList busyUnavailablePeriods = new PeriodList();
HomeCollectionItem home = contentDao.getRootItem(user);
for(Item item: home.getChildren()) {
if(! (item instanceof CollectionItem)) {
continue;
}
CollectionItem collection = (CollectionItem) item;
if(StampUtils.getCalendarCollectionStamp(collection)==null ||
collection.isExcludeFreeBusyRollup()) {
continue;
}
doFreeBusyQuery(busyPeriods, busyTentativePeriods, busyUnavailablePeriods,
collection, period);
}
return createVFreeBusy(busyPeriods, busyTentativePeriods,
busyUnavailablePeriods, period);
}
示例3: doFreeBusyQuery
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
* Adds The FreeBusy query.
* @param busyPeriods The period list.
* @param busyTentativePeriods The period list.
* @param busyUnavailablePeriods The busy unavailable periods periods.
* @param collection The collecton item.
* @param period The period.
*/
protected void doFreeBusyQuery(PeriodList busyPeriods,
PeriodList busyTentativePeriods, PeriodList busyUnavailablePeriods,
CollectionItem collection, Period period) {
CalendarCollectionStamp ccs = StampUtils.getCalendarCollectionStamp(collection);
if(ccs==null) {
return;
}
HashSet<ContentItem> results = new HashSet<ContentItem>();
TimeZone tz = ccs.getTimezone();
// For the time being, use CalendarFilters to get relevant
// items.
CalendarFilter[] filters = createQueryFilters(collection, period);
for(CalendarFilter filter: filters) {
results.addAll(calendarDao.findCalendarItems(collection, filter));
}
for(ContentItem content: results) {
Calendar calendar = entityConverter.convertContent(content);
if(calendar==null) {
continue;
}
// Add busy details from the calendar data
addBusyPeriods(calendar, tz, period, busyPeriods,
busyTentativePeriods, busyUnavailablePeriods);
}
}
示例4: addRelevantPeriods
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
* Add all periods that intersect a given period to the result PeriodList.
*/
private void addRelevantPeriods(PeriodList results, PeriodList periods,
Period range) {
for (Iterator<Period> it = periods.iterator(); it.hasNext();) {
Period p = it.next();
if (p.intersects(range))
results.add(p);
}
}
示例5: evaulateVFreeBusyTimeRange
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
* Evaluates VFreeBusy time range.
* @param freeBusy freebusy.
* @param filter The filter.
* @return The result.
*/
private boolean evaulateVFreeBusyTimeRange(VFreeBusy freeBusy, TimeRangeFilter filter) {
DtStart start = freeBusy.getStartDate();
DtEnd end = freeBusy.getEndDate();
if (start != null && end != null) {
InstanceList instances = new InstanceList();
if (filter.getTimezone() != null) {
instances.setTimezone(new TimeZone(filter.getTimezone()));
}
instances.addComponent(freeBusy, filter.getPeriod().getStart(),
filter.getPeriod().getEnd());
return instances.size() > 0;
}
PropertyList<FreeBusy> props = freeBusy.getProperties(Property.FREEBUSY);
if(props.size()==0) {
return false;
}
for (FreeBusy fb : props) {
PeriodList periods = fb.getPeriods();
Iterator<Period> periodIt = periods.iterator();
while(periodIt.hasNext()) {
Period period = periodIt.next();
if(filter.getPeriod().getStart().before(period.getEnd()) &&
filter.getPeriod().getEnd().after(period.getStart())) {
return true;
}
}
}
return false;
}
示例6: information
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
A VFREEBUSY component overlaps a given time range if the condition
for the corresponding component state specified in the table below
is satisfied. The conditions depend on the presence in the
VFREEBUSY component of the DTSTART and DTEND properties, and any
FREEBUSY properties in the absence of DTSTART and DTEND. Any
DURATION property is ignored, as it has a special meaning when
used in a VFREEBUSY component.
When only FREEBUSY properties are used, each period in each
FREEBUSY property is compared against the time range, irrespective
of the type of free busy information (free, busy, busy-tentative,
busy-unavailable) represented by the property.
+------------------------------------------------------+
| VFREEBUSY has both the DTSTART and DTEND properties? |
| +--------------------------------------------------+
| | VFREEBUSY has the FREEBUSY property? |
| | +----------------------------------------------+
| | | Condition to evaluate |
+---+---+----------------------------------------------+
| Y | * | (start <= DTEND) AND (end > DTSTART) |
+---+---+----------------------------------------------+
| N | Y | (start < freebusy-period-end) AND |
| | | (end > freebusy-period-start) |
+---+---+----------------------------------------------+
| N | N | FALSE |
+---+---+----------------------------------------------+
*
* @param freeBusy comoponent to test
* @param period period to test against
* @param tz timezone to use for floating times
* @return true if component overlaps specified range, false otherwise
*/
public static boolean overlapsPeriod(VFreeBusy freeBusy, Period period, TimeZone tz){
DtStart start = freeBusy.getStartDate();
DtEnd end = freeBusy.getEndDate();
if (start != null && end != null) {
InstanceList instances = new InstanceList();
instances.setTimezone(tz);
instances.addComponent(freeBusy, period.getStart(),period.getEnd());
return instances.size() > 0;
}
PropertyList<FreeBusy> props = freeBusy.getProperties(Property.FREEBUSY);
if (props.size()==0) {
return false;
}
for (FreeBusy fb: props) {
PeriodList periods = fb.getPeriods();
Iterator<Period> periodIt = periods.iterator();
while(periodIt.hasNext()) {
Period fbPeriod = periodIt.next();
if(fbPeriod.intersects(period)) {
return true;
}
}
}
return false;
}
示例7: testAddBusyPeriodsRecurringAllDay
import net.fortuna.ical4j.model.PeriodList; //导入依赖的package包/类
/**
* Test the add of busy periods recurring all day.
* @throws Exception - if something is wrong this exception is thrown.
*/
@Test
public void testAddBusyPeriodsRecurringAllDay() throws Exception {
PeriodList busyPeriods = new PeriodList();
PeriodList busyTentativePeriods = new PeriodList();
PeriodList busyUnavailablePeriods = new PeriodList();
// the range
DateTime start = new DateTime("20070103T090000Z");
DateTime end = new DateTime("20070117T090000Z");
Period fbRange = new Period(start, end);
Calendar calendar = CalendarUtils.parseCalendar(testHelper.getBytes("allday_weekly_recurring.ics"));
// test several timezones
TimeZone tz = TIMEZONE_REGISTRY.getTimeZone("America/Chicago");
queryProcessor.addBusyPeriods(calendar, tz, fbRange, busyPeriods, busyTentativePeriods, busyUnavailablePeriods);
Assert.assertEquals("20070108T060000Z/20070109T060000Z,20070115T060000Z/20070116T060000Z", busyPeriods.toString());
busyPeriods.clear();
tz = TIMEZONE_REGISTRY.getTimeZone("America/Los_Angeles");
queryProcessor.addBusyPeriods(calendar, tz, fbRange, busyPeriods, busyTentativePeriods, busyUnavailablePeriods);
Assert.assertEquals("20070108T080000Z/20070109T080000Z,20070115T080000Z/20070116T080000Z", busyPeriods.toString());
busyPeriods.clear();
tz = TIMEZONE_REGISTRY.getTimeZone("Australia/Sydney");
queryProcessor.addBusyPeriods(calendar, tz, fbRange, busyPeriods, busyTentativePeriods, busyUnavailablePeriods);
Assert.assertEquals("20070107T130000Z/20070108T130000Z,20070114T130000Z/20070115T130000Z", busyPeriods.toString());
}