public void setData(byte[] data) throws IOException, ParserException { CalendarBuilder builder = new CalendarBuilder(); calendar = builder.build(new ByteArrayInputStream(data)); this.data = data.clone(); }
/** * Return the CalendarBuilder instance. * @return CalendarBuilder */ private CalendarBuilder getCalendarBuilderInstance(){ CalendarBuilder builder = calendarBuilderThreadLocal.get(); if (builder == null){ builder = new CalendarBuilder(); calendarBuilderThreadLocal.set(builder); } return builder; }
/** * Loads a calendar from the specified URL. * @param url the URL from which to load calendar data * @return returns a new calendar instance initialised from the specified URL * @throws IOException occurs when there is an error reading from the specified URL * @throws ParserException occurs when the data in the specified URL is invalid */ public static Calendar load(final URL url) throws IOException, ParserException { final CalendarBuilder builder = new CalendarBuilder(); return builder.build(url.openStream()); }
/** * Loads a calendar from the specified URL. * @param url the URL from which to load calendar data * @return returns a new calendar instance initialised from the specified URL * @throws IOException occurs when there is an error reading from the specified URL * @throws ParserException occurs when the data in the specified URL is invalid */ public static Calendar load(final URL url) throws IOException, ParserException { final CalendarBuilder builder = new CalendarBuilder(); return builder.build(url.openStream()); }
/** * Loads a calendar from the specified file. * @param filename the name of the file from which to load calendar data * @return returns a new calendar instance initialised from the specified file * @throws IOException occurs when there is an error reading the specified file * @throws ParserException occurs when the data in the specified file is invalid */ public static Calendar load(final String filename) throws IOException, ParserException { return new CalendarBuilder().build(Files.newInputStream(Paths.get(filename))); }
/** * Loads a calendar from the specified URL. * @param url the URL from which to load calendar data * @return returns a new calendar instance initialised from the specified URL * @throws IOException occurs when there is an error reading from the specified URL * @throws ParserException occurs when the data in the specified URL is invalid */ public static Calendar load(final URL url) throws IOException, ParserException { final CalendarBuilder builder = new CalendarBuilder(); return builder.build(url.openStream()); }
/** * Loads a calendar from the specified file. * @param filename the name of the file from which to load calendar data * @return returns a new calendar instance initialised from the specified file * @throws IOException occurs when there is an error reading the specified file * @throws ParserException occurs when the data in the specified file is invalid */ public static Calendar load(final String filename) throws IOException, ParserException { return new CalendarBuilder().build(Files.newInputStream(Paths.get(filename))); }
/** * Loads a calendar from the specified file. * @param filename the name of the file from which to load calendar data * @return returns a new calendar instance initialised from the specified file * @throws IOException occurs when there is an error reading the specified file * @throws ParserException occurs when the data in the specified file is invalid */ public static Calendar load(final String filename) throws IOException, ParserException { final FileInputStream fin = new FileInputStream(filename); final CalendarBuilder builder = new CalendarBuilder(); return builder.build(fin); }
/** * Loads a calendar from the specified URL. * @param url the URL from which to load calendar data * @return returns a new calendar instance initialised from the specified URL * @throws IOException occurs when there is an error reading from the specified URL * @throws ParserException occurs when the data in the specified URL is invalid */ public static Calendar load(final URL url) throws IOException, ParserException { final CalendarBuilder builder = new CalendarBuilder(); return builder.build(url.openStream()); }
/** * Loads a calendar from the specified URL. * @param url the URL from which to load calendar data * @return returns a new calendar instance initialised from the specified URL * @throws IOException occurs when there is an error reading from the specified URL * @throws ParserException occurs when the data in the specified URL is invalid */ public static Calendar load(final URL url) throws IOException, ParserException { final CalendarBuilder builder = new CalendarBuilder(); return builder.build(url.openStream()); }
/** * Loads a calendar from the specified file. * @param filename the name of the file from which to load calendar data * @return returns a new calendar instance initialised from the specified file * @throws IOException occurs when there is an error reading the specified file * @throws ParserException occurs when the data in the specified file is invalid */ public static Calendar load(final String filename) throws IOException, ParserException { final FileInputStream fin = new FileInputStream(filename); final CalendarBuilder builder = new CalendarBuilder(); return builder.build(fin); }
/** * Loads a calendar from the specified file. * @param filename the name of the file from which to load calendar data * @return returns a new calendar instance initialised from the specified file * @throws IOException occurs when there is an error reading the specified file * @throws ParserException occurs when the data in the specified file is invalid */ public static Calendar load(final String filename) throws IOException, ParserException { final FileInputStream fin = new FileInputStream(filename); final CalendarBuilder builder = new CalendarBuilder(); return builder.build(fin); }
public Calendar deepCopyNotNull(Calendar value) { String representation; try { representation = value.toString(); return new CalendarBuilder().build(new StringReader(representation)); } catch (IOException e) { throw new CosmoIOException(e); } catch (ParserException e) { throw new CosmoParseException(e); } } }
private Calendar buildCalendar(String file) throws IOException, ParserException { InputStream is = getClass().getResourceAsStream(file); CalendarBuilder cb = new CalendarBuilder(); Calendar calendar = cb.build(is); is.close(); return calendar; } }
public Calendar deepCopyNotNull(Calendar value) { String representation; try { representation = value.toString(); return new CalendarBuilder().build(new StringReader(representation)); } catch (IOException e) { throw new CosmoIOException(e); } catch (ParserException e) { throw new CosmoParseException(e); } } }
protected void setUp() throws Exception { CalendarBuilder builder = new CalendarBuilder(); calendar = builder.build(getClass().getResourceAsStream("/samples/valid/Australian_TV_Melbourne.ics")); }
protected void setUp() throws Exception { CompatibilityHints.setHintEnabled( CompatibilityHints.KEY_RELAXED_UNFOLDING, true); CalendarBuilder builder = new CalendarBuilder(); calendar = builder.build(getClass().getResourceAsStream("/samples/valid/incoming.ics")); }
@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(); } } });
/** * Ensure timezones are correctly parsed for this property. * @throws Exception */ public void testTimeZones() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE.ics")); Component event = calendar.getComponent(Component.VEVENT); List<ExDate> exdates = event.getProperties(Property.EXDATE); for (ExDate exDate : exdates) { assertNotNull("This EXDATE should have a timezone", exDate.getDates().getTimeZone()); } }
/** * 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()); }