private void process(final Document doc, final BuildState bs) throws ParserException { // start = element icalendar { vcalendar+ } Element root = doc.getDocumentElement(); if (!XmlUtil.nodeMatches(root, XcalTags.icalendar)) { // error throw new ParserException("Expected " + XcalTags.icalendar + " found " + root, 0); } for (Element el: getChildren(root)) { // Expect vcalendar if (!XmlUtil.nodeMatches(el, XcalTags.vcalendar)) { // error throw new ParserException("Expected " + XcalTags.vcalendar + " found " + el, 0); } bs.setCalendar(null); processVcalendar(el, bs); if (bs.getCalendar() != null) { bs.getCalendars().add(bs.getCalendar()); } } }
/** * @param ical * @return Calendar object or null for no data * @throws Throwable */ public Calendar fromXcal(final IcalendarType ical) throws Throwable { BuildState bs = new BuildState(tzRegistry); bs.setContentHandler(new ContentHandlerImpl(bs)); List<VcalendarType> vcts = ical.getVcalendar(); if (vcts.size() == 0) { return null; } if (vcts.size() > 1) { throw new Exception("More than one vcalendar"); } processVcalendar(vcts.get(0), bs); return bs.getCalendar(); }
private void process(final JsonParser parser, final BuildState bs) throws ParserException { /* ["vcalendar", [ <properties> ], [ <components> ] ] */ try { arrayStart(parser); final String ctype = textField(parser); if (!ctype.equals("vcalendar")) { // error throwException("Expected vcalendar: found " + ctype, parser); } lastComponent = "vcalendar"; bs.setCalendar(null); processVcalendar(parser, bs); if (bs.getCalendar() != null) { bs.getCalendars().add(bs.getCalendar()); } arrayEnd(parser); } catch (final Throwable t) { handleException(t, parser); } }
@Override public void endProperty(final String name) { assertProperty(bs.getProperty()); // replace with a constant instance if applicable.. bs.setProperty(Constants.forProperty(bs.getProperty())); if (bs.getComponent() != null) { bs.getComponent().getProperties().add(bs.getProperty()); } else if (bs.getCalendar() != null) { bs.getCalendar().getProperties().add(bs.getProperty()); } bs.setProperty(null); }
bs.getCalendar().getComponents().add((CalendarComponent)component); if ((component instanceof VTimeZone) && (bs.getTzRegistry() != null)) {