/** * gets master component. * @param components The component list. * @return The component. */ private Component getMasterComponent(ComponentList<? extends Component> components) { Iterator<? extends Component> it = components.iterator(); while(it.hasNext()) { Component c = it.next(); if(c.getProperty(Property.RECURRENCE_ID)==null) { return c; } } throw new IllegalArgumentException("no master found"); }
/** * gets master component. * @param components The component list. * @return The component. */ private Component getMasterComponent(ComponentList<? extends Component> components) { Iterator<? extends Component> it = components.iterator(); while(it.hasNext()) { Component c = it.next(); if(c.getProperty(Property.RECURRENCE_ID)==null) { return c; } } throw new IllegalArgumentException("no master found"); }
@Override public int compare(Component o1, Component o2) { int retVal = 0; Sequence defaultSequence = new Sequence(0); Sequence sequence1 = Optional.ofNullable((Sequence) o1.getProperty(Property.SEQUENCE)).orElse(defaultSequence); Sequence sequence2 = Optional.ofNullable((Sequence) o2.getProperty(Property.SEQUENCE)).orElse(defaultSequence); retVal = sequence1.compareTo(sequence2); if (retVal == 0) { DtStamp defaultDtStamp = new DtStamp(new DateTime(0)); DtStamp dtStamp1 = Optional.ofNullable((DtStamp) o1.getProperty(Property.DTSTAMP)).orElse(defaultDtStamp); DtStamp dtStamp2 = Optional.ofNullable((DtStamp) o2.getProperty(Property.DTSTAMP)).orElse(defaultDtStamp); retVal = dtStamp1.compareTo(dtStamp2); } return retVal; } }
@Override public int compare(Component o1, Component o2) { int retVal = 0; Sequence defaultSequence = new Sequence(0); Sequence sequence1 = Optional.ofNullable((Sequence) o1.getProperty(Property.SEQUENCE)).orElse(defaultSequence); Sequence sequence2 = Optional.ofNullable((Sequence) o2.getProperty(Property.SEQUENCE)).orElse(defaultSequence); retVal = sequence1.compareTo(sequence2); if (retVal == 0) { DtStamp defaultDtStamp = new DtStamp(new DateTime(0)); DtStamp dtStamp1 = Optional.ofNullable((DtStamp) o1.getProperty(Property.DTSTAMP)).orElse(defaultDtStamp); DtStamp dtStamp2 = Optional.ofNullable((DtStamp) o2.getProperty(Property.DTSTAMP)).orElse(defaultDtStamp); retVal = dtStamp1.compareTo(dtStamp2); } return retVal; } }
private void checkDatesForComponent(Component component){ if(component == null){ return; } Property dtStart = component.getProperty(Property.DTSTART); Property dtEnd = component.getProperty(Property.DTEND); if( dtStart instanceof DtStart && dtStart.getValue()!= null && dtEnd instanceof DtEnd && dtEnd.getValue() != null && ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){ throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]"); } }
private void checkDatesForComponent(Component component){ if(component == null){ return; } Property dtStart = component.getProperty(Property.DTSTART); Property dtEnd = component.getProperty(Property.DTEND); if( dtStart instanceof DtStart && dtStart.getValue()!= null && dtEnd instanceof DtEnd && dtEnd.getValue() != null && ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){ throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]"); } }
private static final int getRawOffset(VTimeZone vt) { List seasonalTimes = vt.getObservances().getComponents(Observance.STANDARD); // if no standard time use daylight time.. if (seasonalTimes.size() == 0) { seasonalTimes = vt.getObservances().getComponents(Observance.DAYLIGHT); } if (seasonalTimes.size() > 0) { Collections.sort(seasonalTimes); final Component latestSeasonalTime = (Component) seasonalTimes.get(seasonalTimes.size() - 1); final TzOffsetTo offsetTo = (TzOffsetTo) latestSeasonalTime.getProperty(Property.TZOFFSETTO); if (offsetTo != null) { return (int) offsetTo.getOffset().getOffset(); } } return 0; } }
/** * Perform manual indexing. */ public void testManualIndexing() { long start = System.currentTimeMillis(); List<Component> list = new ArrayList<Component>(); for (Component c : calendar.getComponents()) { if (c.getProperty(Property.LOCATION) != null && "ABC".equals(c.getProperty(Property.LOCATION).getValue())) { list.add(c); } } LOG.info(list.size() + " programs on ABC." + " (" + (System.currentTimeMillis() - start) + "ms)"); } }
final Component comp = (Component)o; final PollItemId pid = (PollItemId)comp.getProperty(Property.POLL_ITEM_ID); if (pid == null) { continue;
/** * Test correct parsing of quoted text. * @throws IOException * @throws ParserException */ public void testQuotedText() throws IOException, ParserException { Calendar calendar = Calendars.load(getClass().getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); assertEquals("At \"The Terrace\" Complex > Melbourne \"\\,", event.getProperty(Property.LOCATION).getValue()); }
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); // Test correct parsing of text with tabs. Calendar calendar = Calendars.load(DescriptionTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); suite.addTest(new DescriptionTest(event .getProperty(Property.DESCRIPTION), "Test\t\ttabs")); return suite; } }
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); //testQuotedText.. Calendar calendar = Calendars.load(LocationTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); Location location = (Location) event.getProperty(Property.LOCATION); suite.addTest(new LocationTest(location, "At \"The Terrace\" Complex > Melbourne \"\\,")); return suite; } }
/** * <p> * Imports a calendar object containing a VAVAILABILITY. * @param cal The calendar imported. * @throws CosmoDavException - if something is wrong this exception is thrown. * </p> */ public void setCalendar(Calendar cal) throws CosmoDavException { AvailabilityItem availability = (AvailabilityItem) getItem(); availability.setAvailabilityCalendar(cal); Component comp = cal.getComponent(ICalendarConstants.COMPONENT_VAVAILABLITY); if (comp==null) { throw new UnprocessableEntityException("VCALENDAR does not contain a VAVAILABILITY"); } String val = null; Property prop = comp.getProperty(Property.UID); if (prop != null) { val = prop.getValue(); } if (StringUtils.isBlank(val)) { throw new UnprocessableEntityException("VAVAILABILITY does not contain a UID"); } availability.setIcalUid(val); }
/** * <p> * Imports a calendar object containing a VAVAILABILITY. * @param cal The calendar imported. * @throws CosmoDavException - if something is wrong this exception is thrown. * </p> */ public void setCalendar(Calendar cal) throws CosmoDavException { AvailabilityItem availability = (AvailabilityItem) getItem(); availability.setAvailabilityCalendar(cal); Component comp = cal.getComponent(ICalendarConstants.COMPONENT_VAVAILABLITY); if (comp==null) { throw new UnprocessableEntityException("VCALENDAR does not contain a VAVAILABILITY"); } String val = null; Property prop = comp.getProperty(Property.UID); if (prop != null) { val = prop.getValue(); } if (StringUtils.isBlank(val)) { throw new UnprocessableEntityException("VAVAILABILITY does not contain a UID"); } availability.setIcalUid(val); }
final Property p = comp.getProperty(Property.POLL_ITEM_ID);
final Property p = comp.getProperty(Property.VOTER);
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); // Test correct parsing of quoted text.. Calendar calendar = Calendars.load(SummaryTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); Summary summary = (Summary) event.getProperty(Property.SUMMARY); suite.addTest(new SummaryTest(summary, "A colon with spaces on either side : like that")); suite.addTest(new SummaryTest("testValidation", summary)); suite.addTest(new SummaryTest("testEquals", summary)); return suite; } }
if(comp.getProperty(Property.RECURRENCE_ID)==null) { instances.addComponent(comp, filter.getPeriod().getStart(), filter.getPeriod().getEnd());
if(comp.getProperty(Property.RECURRENCE_ID)==null) { master = (VToDo) comp;
if(comp.getProperty(Property.RECURRENCE_ID)==null) { instances.addComponent(comp, filter.getPeriod().getStart(), filter.getPeriod().getEnd());