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


Java CalendarBuilder.build方法代码示例

本文整理汇总了Java中net.fortuna.ical4j.data.CalendarBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java CalendarBuilder.build方法的具体用法?Java CalendarBuilder.build怎么用?Java CalendarBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.fortuna.ical4j.data.CalendarBuilder的用法示例。


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

示例1: ReadCalendarFiles

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
public ReadCalendarFiles(String filePath) throws IOException, ParserException {
  Map<String, String> calendarEntry = null;
  FileInputStream fin = new FileInputStream(filePath);
  CalendarBuilder builder = new CalendarBuilder();
  net.fortuna.ical4j.model.Calendar calendar = builder.build(fin);
  for (Iterator i = calendar.getComponents().iterator(); i.hasNext(); ) {
    Component component = (Component) i.next();
    if (component.getName().equalsIgnoreCase("VEVENT")) {
      calendarEntry = new HashMap<>();
      for (Iterator j = component.getProperties().iterator(); j.hasNext(); ) {
        net.fortuna.ical4j.model.Property property = (Property) j.next();
        calendarEntry.put(property.getName(), property.getValue());
      }
      calendarEntries.add(calendarEntry);
    }
  }
}
 
开发者ID:mark-watson,项目名称:power-java,代码行数:18,代码来源:ReadCalendarFiles.java

示例2: readCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Internal read calendar file from filesystem
 */
