当前位置: 首页>>代码示例>>Java>>正文


Java Calendar类代码示例

本文整理汇总了Java中net.fortuna.ical4j.model.Calendar的典型用法代码示例。如果您正苦于以下问题:Java Calendar类的具体用法?Java Calendar怎么用?Java Calendar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Calendar类属于net.fortuna.ical4j.model包,在下文中一共展示了Calendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAppointmentstoCalendar

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Parses a List of Appointments into a VCALENDAR component.
 *
 * @param appointments List of Appointments for the Calendar
 * @param ownerId      Owner of the Appointments
 * @return VCALENDAR representation of the Appointments
 */
public Calendar parseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId) {
	String tzid = parseTimeZone(null, userDao.get(ownerId)).getID();

	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();

	net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
	if (timeZone == null) {
		throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
	}

	Calendar icsCalendar = new Calendar();
	icsCalendar.getProperties().add(new ProdId(PROD_ID));
	icsCalendar.getProperties().add(Version.VERSION_2_0);
	icsCalendar.getProperties().add(CalScale.GREGORIAN);
	icsCalendar.getComponents().add(timeZone.getVTimeZone());

	for (Appointment appointment : appointments) {
		DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());

		VEvent meeting = new VEvent(start, end, appointment.getTitle());
		meeting = addVEventpropsfromAppointment(appointment, meeting);
		icsCalendar.getComponents().add(meeting);
	}
	return icsCalendar;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:33,代码来源:IcalUtils.java

