public void setData(byte[] data) throws IOException, ParserException { CalendarBuilder builder = new CalendarBuilder(); calendar = builder.build(new ByteArrayInputStream(data)); this.data = data.clone(); }
/** * Builds an iCalendar model from the specified input stream. * @param in an input stream to read calendar data from * @return a calendar parsed from the specified input stream * @throws IOException where an error occurs reading data from the specified stream * @throws ParserException where an error occurs parsing data from the stream */ public Calendar build(final InputStream in) throws IOException, ParserException { return build(new InputStreamReader(in, DEFAULT_CHARSET)); }
/** * 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()); }
/** * Builds an iCalendar model from the specified reader. An <code>UnfoldingReader</code> is applied to the * specified reader to ensure the data stream is correctly unfolded where appropriate. * * @param in a reader to read calendar data from * @return a calendar parsed from the specified reader * @throws IOException where an error occurs reading data from the specified reader * @throws ParserException where an error occurs parsing data from the reader */ public Calendar build(final Reader in) throws IOException, ParserException { return build(new UnfoldingReader(in)); }
/** * Builds an iCalendar model from the specified reader. An <code>UnfoldingReader</code> is applied to the * specified reader to ensure the data stream is correctly unfolded where appropriate. * * @param in a reader to read calendar data from * @return a calendar parsed from the specified reader * @throws IOException where an error occurs reading data from the specified reader * @throws ParserException where an error occurs parsing data from the reader */ public Calendar build(final Reader in) throws IOException, ParserException { return build(new UnfoldingReader(in)); }
/** * Builds an iCalendar model from the specified reader. An <code>UnfoldingReader</code> is applied to the * specified reader to ensure the data stream is correctly unfolded where appropriate. * @param in a reader to read calendar data from * @return a calendar parsed from the specified reader * @throws IOException where an error occurs reading data from the specified reader * @throws ParserException where an error occurs parsing data from the reader */ public Calendar build(final Reader in) throws IOException, ParserException { return build(new UnfoldingReader(in)); }
/** * 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()); }
/** * Builds an iCalendar model from the specified reader. An <code>UnfoldingReader</code> is applied to the * specified reader to ensure the data stream is correctly unfolded where appropriate. * * @param in a reader to read calendar data from * @return a calendar parsed from the specified reader * @throws IOException where an error occurs reading data from the specified reader * @throws ParserException where an error occurs parsing data from the reader */ public Calendar build(final Reader in) throws IOException, ParserException { return build(new UnfoldingReader(in)); }
/** * 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))); }
/** * Parse icalendar data from InputStream * @param is icalendar data inputstream * @return Calendar object * @throws ParserException - if something is wrong this exception is thrown. * @throws IOException - if something is wrong this exception is thrown. */ public static Calendar parseCalendar(InputStream is) throws ParserException, IOException { CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder(); clearTZRegistry(builder); return builder.build(is); }
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); } } }
/** * @throws IOException * @throws ParserException * @throws ValidationException */ public void testBuildValid() throws IOException, ParserException, ValidationException { Calendar calendar = builder.build(fin); calendar.validate(); }
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()); }