/** * {@inheritDoc} */ public final boolean equals(final Object arg0) { if (arg0 instanceof Calendar) { final Calendar calendar = (Calendar) arg0; return new EqualsBuilder().append(getProperties(), calendar.getProperties()) .append(getComponents(), calendar.getComponents()).isEquals(); } return super.equals(arg0); }
/** * {@inheritDoc} */ @Override public void startCalendar() { calendar = new Calendar(); }
private VFreeBusy freeBusy(net.fortuna.ical4j.model.Calendar cal) { return (VFreeBusy) cal.getComponent("VFREEBUSY"); }
@Before public void setUp() { calendar = new Calendar(); calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN")); calendar.getProperties().add(Version.VERSION_2_0); calendar.getProperties().add(CalScale.GREGORIAN); VEvent vEvent = new VEvent(); vEvent.getProperties().add(new Uid("1")); calendar.getComponents().add(vEvent); }
/** * */ public void testCreateDefinition() { Calendar calendar = new Calendar(); calendar.getComponents().add(tz); log.info(calendar.toString()); }
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; }
@Override public void run() { try { Calendar cal = new Calendar(calendar); size.addAndGet(cal.getComponents().size()); } catch (IOException | ParseException | URISyntaxException e) { e.printStackTrace(); } } });
/** * Create a base Calendar containing no components. * @return base Calendar */ public static Calendar createBaseCalendar() { Calendar cal = new Calendar(); cal.getProperties().add(new ProdId(CosmoConstants.PRODUCT_ID)); cal.getProperties().add(Version.VERSION_2_0); cal.getProperties().add(CalScale.GREGORIAN); return cal; }
@Override public Calendar transform(Calendar object) { if (!Method.COUNTER.equals(object.getMethod())) { throw new IllegalArgumentException("Expecting COUNTER method in source"); } for (CalendarComponent component : object.getComponents()) { organizerUpdate.transform(component); } return super.transform(object); } }
/** * Convenience method for retrieving a named property. * @param name name of the property to retrieve * @return the first matching property in the property list with the specified name */ public final <T extends Property> T getProperty(final String name) { return getProperties().getProperty(name); }
/** * Retrieving Data as String */ public String getICalDataAsString() { return icsCalendar.toString(); } }
/** * Perform validation on the calendar, its properties and its components in its current state. * @throws ValidationException where the calendar is not in a valid state */ public final void validate() throws ValidationException { validate(true); }
/** * Returns the mandatory prodid property. * @return the PRODID property, or null if property doesn't exist */ public final ProdId getProductId() { return getProperty(Property.PRODID); }
/** * Outputs an iCalender string to the specified writer. * @param calendar calendar to write to writer * @param out a writer * @throws IOException thrown when unable to write to writer * @throws ValidationException where calendar validation fails */ public final void output(final Calendar calendar, final Writer out) throws IOException, ValidationException { if (isValidating()) { calendar.validate(); } try (FoldingWriter writer = new FoldingWriter(out, foldLength)) { writer.write(calendar.toString()); } } }
public void testVAvailability() throws ParserException, IOException { CalendarBuilder calendarBuilder = new CalendarBuilder(); String availability = getVAvailabilityICal(); Reader reader = new StringReader(availability); Calendar calendar = calendarBuilder.build(reader); Component availabilityComponent = calendar.getComponent(Component.VAVAILABILITY); Assert.assertNotNull(availabilityComponent); Assert.assertFalse(((VAvailability) availabilityComponent).getAvailable().isEmpty()); String iCalString = calendar.toString(); Assert.assertTrue(iCalString.contains("BEGIN:AVAILABLE")); Assert.assertEquals(iCalString.trim(), availability); }
public Builder from(Calendar calendar, byte[] originalEvent) { this.ical = new String(originalEvent, StandardCharsets.UTF_8); VEvent vevent = (VEvent) calendar.getComponent("VEVENT"); this.uid = optionalOf(vevent.getUid()); this.method = optionalOf(calendar.getMethod()); this.recurrenceId = optionalOf(vevent.getRecurrenceId()); this.sequence = optionalOf(vevent.getSequence()); this.dtstamp = optionalOf(vevent.getDateStamp()); return this; }
@Override public Calendar transform(Calendar object) { if (!Method.REQUEST.equals(object.getMethod())) { throw new IllegalArgumentException("Expecting REQUEST method in source"); } return super.transform(object); } }
/** * Convenience method for retrieving a named component. * @param name name of the component to retrieve * @return the first matching component in the component list with the specified name */ public final CalendarComponent getComponent(final String name) { return getComponents().getComponent(name); }
@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(); } } });
@Override public Calendar transform(Calendar object) { if (!Method.COUNTER.equals(object.getMethod())) { throw new IllegalArgumentException("Expecting COUNTER method in source"); } for (CalendarComponent component : object.getComponents()) { organizerUpdate.transform(component); } return super.transform(object); } }