@Override
public Calendar readCalendar(final String type, final String calendarID) {
    log.debug("readCalendar from file, type=" + type + "  calendarID=" + calendarID);
    final File calendarFile = getCalendarFile(type, calendarID);

    InputStream in = null;
    try {
        in = new BufferedInputStream(new FileInputStream(calendarFile));
    } catch (final FileNotFoundException fne) {
        throw new OLATRuntimeException("Not found: " + calendarFile, fne);
    }

    final CalendarBuilder builder = new CalendarBuilder();
    Calendar calendar = null;
    try {
        calendar = builder.build(in);
    } catch (final Exception e) {
        throw new OLATRuntimeException("Error parsing calendar file.", e);
    } finally {
        if (in != null) {
            FileUtils.closeSafely(in);
        }
    }
    return calendar;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:29,代码来源:CalendarDaoICalFileImpl.java

示例3: extractUid

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
private String extractUid(String icalendar) throws IOException, ParserException {
    
    String uid = null;
    StringReader reader = new StringReader(icalendar);
    CalendarBuilder builder = new CalendarBuilder();
    Calendar calendar = builder.build(new UnfoldingReader(reader, true));
    if ( calendar != null && calendar.getComponents() != null ) {
        Iterator<Component> iterator = calendar.getComponents().iterator();
        while (iterator.hasNext()) {
            Component component = iterator.next();
            if ( component instanceof VEvent ) {
                uid = ((VEvent)component).getUid().getValue();
                break;
            }
        }
    }
    
    return uid;
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:20,代码来源:EventCollectionResource.java

示例4: testContentDaoCreateAvailability

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Tests content dao create availability.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testContentDaoCreateAvailability() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    AvailabilityItem newItem = new HibAvailabilityItem();
    newItem.setOwner(user);
    newItem.setName("test");
    newItem.setIcalUid("icaluid");
    
    CalendarBuilder cb = new CalendarBuilder();
    net.fortuna.ical4j.model.Calendar calendar = cb.build(helper.getInputStream("vavailability.ics"));
    
    newItem.setAvailabilityCalendar(calendar);
    
    newItem = (AvailabilityItem) contentDao.createContent(root, newItem);

    Assert.assertTrue(getHibItem(newItem).getId() > -1);
    Assert.assertNotNull(newItem.getUid());

    clearSession();

    ContentItem queryItem = (ContentItem) contentDao.findItemByUid(newItem.getUid());

    helper.verifyItem(newItem, queryItem);
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:31,代码来源:HibernateContentDaoTest.java

示例5: getCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Gets calendar.
 * @param name The name.
 * @return The calendar.
 * @throws Exception - if something is wrong this exception is thrown.
 */
protected Calendar getCalendar(String name) throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    InputStream in = getClass().getClassLoader().getResourceAsStream("testdata/" + name);
    if (in == null) {
        throw new IllegalStateException("resource " + name + " not found");
    }        
    Calendar calendar = cb.build(in);
    return calendar;
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:16,代码来源:CalendarFilterEvaluaterTest.java

示例6: testLimitRecurrenceSetThisAndFuture

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Tests the set of limit recurrence.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testLimitRecurrenceSetThisAndFuture() throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    FileInputStream fis = new FileInputStream(baseDir + "limit_recurr_taf_test.ics");
    Calendar calendar = cb.build(fis);
    
    Assert.assertEquals(4, calendar.getComponents().getComponents("VEVENT").size());
    
    VTimeZone vtz = (VTimeZone) calendar.getComponents().getComponent("VTIMEZONE");
    TimeZone tz = new TimeZone(vtz);
    OutputFilter filter = new OutputFilter("test");
    DateTime start = new DateTime("20060108T170000", tz);
    DateTime end = new DateTime("20060109T170000", tz);
    start.setUtc(true);
    end.setUtc(true);
    
    Period period = new Period(start, end);
    filter.setLimit(period);
    filter.setAllSubComponents();
    filter.setAllProperties();
    
    StringBuffer buffer = new StringBuffer();
    filter.filter(calendar, buffer);
    StringReader sr = new StringReader(buffer.toString());
    
    Calendar filterCal = cb.build(sr);
    
    Assert.assertEquals(2, filterCal.getComponents().getComponents("VEVENT").size());
    // Make sure 2nd and 3rd override are dropped
    ComponentList<VEvent> vevents = filterCal.getComponents().getComponents(VEvent.VEVENT);
    
    for(VEvent c : vevents) {            
        Assert.assertNotSame("event 6 changed",c.getProperties().getProperty("SUMMARY").getValue());
        Assert.assertNotSame("event 6 changed 2",c.getProperties().getProperty("SUMMARY").getValue());
    }   
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:41,代码来源:LimitRecurrenceSetTest.java

示例7: getCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Gets calendar.
 * @param name The name.
 * @return The calendar.
 * @throws Exception - if something is wrong this exception is thrown.
 */
protected Calendar getCalendar(String name) throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    FileInputStream fis = new FileInputStream(baseDir + name);
    Calendar calendar = cb.build(fis);
    return calendar;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:13,代码来源:EntityConverterTest.java

示例8: testLimitFloatingRecurrenceSet

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Tests limit floating recurrence set.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testLimitFloatingRecurrenceSet() throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    FileInputStream fis = new FileInputStream(baseDir + "limit_recurr_float_test.ics");
    Calendar calendar = cb.build(fis);
    
    Assert.assertEquals(3, calendar.getComponents().getComponents("VEVENT").size());
    
    OutputFilter filter = new OutputFilter("test");
    DateTime start = new DateTime("20060102T170000");
    DateTime end = new DateTime("20060104T170000");
    
    start.setUtc(true);
    end.setUtc(true);
    
    Period period = new Period(start, end);
    filter.setLimit(period);
    filter.setAllSubComponents();
    filter.setAllProperties();
    
    StringBuffer buffer = new StringBuffer();
    filter.filter(calendar, buffer);
    StringReader sr = new StringReader(buffer.toString());
    
    Calendar filterCal = cb.build(sr);
    
    Assert.assertEquals(2, filterCal.getComponents().getComponents("VEVENT").size());
    // Make sure 2nd override is dropped
    ComponentList<VEvent> vevents = filterCal.getComponents().getComponents(VEvent.VEVENT);        
    for(VEvent c : vevents) {            
        Assert.assertNotSame("event 6 changed 2",c.getProperties().getProperty("SUMMARY").getValue());
    }   
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:38,代码来源:LimitRecurrenceSetTest.java

示例9: getCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Gets calendar.
 * @param name The name.
 * @return The calendar.
 * @throws Exception - if something is wrong this exception is thrown.
 */
protected Calendar getCalendar(String name) throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    InputStream in = getClass().getClassLoader().getResourceAsStream("testdata/expander/" + name);
    if (in == null) {
        throw new IllegalStateException("resource " + name + " not found");
    }        
    Calendar calendar = cb.build(in);
    return calendar;
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:16,代码来源:RecurrenceExpanderTest.java

示例10: getCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Gets calendar.
 *
 * @param name The name.
 * @return The calendar.
 * @throws Exception - if something is wrong this exception is thrown.
 */
protected Calendar getCalendar(String name) throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    InputStream in = getClass().getClassLoader().getResourceAsStream("testdata/instancelist/" + name);
    if (in == null) {
        throw new IllegalStateException("resource " + name + " not found");
    }
    Calendar calendar = cb.build(in);
    return calendar;
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:17,代码来源:InstanceListTest.java

示例11: parseCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Parse icalendar string into Calendar object.
 * @param calendar icalendar string
 * @return Calendar object
 * @throws ParserException - if something is wrong this exception is thrown.
 * @throws IOException - if something is wrong this exception is thrown.
 */
public static Calendar parseCalendar(String calendar) throws ParserException, IOException {
    if (calendar == null) {
        return null;
    }
    CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
    clearTZRegistry(builder);
    
    StringReader sr = new StringReader(calendar);
    return builder.build(sr);
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:18,代码来源:CalendarUtils.java

示例12: getCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Gets calendar.
 * @param name The name.
 * @return The calendar.
 * @throws Exception - if something is wrong this exception is thrown.
 */
protected Calendar getCalendar(String name) throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    InputStream in = getClass().getClassLoader().getResourceAsStream("expander/" + name);
    if (in == null) {
        throw new IllegalStateException("resource " + name + " not found");
    }        
    Calendar calendar = cb.build(in);
    return calendar;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:16,代码来源:RecurrenceExpanderTest.java

示例13: testLimitRecurrenceSet

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Tests limit recurrence set.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testLimitRecurrenceSet() throws Exception {
    CalendarBuilder cb = new CalendarBuilder();
    FileInputStream fis = new FileInputStream(baseDir + "limit_recurr_test.ics");
    Calendar calendar = cb.build(fis);
    
    Assert.assertEquals(5, calendar.getComponents().getComponents("VEVENT").size());
    
    VTimeZone vtz = (VTimeZone) calendar.getComponents().getComponent("VTIMEZONE");
    TimeZone tz = new TimeZone(vtz);
    OutputFilter filter = new OutputFilter("test");
    DateTime start = new DateTime("20060104T010000", tz);
    DateTime end = new DateTime("20060106T010000", tz);
    start.setUtc(true);
    end.setUtc(true);
    
    Period period = new Period(start, end);
    filter.setLimit(period);
    filter.setAllSubComponents();
    filter.setAllProperties();
    
    StringBuffer buffer = new StringBuffer();
    filter.filter(calendar, buffer);
    StringReader sr = new StringReader(buffer.toString());
    
    Calendar filterCal = cb.build(sr);
    
    ComponentList<CalendarComponent> comps = filterCal.getComponents();
    Assert.assertEquals(3, comps.getComponents("VEVENT").size());
    Assert.assertEquals(1, comps.getComponents("VTIMEZONE").size());
    
    // Make sure 3rd and 4th override are dropped

    ComponentList<CalendarComponent> events = comps.getComponents("VEVENT");
    for(CalendarComponent c : events) {            
        Assert.assertNotSame("event 6 changed 3",c.getProperties().getProperty("SUMMARY").getValue());
        Assert.assertNotSame("event 6 changed 4",c.getProperties().getProperty("SUMMARY").getValue());
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:44,代码来源:LimitRecurrenceSetTest.java

示例14: makeCalendar

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
protected static Calendar makeCalendar(GenericValue workEffort, Map<String, Object> context) throws GenericEntityException {
    String iCalData = null;
    GenericValue iCalValue = workEffort.getRelatedOne("WorkEffortIcalData", false);
    if (iCalValue != null) {
        iCalData = iCalValue.getString("icalData");
    }
    boolean newCalendar = true;
    Calendar calendar = null;
    if (iCalData == null) {
        Debug.logVerbose("iCalendar Data not found, creating new Calendar", module);
        calendar = new Calendar();
    } else {
        Debug.logVerbose("iCalendar Data found, using saved Calendar", module);
        StringReader reader = new StringReader(iCalData);
        CalendarBuilder builder = new CalendarBuilder();
        try {
            calendar = builder.build(reader);
            newCalendar = false;
        } catch (Exception e) {
            Debug.logError(e, "Error while parsing saved iCalendar, creating new iCalendar: ", module);
            calendar = new Calendar();
        }
    }
    PropertyList propList = calendar.getProperties();
    replaceProperty(propList, prodId);
    replaceProperty(propList, new XProperty(workEffortIdXPropName, workEffort.getString("workEffortId")));
    if (newCalendar) {
        propList.add(Version.VERSION_2_0);
        propList.add(CalScale.GREGORIAN);
        // TODO: Get time zone from publish properties value
        java.util.TimeZone tz = java.util.TimeZone.getDefault();
        TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
        net.fortuna.ical4j.model.TimeZone timezone = registry.getTimeZone(tz.getID());
        calendar.getComponents().add(timezone.getVTimeZone());
    }
    return calendar;
}
 
开发者ID:jamesyong,项目名称:o3erp,代码行数:38,代码来源:ICalConverter.java

示例15: load

import net.fortuna.ical4j.data.CalendarBuilder; //导入方法依赖的package包/类
/**
 * Load the calendar events from the given reader.
 *
 * @param calendar
 *            the target {@link ICalendar}
 * @param reader
 *            the input source reader
 * @throws IOException
 * @throws ParserException
 */
@Transactional
public void load(ICalendar calendar, Reader reader) throws IOException, ParserException {
	Preconditions.checkNotNull(calendar, "calendar can't be null");
	Preconditions.checkNotNull(reader, "reader can't be null");

	final CalendarBuilder builder = new CalendarBuilder();
	final Calendar cal = builder.build(reader);

	if (calendar.getName() == null && cal.getProperty(X_WR_CALNAME) != null) {
		calendar.setName(cal.getProperty(X_WR_CALNAME).getValue());
	}

	for (Object item : cal.getComponents(Component.VEVENT)) {
		findOrCreateEvent((VEvent) item, calendar);
	}
}
 
开发者ID:axelor,项目名称:axelor-business-suite,代码行数:27,代码来源:ICalendarService.java


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