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


Java CalendarComponent类代码示例

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


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

示例1: parseCalendartoAppointments

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * Parses a Calendar with multiple VEvents into Appointments
 *
 * @param calendar Calendar to Parse
 * @param ownerId  Owner of the Appointments
 * @return <code>List</code> of Appointments
 */
public List<Appointment> parseCalendartoAppointments(Calendar calendar, Long ownerId) {
	List<Appointment> appointments = new ArrayList<>();
	ComponentList<CalendarComponent> events = calendar.getComponents(Component.VEVENT);
	User owner = userDao.get(ownerId);

	for (CalendarComponent event : events) {
		Appointment a = new Appointment();
		a.setOwner(owner);
		a.setDeleted(false);
		a.setRoom(createDefaultRoom());
		a.setReminder(Appointment.Reminder.none);
		a = addVEventPropertiestoAppointment(a, event);
		appointments.add(a);
	}
	return appointments;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:24,代码来源:IcalUtils.java

示例2: hasMultipleComponentTypes

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的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

示例3: checkMoment

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
public boolean checkMoment(Date date) {
    if (calendar != null) {
        Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
        Predicate<CalendarComponent> periodRule = new PeriodRule<>(period);
        Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY);
        Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT));
        if (events != null && !events.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:13,代码来源:Calendar.java

示例4: iCalEventNameTest

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
@Test
public void iCalEventNameTest() {
	ComponentList<CalendarComponent> iCalComponents = iCal.getComponents();
	
	// Not testing the count
	if(iCalComponents.size() == 0)
		return;
	
	// Get all the events (recurring + nonrecurring)
	Vector<Event> allEvents = new Vector<Event>();
	allEvents.addAll(EventsManager.getRecurringEvents());
	allEvents.addAll(EventsManager.getNonrecurringEvents());
	
	// Iterate through each iCal VEvent and check if it has a corresponding Memoranda Event
	for(int i = 0; i < iCalComponents.size(); i++) {
		boolean found = false;
		String name = iCalComponents.get(i).getProperties().getProperty(Property.SUMMARY).getValue();
		
		for(int j = 0; j < allEvents.size(); j++) {
			if(allEvents.get(j).getText().equals(name)) {
				found = true;
				break;
			}
		}
		
		// Fail if it's not found
		assertTrue(found);
	}
}
 
开发者ID:cst316,项目名称:spring16project-Modula-2,代码行数:30,代码来源:ICalExportTest.java

示例5: parseCalendartoAppointment

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * Updating Appointments which already exist, by parsing the Calendar. And updating etag.
 * Doesn't work with complex Recurrences.
 * Note: Hasn't been tested to acknowledge DST, timezones should acknowledge this.
 *
 * @param a        Appointment to be updated.
 * @param calendar iCalendar Representation.
 * @param etag     The ETag of the calendar.
 * @return Updated Appointment.
 */
public Appointment parseCalendartoAppointment(Appointment a, Calendar calendar, String etag) {
	if (calendar == null) {
		return a;
	}
	CalendarComponent event = calendar.getComponent(Component.VEVENT);
	if (event != null) {
		a.setEtag(etag);
		a = addVEventPropertiestoAppointment(a, event);
	}
	return a;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:22,代码来源:IcalUtils.java

示例6: componentToUTC

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * @param comp The component.
 */
private void componentToUTC(Component comp) {
    // Do to each top-level property
    for (Property prop : (List<Property>) comp.getProperties()) {
        if (prop instanceof DateProperty) {
            DateProperty dprop = (DateProperty) prop;
            Date date = dprop.getDate();
            if (date instanceof DateTime &&
                (((DateTime) date).getTimeZone() != null)) {
                dprop.setUtc(true);
            }
        }
    }

    // Do to each embedded component
    ComponentList<? extends CalendarComponent> subcomps = null;
    if (comp instanceof VEvent) {
        subcomps = ((VEvent) comp).getAlarms() ;
    }
    else if (comp instanceof VToDo) {
        subcomps = ((VToDo)comp).getAlarms();
    }

    if (subcomps != null) {
        for (CalendarComponent subcomp :  subcomps) {
            componentToUTC(subcomp);
        }
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:32,代码来源:OutputFilter.java

示例7: hasSupportedComponent

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
public static boolean hasSupportedComponent(Calendar calendar) {
    for (Object component: calendar.getComponents()) {
        if (isSupportedComponent(((CalendarComponent)component).getName())) {
             return true;
        }
     }
     return false;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:9,代码来源:CalendarUtils.java

示例8: getFreeBusyCalendar

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * Obfuscates the specified calendar by removing unnecessary properties and replacing text fields with specified
 * text.
 * 
 * @param original
 *            calendar to be obfuscated
 * @param productId
 *            productId to be set for the copy calendar.
 * @param freeBusyText
 * @return obfuscated calendar.
 */
public static Calendar getFreeBusyCalendar(Calendar original, String productId, String freeBusyText) {
    // Make a copy of the original calendar
    Calendar copy = new Calendar();
    copy.getProperties().add(new ProdId(productId));
    copy.getProperties().add(Version.VERSION_2_0);
    copy.getProperties().add(CalScale.GREGORIAN);
    copy.getProperties().add(new XProperty(FREE_BUSY_X_PROPERTY, Boolean.TRUE.toString()));

    ComponentList<CalendarComponent> events = original.getComponents(Component.VEVENT);
    for (Component event : events) {
        copy.getComponents().add(getFreeBusyEvent((VEvent) event, freeBusyText));
    }
    return copy;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:26,代码来源:FreeBusyUtil.java

示例9: testLimitRecurrenceSet

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的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

示例10: parseFile

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
private static ArrayList<VEvent> parseFile(String iCalFile, DataSource dataSource) {
    Log.d(TAG, "Initial");
    ArrayList<VEvent> vEvents = new ArrayList<>();
    StringReader stringReader = new StringReader(iCalFile);
    CalendarBuilder calendarBuilder = new CalendarBuilder();
    Calendar calendar = null;
    Log.d(TAG, "Readers done");
    StopWatch stopWatch = new StopWatch();

    stopWatch.start();
    try {
        CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
        calendar = calendarBuilder.build(stringReader);
    } catch (IOException | ParserException e) {
        FirebaseCrash.report(e);
        Log.e(TAG, "Failed to parse calendar for " + dataSource + "!!!", e);
    }
    stopWatch.stop();

    Log.d(TAG, "Calendar build time: " + stopWatch.getTime() + "ms");
    Log.v(TAG, Runtime.getRuntime().availableProcessors() + " possible simultaneous tasks with " + Runtime.getRuntime().maxMemory() + " bytes of memory max and " + Runtime.getRuntime().freeMemory() + " bytes of memory free");

    if (calendar != null) {
        Log.i(TAG, "VTIMEZONEs of " + dataSource + ": " + calendar.getComponents(CalendarComponent.VTIMEZONE));
        //VTimeZone vTimeZone = (VTimeZone) calendar.getComponent(CalendarComponent.VTIMEZONE);
        //final TimeZone timeZone = new TimeZone(vTimeZone);
        //Log.i(TAG, "parseFile: " + vTimeZone);
        vEvents = Stream.of(calendar.getComponents())
                .filter(value -> value instanceof VEvent)
                .map(value -> (VEvent) value)
                .collect(Collectors.toCollection(ArrayList::new));
    }

    return vEvents;
}
 
开发者ID:Pattonville-App-Development-Team,项目名称:Android-App,代码行数:36,代码来源:RetrieveCalendarDataAsyncTask.java

示例11: setCustomResourceForDates

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private void setCustomResourceForDates() {

    final Handler dataHandler = new Handler();
    (new Thread(new Runnable() {
        @Override
        public void run() {

            try {

                InputStream icsInput = getAssets().open("ASECalendar.ics");
                CalendarBuilder builder = new CalendarBuilder();
                net.fortuna.ical4j.model.Calendar calendar = builder.build(icsInput);

                for (Object calendarComponentObject : calendar.getComponents()) {
                    CalendarComponent calendarComponent = (CalendarComponent) calendarComponentObject;
                    String title = calendarComponent.getProperty(Property.SUMMARY).getValue();
                    if (title.length() > 4) {
                        Date startDate = parseDate(calendarComponent.getProperty(Property.DTSTART).getValue());
                        Date endDate = parseDate(calendarComponent.getProperty(Property.DTEND).getValue());
                        title = title.replaceAll("^CD\\d\\d:\\s", "").replaceAll("^CD\\d:\\s", "").replace("*", "");

                        int color = R.color.calendar_green;

                        if (containsAny(title, new String[]{"assessment", "exam", "test", "assesment", "end semester"})) {
                            color = R.color.calendar_red;
                        } else if (containsAny(title, new String[]{"institution day", "amritotsavam", "amritotasavam", "classes", "working", "instruction", "enrolment", "Birthday", "Talent", "TABLE", "orientation", "counselling"})) {
                            color = R.color.calendar_blue;
                        } else if (containsAny(title, new String[]{"anokha", "tech fest"})) {
                            color = R.color.calendar_anokha_orange;
                        }

                        Calendar start = Calendar.getInstance();
                        start.setTime(startDate);
                        Calendar end = Calendar.getInstance();
                        end.setTime(endDate);

                        //noinspection WrongConstant
                        if (start.get(Calendar.DAY_OF_MONTH) == end.get(Calendar.DAY_OF_MONTH) || end.get(Calendar.DAY_OF_MONTH) == start.get(Calendar.DAY_OF_MONTH) + 1) {
                            backgroundColors.put(startDate, color);
                            textColors.put(startDate, R.color.white);
                            descriptions.put(formatter.format(startDate), title);
                        } else {
                            for (Date date = start.getTime(); start.before(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
                                backgroundColors.put(date, color);
                                textColors.put(date, R.color.white);
                                descriptions.put(formatter.format(date), title);
                            }
                        }
                    }
                }

            } catch (Exception e) {
                FirebaseCrash.report(e);
            }

            dataHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (caldroidFragment != null) {
                        caldroidFragment.setBackgroundResourceForDates(backgroundColors);
                        caldroidFragment.setTextColorForDates(textColors);
                        caldroidFragment.refreshView();
                        findViewById(R.id.calendar_holder).setVisibility(View.VISIBLE);
                        findViewById(R.id.progress).setVisibility(View.GONE);
                    }
                }
            });
        }
    })).start();
}
 
开发者ID:niranjan94,项目名称:amrita-info-desk,代码行数:72,代码来源:Calender.java

示例12: getCalendarEvents

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
private ArrayList<CalendarEvent> getCalendarEvents() {
    ArrayList<CalendarEvent> calendarEvents = new ArrayList<>();
    CacheManager cacheManager = CacheManager.getInstance();
    Cache cache = cacheManager.getCache("calendar");

    //Return data from the cache, if available
    Element element = cache.get("calendar");
    if (element != null) {
        return (ArrayList<CalendarEvent>) element.getObjectValue();
    }

    InputStream stream;

    //Download and parse .ics and refresh the cache
    try {

        OkHttpClient client = new OkHttpClient();

        Request request = new Request.Builder()
                .url(CALENDAR_URL)
                .get()
                .build();

        Response response = client.newCall(request).execute();

        String redirect = response.header("Location");
        if (redirect != null) {
            request = new Request.Builder()
                    .url(redirect)
                    .get()
                    .build();
            response = client.newCall(request).execute();
        }

        stream = response.body().byteStream();

        CalendarBuilder builder = new CalendarBuilder();
        Calendar calendar = builder.build(stream);


        SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd");

        for (CalendarComponent calendarComponent : calendar.getComponents()) {
            Date dtstart = dateParser.parse(calendarComponent.getProperty("DTSTART").getValue());
            String uid = calendarComponent.getProperty("UID").getValue();
            Date dtend = dateParser.parse(calendarComponent.getProperty("DTEND").getValue());
            String summary = calendarComponent.getProperty("SUMMARY").getValue();

            calendarEvents.add(new CalendarEvent(dtstart, uid, dtend, summary));
        }

        cache.put(new Element("calendar", calendarEvents));

    } catch (ParserException | IOException | ParseException e) {
        e.printStackTrace();
    }

    return calendarEvents;
}
 
开发者ID:ApplETS,项目名称:applets-java-api,代码行数:60,代码来源:CalendarResource.java

示例13: createBaseCalendar

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * Create a base Calendar containing a single component.
 * @param comp Component to add to the base Calendar
 * @return base Calendar
 */
public static Calendar createBaseCalendar(CalendarComponent comp) {
    Calendar cal = createBaseCalendar(); 
    cal.getComponents().add(comp);
    return cal;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:11,代码来源:ICalendarUtils.java

示例14: splitCalendar

import net.fortuna.ical4j.model.component.CalendarComponent; //导入依赖的package包/类
/**
 * Given a calendar with many different components, split into
 * separate calendars that contain only a single component type
 * and a single UID.
 * @param calendar The calendar.
 * @return The split calendar.
 */
private CalendarContext[] splitCalendar(Calendar calendar) {
    Vector<CalendarContext> contexts = new Vector<CalendarContext>();
    Set<String> allComponents = new HashSet<String>();
    Map<String, ComponentList<CalendarComponent>> componentMap = new HashMap<>();
    
    ComponentList<CalendarComponent> comps = calendar.getComponents();
    for(CalendarComponent comp : comps) {            
        // ignore vtimezones for now
        if(comp instanceof VTimeZone) {
            continue;
        }
        
        Uid uid = (Uid) comp.getProperty(Property.UID);
        RecurrenceId rid = (RecurrenceId) comp.getProperty(Property.RECURRENCE_ID);
        
        String key = uid.getValue();
        if(rid!=null) {
            key+=rid.toString();
        }
        
        // ignore duplicates
        if(allComponents.contains(key)) {
            continue;
        }
        
        allComponents.add(key);
        
        ComponentList<CalendarComponent> cl = componentMap.get(uid.getValue());
        
        if(cl==null) {
            cl = new ComponentList<>();
            componentMap.put(uid.getValue(), cl);
        }
        
        cl.add(comp);
    }
    
    for(Entry<String, ComponentList<CalendarComponent>> entry : componentMap.entrySet()) {
       
        Component firstComp = (Component) entry.getValue().get(0);
        
        Calendar cal = ICalendarUtils.createBaseCalendar();
        cal.getComponents().addAll(entry.getValue());
        addTimezones(cal);
        
        CalendarContext cc = new CalendarContext();
        cc.calendar = cal;
        cc.type = firstComp.getName();
        
        contexts.add(cc);
    }
    
    return contexts.toArray(new CalendarContext[contexts.size()]);
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:62,代码来源:EntityConverter.java


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