Search in sources :

Example 1 with SubstitutionScheduleParser

use of me.vertretungsplan.parser.SubstitutionScheduleParser in project substitution-schedule-parser by vertretungsplanme.

the class ParserUtil method parseSubstitutionSchedule.

/**
 * Parses a substitution schedule.
 *
 * @param data       A <code>SubstitutionScheduleData</code> instance containing information about the schedule you
 *                   want to parse.
 * @param credential A <code>Credential</code> subclass for authentication. If the schedule requires no
 *                   authentication, use <code>null</code>.
 * @param cp         An optional <code>CookieProvider</code> implementation. This can be used if you want to reuse
 *                   session cookies the next time you load the schedule. If you don't need it, pass
 *                   <code>null</code>.
 * @param handler    An optional <code>DebuggingDataHandler</code> implementation. If you don't need it, pass
 *                   <code>null</code>.
 * @return The parsed substitution schedule.
 * @throws JSONException              When there's an error with your JSON configuration
 * @throws CredentialInvalidException When the <code>Credential</code> you supplied was invalid
 * @throws IOException                When there was another error while loading or parsing the schedule
 */
public static SubstitutionSchedule parseSubstitutionSchedule(SubstitutionScheduleData data, Credential credential, CookieProvider cp, DebuggingDataHandler handler) throws JSONException, CredentialInvalidException, IOException {
    SubstitutionScheduleParser parser = BaseParser.getInstance(data, cp);
    if (credential != null)
        parser.setCredential(credential);
    if (handler != null)
        ((BaseParser) parser).setDebuggingDataHandler(handler);
    SubstitutionSchedule schedule = parser.getSubstitutionSchedule();
    for (String a : data.getAdditionalInfos()) {
        BaseAdditionalInfoParser aParser = BaseAdditionalInfoParser.getInstance(a);
        schedule.addAdditionalInfo(aParser.getAdditionalInfo());
    }
    return schedule;
}
Also used : SubstitutionScheduleParser(me.vertretungsplan.parser.SubstitutionScheduleParser) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) BaseAdditionalInfoParser(me.vertretungsplan.additionalinfo.BaseAdditionalInfoParser)

Aggregations

BaseAdditionalInfoParser (me.vertretungsplan.additionalinfo.BaseAdditionalInfoParser)1 SubstitutionSchedule (me.vertretungsplan.objects.SubstitutionSchedule)1 SubstitutionScheduleParser (me.vertretungsplan.parser.SubstitutionScheduleParser)1