示例2: MultigetHandler

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
public MultigetHandler(List<String> hrefs, boolean onlyEtag, String path, OmCalendar calendar, HttpClient client,
		AppointmentDao appointmentDao, IcalUtils utils) {
	super(path, calendar, client, appointmentDao, utils);
	this.onlyEtag = onlyEtag;

	if (hrefs == null || hrefs.isEmpty() || calendar.getSyncType() == SyncType.NONE) {
		isMultigetDisabled = true;
	} else {
		DavPropertyNameSet properties = new DavPropertyNameSet();
		properties.add(DavPropertyName.GETETAG);

		CalendarData calendarData = null;
		if (!onlyEtag) {
			calendarData = new CalendarData();
		}
		CompFilter vcalendar = new CompFilter(Calendar.VCALENDAR);
		vcalendar.addCompFilter(new CompFilter(Component.VEVENT));
		query = new CalendarMultiget(properties, calendarData, false, false);
		query.setHrefs(hrefs);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:22,代码来源:MultigetHandler.java

示例3: createCalendarResource

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
protected DavContent createCalendarResource(DavRequest request,
                                              DavResponse response,
                                              DavResourceLocator locator,
                                              Calendar calendar)
      throws CosmoDavException {
      if (!calendar.getComponents(Component.VEVENT).isEmpty()) {
          return new DavEvent(locator, getResourceFactory(), getEntityFactory());
      }
      if (!calendar.getComponents(Component.VTODO).isEmpty()) {
          return new DavTask(locator, getResourceFactory(), getEntityFactory());
      }
      if (!calendar.getComponents(Component.VJOURNAL).isEmpty()) {
          return new DavJournal(locator, getResourceFactory(), getEntityFactory());
      }
      if (!calendar.getComponents(Component.VFREEBUSY).isEmpty()) {
          return new DavFreeBusy(locator, getResourceFactory(), getEntityFactory());
      }
      if (!calendar.getComponents(ICalendarConstants.COMPONENT_VAVAILABLITY)
              .isEmpty()) {
          return new DavAvailability(locator, getResourceFactory(), getEntityFactory());
      }
      throw new SupportedCalendarComponentException();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:24,代码来源:CalendarResourceProvider.java

示例4: handleEventStampFilter

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * handle event stamp filter.
 * @param s The stamp.
 * @param esf The event stamp filter.
 * @return boolean.
 */
private boolean handleEventStampFilter(Stamp s, EventStampFilter esf) {
    
    BaseEventStamp es = (BaseEventStamp) s;
    
    // check recurring
    if(esf.getIsRecurring()!=null) {
        if(esf.getIsRecurring().booleanValue() && !es.isRecurring()) {
            return false;
        }
        else if(!esf.getIsRecurring().booleanValue() && es.isRecurring()) {
            return false;
        }
    }   
    
    Calendar cal = new EntityConverter(null).convertNote((NoteItem) s.getItem());
    CalendarFilter cf = getCalendarFilter(esf);
    CalendarFilterEvaluater cfe = new CalendarFilterEvaluater();
    
    if(cfe.evaluate(cal, cf)==false) {
        return false;
    }
    
    return true;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:31,代码来源:ItemFilterEvaluater.java

示例5: convertEventCalendar

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Expands an event calendar and returns a set of notes representing the
 * master and exception items.
 * <p>
 * The provided note corresponds to the recurrence master or, for
 * non-recurring items, the single event in the calendar. The result set
 * includes both the master note as well as a modification note for
 * exception event in the calendar.
 * </p>
 * <p>
 * If the master note does not already have a UUID or an event stamp, one
 * is assigned to it. A UUID is assigned because any modification items
 * that are created require the master's UUID in order to construct
 * their own.
 * </p>
 * <p>
 * If the given note is already persistent, and the calendar does not
 * contain an exception event matching an existing modification, that
 * modification is set inactive. It is still returned in the result set.
 * </p>
 * @param note The note item.
 * @param calendar The calendar.
 * @return set note item.
 */
public Set<NoteItem> convertEventCalendar(NoteItem note, Calendar calendar) {
    EventStamp eventStamp = (EventStamp) note.getStamp(EventStamp.class);
    
    if (eventStamp == null) {
        eventStamp = entityFactory.createEventStamp(note);
        note.addStamp(eventStamp);
    }

    if (note.getUid() == null) {
        note.setUid(entityFactory.generateUid());
    }

    updateEventInternal(note, calendar);

    LinkedHashSet<NoteItem> items = new LinkedHashSet<NoteItem>();
    items.add(note);

    // add modifications to set of items
    for(Iterator<NoteItem> it = note.getModifications().iterator(); it.hasNext();) {
        NoteItem mod = it.next();
        items.add(mod);
    }

    return items;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:50,代码来源:EntityConverter.java

示例6: addToInstanceList

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
    * Adds to instance list.
    *
    * @param calendar  The calendar.
    * @param instances The instances.
    * @param start     The start.
    * @param end       The end.
    */
   private static void addToInstanceList(Calendar calendar,
                                         InstanceList instances, Date start, Date end) {
       ComponentList<VEvent> vevents = calendar.getComponents().getComponents(VEvent.VEVENT);
Iterator<VEvent> it = vevents.iterator();
       boolean addedMaster = false;
       while (it.hasNext()) {
           VEvent event = (VEvent)it.next();
           if (event.getRecurrenceId() == null) {
               addedMaster = true;
               instances.addComponent(event, start, end);
           } else {
               Assert.assertTrue(addedMaster);
               instances.addOverride(event, start, end);
           }
       }
   }
 
开发者ID:1and1,项目名称:cosmo,代码行数:25,代码来源:InstanceListTest.java

示例7: post

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
@Override
public void post(DavRequest request, DavResponse response, WebDavResource resource) throws CosmoDavException, IOException {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Handling POST method for Outbox");
    }

    int status = DavResponse.SC_OK;
    ScheduleMultiResponse ms = new ScheduleMultiResponse();
    try {
        // according to http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-05
        // only REQUEST and REFRESH are available for post
        DavInputContext ctx = (DavInputContext) createInputContext(request);
        Calendar calendar = ctx.getCalendar(true);

        processPostRequest(calendar, ms);
    } catch (RuntimeException exc) {
        status = DavResponse.SC_INTERNAL_SERVER_ERROR;
    }

    response.sendXmlResponse(ms, status);
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:22,代码来源:OutboxCollectionProvider.java

示例8: getCalendarFilter

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Gets calendar filter.
 * @param esf event stamp filter.
 * @return calendar filter.
 */
private CalendarFilter getCalendarFilter(EventStampFilter esf) {
    ComponentFilter eventFilter = new ComponentFilter(Component.VEVENT);
    eventFilter.setTimeRangeFilter(new TimeRangeFilter(esf.getPeriod().getStart(), esf.getPeriod().getEnd()));
    if (esf.getTimezone() != null) {
        eventFilter.getTimeRangeFilter().setTimezone(esf.getTimezone().getVTimeZone());
    }

    ComponentFilter calFilter = new ComponentFilter(
            net.fortuna.ical4j.model.Calendar.VCALENDAR);
    calFilter.getComponentFilters().add(eventFilter);

    CalendarFilter filter = new CalendarFilter();
    filter.setFilter(calFilter);
    
    return filter;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:22,代码来源:ItemFilterEvaluater.java

示例9: createCalendar

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
public void createCalendar() {
    
    NoteItem note = (NoteItem) getItem();
   
    String icalUid = note.getIcalUid();
    if(icalUid==null) {
        // A modifications UID will be the parent's icaluid
        // or uid
        if(note.getModifies()!=null) {
            if(note.getModifies().getIcalUid()!=null) {
                icalUid = note.getModifies().getIcalUid();
            }
            else {
                icalUid = note.getModifies().getUid();
            }
        } else {
            icalUid = note.getUid();
        }
    }

    Calendar cal = ICalendarUtils.createBaseCalendar(new VEvent(), icalUid);
    
    setEventCalendar(cal);
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:25,代码来源:HibBaseEventStamp.java

示例10: hasMultipleComponentTypes

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
public static boolean hasMultipleComponentTypes(Calendar calendar) {
    String found = null;
    for (Object component: calendar.getComponents()) {
        if (component instanceof VTimeZone) {
            continue;
        }
        if (found == null) {
            found = ((CalendarComponent)component).getName();
            continue;
        }
        if (! found.equals(((CalendarComponent)component).getName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:17,代码来源:CalendarUtils.java

示例11: writeContentOnResponse

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
private void writeContentOnResponse(DavRequest request, DavResponse response, WebDavResource resource)
        throws IOException {
    // strip the content if there's a ticket with free-busy access
    if (!(resource instanceof DavCalendarCollection)) {
        throw new IllegalStateException("Incompatible resource type for this provider");
    }
    DavCalendarCollection davCollection = DavCalendarCollection.class.cast(resource);
    CollectionItem collectionItem = (CollectionItem) davCollection.getItem();

    Calendar result = getCalendarFromCollection(request, collectionItem);

    Ticket contextTicket = getSecurityContext().getTicket();
    Set<Ticket> collectionTickets = collectionItem.getTickets();
    if (contextTicket != null && collectionTickets != null) {
        if (collectionTickets.contains(contextTicket) && contextTicket.isFreeBusy()) {
            result = FreeBusyUtil.getFreeBusyCalendar(result, this.productId);
        }
    }
    response.setHeader("ETag", "\""+ resource.getETag() +"\"");
    response.setContentType(ICALENDAR_MEDIA_TYPE);
    response.setCharacterEncoding(CHARSET_UTF8);
    response.getWriter().write(result.toString());
    response.flushBuffer();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:25,代码来源:CalendarCollectionProvider.java

示例12: evaluate

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Evaulate CalendarFilter against a Calendar.
 * @param calendar calendar to evaluate against
 * @param filter filter to apply
 * @return true if the filter
 * @throws UnsupportedQueryException if filter represents a query
 *                              that the server does not support
 */
public boolean evaluate(Calendar calendar, CalendarFilter filter) {
    ComponentFilter rootFilter = filter.getFilter();
    
    // root filter must be "VCALENDAR"
    if(!COMP_VCALENDAR.equalsIgnoreCase(rootFilter.getName())) {
        return false;
    }
    
    stack.clear();
    
    // evaluate all component filters
    for(ComponentFilter compFilter : rootFilter.getComponentFilters()) {            
        // If any component filter fails to match, then the calendar filter
        // does not match
        if(!evaluateComps(calendar.getComponents(), compFilter)) {
            return false;
        }
    }
    
    return true;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:30,代码来源:CalendarFilterEvaluater.java

示例13: testEvaluateVJournalFilterPropFilter

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Tests evaluate VJournal filter prop filter.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testEvaluateVJournalFilterPropFilter() throws Exception {
    
    CalendarFilterEvaluater evaluater = new CalendarFilterEvaluater();
    Calendar calendar = getCalendar("vjournal.ics");
    
    
    CalendarFilter filter = new CalendarFilter();
    ComponentFilter compFilter = new ComponentFilter("VCALENDAR");
    ComponentFilter eventFilter = new ComponentFilter("VJOURNAL");
    filter.setFilter(compFilter);
    compFilter.getComponentFilters().add(eventFilter);
    
    Assert.assertTrue(evaluater.evaluate(calendar, filter));
    
    PropertyFilter propFilter = new PropertyFilter("SUMMARY");
    TextMatchFilter textFilter = new TextMatchFilter("Staff");
    propFilter.setTextMatchFilter(textFilter);
    eventFilter.getPropFilters().add(propFilter);
    
    Assert.assertTrue(evaluater.evaluate(calendar, filter));
    
    textFilter.setValue("bogus");
    Assert.assertFalse(evaluater.evaluate(calendar, filter));
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:30,代码来源:CalendarFilterEvaluaterTest.java

示例14: testRecurrenceExpanderFloating

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
/**
 * Tests reccurence expander floating.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test 
public void testRecurrenceExpanderFloating() throws Exception {
    RecurrenceExpander expander = new RecurrenceExpander();
    Calendar calendar = getCalendar("floating_recurring1.ics");
    
    Date[] range = expander.calculateRecurrenceRange(calendar);
    
    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertEquals("20070119T120000", range[1].toString());
    
    calendar = getCalendar("floating_recurring2.ics");
    range = expander.calculateRecurrenceRange(calendar);
    
    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertNull(range[1]);
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:21,代码来源:RecurrenceExpanderTest.java

示例15: asItems

import net.fortuna.ical4j.model.Calendar; //导入依赖的package包/类
public Set<NoteItem> asItems(Calendar calendar) {
    Set<NoteItem> items = new HashSet<>();
    if (calendar != null) {
        Set<ICalendarItem> calendarItems = this.entityConverter.convertCalendar(calendar);

        for (ICalendarItem item : calendarItems) {
            /**
             * Only VEVENT are supported currently. VTODO or VJOURNAL are not yet supported.
             */
            if (item instanceof HibNoteItem) {
                HibNoteItem noteItem = (HibNoteItem) item;
                Date now = new Date();
                noteItem.setCreationDate(now);
                noteItem.setModifiedDate(now);
                items.add(noteItem);
                noteItem.setName(noteItem.getIcalUid() + ".ics");
            }
        }
    }
    return items;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:22,代码来源:ContentConverter.java


注:本文中的net.fortuna.ical4j.model.Calendar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。