Class IcsParser
IcsEvent model — the exact
inverse of IcsWriter.
This is not IcsReader, and the difference matters. IcsReader
expands a recurring object into the occurrences that fall inside a window,
which is what a display needs. This parser keeps the object as it was
written: one master carrying its rule and its exceptions, plus any overrides
as separate events. Materialising a series from expanded occurrences would
produce a hundred unrelated events where the user has one weekly meeting.
Sharing IcsEvent with the writer is deliberate: it makes the round
trip testable. Anything the writer can say, this can read back, and a golden
that survives write(parse(ics)) unchanged has proven both halves at
once.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<org.exoplatform.caldav.model.IcsEvent> Reads every VEVENT of one calendar object, skipping an object that cannot be read at all.List<org.exoplatform.caldav.model.IcsEvent> parseOrFail(String ics) Reads every VEVENT of one calendar object, or says it could not.
-
Constructor Details
-
IcsParser
public IcsParser()
-
-
Method Details
-
parse
Reads every VEVENT of one calendar object, skipping an object that cannot be read at all.The master comes first when there is one, so a caller that creates before it overrides does not have to sort. An object with no VEVENT at all — a lone VTODO, or a body a server sent in error — yields an empty list rather than an exception: one unreadable object must not stop a synchronisation that has other objects to bring in.
Empty is not an answer to a question. This returns the same empty list for "there was nothing in it" and for "it could not be read", which is right for a caller that is importing objects and wrong for one that is deciding whether a copy carries an answer worth protecting. That caller uses
parseOrFail(String)instead.- Parameters:
ics- the calendar object as the server sent it- Returns:
- the events it carries, master first; empty when it carries none and when it cannot be read
-
parseOrFail
Reads every VEVENT of one calendar object, or says it could not.The flavour for a caller that must tell an object carrying nothing from an object it failed to understand. Those are the same empty list to
parse(String), and conflating them is how a copy holding a user's answer gets treated as a copy nobody answered — and then repaired over.- Parameters:
ics- the calendar object as the server sent it- Returns:
- the events it carries, master first; empty when it genuinely carries none
- Throws:
IcsParseException- when the body is not readable as iCalendar
-