本文整理汇总了Java中net.fortuna.ical4j.data.ParserException类的典型用法代码示例。如果您正苦于以下问题:Java ParserException类的具体用法?Java ParserException怎么用?Java ParserException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParserException类属于net.fortuna.ical4j.data包,在下文中一共展示了ParserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ReadCalendarFiles
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public ReadCalendarFiles(String filePath) throws IOException, ParserException {
Map<String, String> calendarEntry = null;
FileInputStream fin = new FileInputStream(filePath);
CalendarBuilder builder = new CalendarBuilder();
net.fortuna.ical4j.model.Calendar calendar = builder.build(fin);
for (Iterator i = calendar.getComponents().iterator(); i.hasNext(); ) {
Component component = (Component) i.next();
if (component.getName().equalsIgnoreCase("VEVENT")) {
calendarEntry = new HashMap<>();
for (Iterator j = component.getProperties().iterator(); j.hasNext(); ) {
net.fortuna.ical4j.model.Property property = (Property) j.next();
calendarEntry.put(property.getName(), property.getValue());
}
calendarEntries.add(calendarEntry);
}
}
}
示例2: createCampaign
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
private static CampaignCreateMethod createCampaign(
final String apikey, final String listId, final URL calendarUrl, final File groupDirectory)
throws IOException, ParserException, ParserConfigurationException, SAXException {
final CampaignCreateMethod create = new CampaignCreateMethod();
create.apikey = apikey;
create.type = CampaignType.plaintext;
final MailChimpObject options = new MailChimpObject();
options.put("list_id", listId);
options.put("subject", createSubject());
options.put("from_email", FROM_ADDRESS);
options.put("from_name", "Meet-Hub-Hannover");
create.options = options;
final MailChimpObject content = new MailChimpObject();
content.put("text", createMailText(calendarUrl, groupDirectory));
create.content = content;
return create;
}
示例3: createMailText
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
private static String createMailText(final URL calendarUrl, final File groupDirectory)
throws IOException, ParserException, ParserConfigurationException, SAXException {
final Calendar mergedCalendar = loadCalendar(calendarUrl);
final Period nextPeriod = new Period(new DateTime(), new Dur(1));
return "== Meet-Hub-Hannover Veranstaltungs-Newsletter ==\n" +
"\n" +
"Nächste Woche:\n" +
formatNextEvents(mergedCalendar, nextPeriod) +
"\n" +
"Danach:\n" +
formatLaterEvents(mergedCalendar, nextPeriod) +
"\n" +
"Beteiligte Gruppen:\n" +
formatGroups(groupDirectory) +
"\n" +
"==============================================\n" +
"*|LIST:DESCRIPTION|*\n" +
"\n" +
"Die E-Mail-Adresse *|EMAIL|* vom Newsletter abmelden:\n" +
"*|UNSUB|*\n";
}
示例4: getVTimeZone
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
/**
* Return ical4j VTimeZone instance for timezone id
* @param id timezone id
* @return ical4j VTimeZone instance
*/
public static VTimeZone getVTimeZone(String id) {
if(!allTimezoneIds.contains(id)) {
return null;
}
com.ibm.icu.util.VTimeZone icuvtz = com.ibm.icu.util.VTimeZone.create(id);
if(icuvtz==null) {
return null;
}
try {
StringWriter sw = new StringWriter();
icuvtz.write(sw, TIMEZONE_START_DATE);
VTimeZone vtz = (VTimeZone) CalendarUtils.parseComponent(sw.toString());
fixIcuVTimeZone(vtz);
return vtz;
} catch (ParserException | IOException e) {
throw new CosmoException(e);
}
}
示例5: extractUid
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
private String extractUid(String icalendar) throws IOException, ParserException {
String uid = null;
StringReader reader = new StringReader(icalendar);
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(new UnfoldingReader(reader, true));
if ( calendar != null && calendar.getComponents() != null ) {
Iterator<Component> iterator = calendar.getComponents().iterator();
while (iterator.hasNext()) {
Component component = iterator.next();
if ( component instanceof VEvent ) {
uid = ((VEvent)component).getUid().getValue();
break;
}
}
}
return uid;
}
示例6: importCalendarFile
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public void importCalendarFile(ActionRequest request, ActionResponse response) throws IOException, ParserException
{
ImportConfiguration imp = request.getContext().asType(ImportConfiguration.class);
Object object = request.getContext().get("_id");
Calendar cal = null;
if(object != null){
Long id = Long.valueOf(object.toString());
cal = Beans.get(CalendarRepository.class).find(id);
}
if(cal == null){
cal = new Calendar();
}
File data = MetaFiles.getPath( imp.getDataMetaFile() ).toFile();
calendarService.importCalendar(cal, data);
response.setCanClose(true);
response.setReload(true);
}
示例7: loadSources
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public static void loadSources() throws IOException, ParserException {
loadWebSource();
if (familyCalendars.getCalendars().isEmpty()) {
totalWorkProperty.set(10);
// createWebCalendar("https://www.nasa.gov/templateimages/redesign/calendar/iCal/nasa_calendar.ics", "NASA", Calendar.Style.STYLE1, communityCalendars);
workDoneProperty.set(1);
createWebCalendar("https://cantonbecker.com/astronomy-calendar/astrocal.ics", "Moon / Astro", Calendar.Style.STYLE2, communityCalendars);
workDoneProperty.set(2);
createWebCalendar("http://ical.mac.com/ical/US32Holidays.ics", "US Holidays", Calendar.Style.STYLE3, communityCalendars);
workDoneProperty.set(3);
createWebCalendar("https://www.google.com/calendar/ical/6g08e17mnjao5k7ddftfvq5gs8%40group.calendar.google.com/public/basic.ics", "FC Liverpool", Calendar.Style.STYLE5, communityCalendars);
workDoneProperty.set(4);
createWebCalendar("https://www.google.com/calendar/ical/ohg8jr90apq8k0vili2fbs17to%40group.calendar.google.com/public/basic.ics", "Real Madrid", Calendar.Style.STYLE4, communityCalendars);
workDoneProperty.set(5);
createWebCalendar("https://calendar.google.com/calendar/ical/flexcalendarfxdemo%40gmail.com/private-43f02ea9664382e80e6fbe0a541511ee/basic.ics", "Standard", Calendar.Style.STYLE1, familyCalendars);
workDoneProperty.set(6);
createWebCalendar("https://calendar.google.com/calendar/ical/75bjnbr2qr5qgetav71tug2sec%40group.calendar.google.com/private-c6c6a59d97aa2806fe28cfbdb2e2957b/basic.ics", "Home", Calendar.Style.STYLE2, familyCalendars);
workDoneProperty.set(7);
createWebCalendar("https://calendar.google.com/calendar/ical/5rj1uvaobtosjqoqqkpdlj01gg%40group.calendar.google.com/private-4dc56992aed93526cbab07da6cd4b69b/basic.ics", "School", Calendar.Style.STYLE3, familyCalendars);
workDoneProperty.set(8);
createWebCalendar("https://calendar.google.com/calendar/ical/0itqq6d7pukf1tapbll3lbad5c%40group.calendar.google.com/private-7fb78a4b949cede8228d791faba9061e/basic.ics", "Sports", Calendar.Style.STYLE4, familyCalendars);
workDoneProperty.set(9);
createWebCalendar("https://calendar.google.com/calendar/ical/u6em5saa8omkamh68bl7fikclo%40group.calendar.google.com/private-bce22b1e9b43b632c7edfad45d677b59/basic.ics", "Work", Calendar.Style.STYLE5, familyCalendars);
workDoneProperty.set(10);
}
}
示例8: createWebCalendar
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public static ICalCalendar createWebCalendar(String url, String name, Calendar.Style style, CalendarSource source) throws IOException, ParserException {
if (url == null || url.isEmpty() || name == null || name.isEmpty() || style == null) {
return null;
}
WebCalendarData data = new WebCalendarData(url, name, style, source == familyCalendars);
ICalCalendar cal = putWebCalendar(data, source);
List<WebCalendarData> webCalendarDatas = new ArrayList<>();
webCalendarDatas.addAll(webCalendars.keySet());
if (!webCalendarDatas.isEmpty()) {
final File directory = new File(System.getProperty("user.home") + SETTINGS_DIR);
boolean directoryExists = true;
if (!directory.exists()) {
directoryExists = directory.mkdirs();
}
if (directoryExists) {
final File file = new File(directory, SETTINGS_FILE);
boolean fileExists = true;
if (!file.exists()) {
fileExists = file.createNewFile();
}
if (fileExists) {
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
oos.writeObject(webCalendarDatas);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return cal;
}
示例9: testCalendar
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
@Test
public void testCalendar() throws IOException, ParserException, ParseException, SQLException {
String calendarString = "BEGIN:VCALENDAR\n" +
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:Asia/Yekaterinburg\n" +
"BEGIN:STANDARD\n" +
"TZOFFSETFROM:+0500\n" +
"TZOFFSETTO:+0500\n" +
"TZNAME:YEKT\n" +
"DTSTART:19700101T000000\n" +
"END:STANDARD\n" +
"END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" +
"CREATED:20161213T045151Z\n" +
"LAST-MODIFIED:20161213T045242Z\n" +
"DTSTAMP:20161213T045242Z\n" +
"UID:9d000df0-6354-479d-a407-218dac62c7c9\n" +
"SUMMARY:Every night\n" +
"RRULE:FREQ=DAILY\n" +
"DTSTART;TZID=Asia/Yekaterinburg:20161130T230000\n" +
"DTEND;TZID=Asia/Yekaterinburg:20161201T070000\n" +
"TRANSP:OPAQUE\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
Calendar calendar = new Calendar();
calendar.setData(calendarString.getBytes());
DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ssX");
Date date = format.parse("2016-12-13 22:59:59+05");
Assert.assertTrue(!calendar.checkMoment(date));
date = format.parse("2016-12-13 23:00:01+05");
Assert.assertTrue(calendar.checkMoment(date));
date = format.parse("2016-12-13 06:59:59+05");
Assert.assertTrue(calendar.checkMoment(date));
date = format.parse("2016-12-13 07:00:01+05");
Assert.assertTrue(!calendar.checkMoment(date));
}
示例10: testCalendarFileReader
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public void testCalendarFileReader() throws InvalidFormatException, XmlException, IOException, TikaException, SAXException, ParserException {
ReadCalendarFiles calendar = new ReadCalendarFiles("GoogleTakeout/Calendar/Mark Watson.ics");
System.err.println("\n\nTest iCal calendar file has " + calendar.size() + " calendar entries.");
for (int i=0, size=calendar.size(); i<size; i++) {
Map<String,String> entry = calendar.getCalendarEntry(i);
System.err.println("\n\tNext calendar entry:");
System.err.println("\n\t\tDTSAMP:\t" + entry.getOrDefault("DTSTAMP", ""));
System.err.println("\n\t\tSUMMARY:\t" + entry.getOrDefault("SUMMARY", ""));
System.err.println("\n\t\tDESCRIPTION:\t" + entry.getOrDefault("DESCRIPTION", ""));
}
}
示例11: testMboxFileReader
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public void testMboxFileReader() throws InvalidFormatException, XmlException, IOException, TikaException, SAXException, ParserException {
ReadMbox mbox = new ReadMbox("GoogleTakeout/Mail/bookexample.mbox");
System.err.println("\nMBOX size = " + mbox.size());
for (int i=0, size=mbox.size(); i<size; i++) {
System.err.println("\n* * next email:\n\n" + mbox.getEmail(i) + "\n");
}
}
示例12: main
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public static void main(final String[] args) throws MalformedURLException {
System.out.println("command line: <apikey> <list-id> <calendar-url> <group-directory>\n");
final String apiKey = args[0];
final String listId = args[1];
final URL calendarUrl = new URL(args[2]);
final File groupDirectory = new File(args[3]);
final MailChimpClient mc = new MailChimpClient();
try {
System.out.println("Creating campaign...\n");
final String cid = mc.execute(createCampaign(apiKey, listId, calendarUrl, groupDirectory));
System.out.println("Campaign ID: " + cid);
System.out.println("Test sending...");
final CampaignSendTestMethod sendMethod = new CampaignSendTestMethod();
sendMethod.apikey = apiKey;
sendMethod.cid = cid;
sendMethod.test_emails = Arrays.asList(TEST_ADDRESS);
mc.execute(sendMethod);
final String time = getScheduleTime();
System.out.println("Scheduling real sending for " + time + " ...");
final CampaignScheduleMethod schedule = new CampaignScheduleMethod();
schedule.apikey = apiKey;
schedule.cid = cid;
schedule.schedule_time = time;
mc.execute(schedule);
System.out.println("Finished.");
} catch (final IOException | MailChimpException | ParserException | ParserConfigurationException | SAXException e) {
System.out.println("Fehler beim Senden");
e.printStackTrace(System.out);
} finally {
mc.close();
}
}
示例13: loadCalendar
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
public static Calendar loadCalendar(final URL url) throws IOException, ParserException {
//noetig wegen ical4j-Bug #167
CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
final CalendarBuilder b = new CalendarBuilder();
final URLConnection conn = url.openConnection();
try (InputStream in = conn.getInputStream()) {
return b.build(in);
}
}
示例14: extractNews
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
private List<News> extractNews(String path) throws IOException, ParserException {
FileInputStream fin = new FileInputStream(path);
CalendarBuilder builder = new CalendarBuilder();
net.fortuna.ical4j.model.Calendar calendar = builder.build(fin);
ComponentList events = calendar.getComponents(Component.VEVENT);
List<News> news = new ArrayList<>();
for (Object e : events) {
VEvent event = (VEvent) e;
news.add(new News(event.getSummary().getValue(), event.getStartDate().getDate(), event.getDescription().getValue()));
}
return news;
}
示例15: parseCalendar
import net.fortuna.ical4j.data.ParserException; //导入依赖的package包/类
/**
* Parse icalendar string into Calendar object.
* @param calendar icalendar string
* @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(String calendar) throws ParserException, IOException {
if (calendar == null) {
return null;
}
CalendarBuilder builder = CalendarBuilderDispenser.getCalendarBuilder();
clearTZRegistry(builder);
StringReader sr = new StringReader(calendar);
return builder.build(sr);
}