/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList<?> components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
/** * @param componentName a component name used in the assertion * @param components a list of components * @throws ValidationException where the assertion fails */ public static void assertOneOrLess(String componentName, ComponentList components) throws ValidationException { if (components.getComponents(componentName).size() > 1) { throw new ValidationException(ASSERT_ONE_OR_LESS_MESSAGE, new Object[] {componentName}); } } }
public void run() { if (mCalendar == null) { mInsertDeleteLayout.setVisibility(View.GONE); return; } Resources res = getResources(); final int n = mCalendar.getComponents(VEvent.VEVENT).size(); mInsertButton.setText(get(res, R.plurals.insert_n_entries, n)); mDeleteButton.setText(get(res, R.plurals.delete_n_entries, n)); mInsertDeleteLayout.setVisibility(View.VISIBLE); mScrollViewMain.post(new Runnable() { @Override public void run() { mScrollViewMain.fullScroll(ScrollView.FOCUS_DOWN); } }); } private String get(Resources res, int id, int n) {
@Override public void run() { try { Calendar cal = new Calendar(calendar); size.addAndGet(cal.getComponents().size()); } catch (IOException | ParseException | URISyntaxException e) { e.printStackTrace(); } } });
if (comps == null || comps.size() == 0) { LOG.warn("error validating freebusy: " + calendar.toString()); return false;
if (comps == null || comps.size() == 0) { LOG.warn("error validating task: " + calendar.toString()); return false;
if (comps == null || comps.size() == 0) { LOG.warn("error validating task: " + calendar.toString()); return false;
if (comps == null || comps.size() == 0) { LOG.warn("error validating freebusy: " + calendar.toString()); return false;
/** * Indexing with IndexedComponentList. */ public void testIndexing() { long start = System.currentTimeMillis(); IndexedComponentList<CalendarComponent> list = new IndexedComponentList<CalendarComponent>(calendar.getComponents(), Property.LOCATION); LOG.info(list.getComponents("ABC").size() + " programs on ABC." + " (" + (System.currentTimeMillis() - start) + "ms)"); }
/** * 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; } }
/** * 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; } }
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); }
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); }
@Override public void run() { FileInputStream fis = null; try { fis = new FileInputStream("src/test/resources/samples/valid/lotr.ics"); Calendar calendar = new CalendarBuilder().build(fis); size.addAndGet(calendar.getComponents().size()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { try { fis.close(); } catch (IOException e) { //ignore } } } });
@Override public void run() { try(FileInputStream fis = new FileInputStream("src/test/resources/samples/valid/lotr.ics");) { Calendar calendar = new CalendarBuilder().build(fis); Calendar cal = new Calendar(calendar); size.addAndGet(cal.getComponents().size()); } catch (IOException | ParserException | URISyntaxException | ParseException e) { e.printStackTrace(); } } });
/** * Test method for {@link net.fortuna.ical4j.data.HCalendarParser#parse(java.io.Reader, net.fortuna.ical4j.data.ContentHandler)}. */ public void testParseReaderContentHandler() throws IOException, ParserException { Calendar icsCalendar = Calendars.load(getClass().getResource("/samples/hcalendar/example1.ics")); // remove prod-id which seems to be not handled by hcalendar.. icsCalendar.getProperties().remove(icsCalendar.getProperty(Property.PRODID)); CalendarBuilder builder = new CalendarBuilder(new HCalendarParser()); Calendar hcalCalendar = builder.build(getClass().getResourceAsStream("/samples/hcalendar/example1.html")); // assertEquals(icsCalendar, hcalCalendar); assertEquals(icsCalendar.getProperties().size(), hcalCalendar.getProperties().size()); assertEquals(icsCalendar.getComponents().size(), hcalCalendar.getComponents().size()); }
assertNotNull("Calendar is null", calendar); ComponentList<CalendarComponent> comps = calendar.getComponents(Component.VEVENT); assertTrue("VEVENT not found", comps.size() == 1); VEvent vevent = (VEvent) comps.get(0);