Java Code Examples for net.fortuna.ical4j.model.ComponentList#size()

The following examples show how to use net.fortuna.ical4j.model.ComponentList#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ICalendarUtils.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/**
 * Find and return the first DISPLAY VALARM in a comoponent
 * @param component VEVENT or VTODO
 * @return first DISPLAY VALARM, null if there is none
 */
public static VAlarm getDisplayAlarm(Component component) {
    ComponentList<VAlarm> alarms = null;
    
    if(component instanceof VEvent) {
        alarms = ((VEvent) component).getAlarms();
    }
    else if(component instanceof VToDo) {
        alarms = ((VToDo) component).getAlarms();
    }
    
    if(alarms==null || alarms.size()==0) {
        return null;
    }
    
    for(Iterator<VAlarm> it = alarms.iterator();it.hasNext();) {
        VAlarm alarm = it.next();
        if(Action.DISPLAY.equals(alarm.getAction())) {
            return alarm;
        }
    }
    
    return null;   
}
 
Example 2
Source File: HibEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public VEvent getMasterEvent() {
    if(getEventCalendar()==null) {
        return null;
    }
    
    ComponentList<VEvent> events = getEventCalendar().getComponents().getComponents(
            Component.VEVENT);
    
    if(events.size()==0) {
        return null;
    }
    
    return (VEvent) events.get(0);
}
 
Example 3
Source File: MockEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets master event.
 * @return The event.
 */
public VEvent getMasterEvent() {
    if (getEventCalendar() == null) {
        return null;
    }
    
    ComponentList<VEvent> events = getEventCalendar().getComponents().getComponents(
            Component.VEVENT);
    
    if (events.size() == 0) {
        return null;
    }
    
    return (VEvent) events.get(0);
}