public abstract class BaseParser extends Object implements SubstitutionScheduleParser
SubstitutionScheduleParser implementations.| Modifier and Type | Field and Description |
|---|---|
protected ColorProvider |
colorProvider |
protected CookieProvider |
cookieProvider |
protected org.apache.http.client.CookieStore |
cookieStore |
protected Credential |
credential |
protected org.mozilla.universalchardet.UniversalDetector |
encodingDetector |
protected org.apache.http.client.fluent.Executor |
executor |
static String |
PARAM_CLASS_REGEX |
protected SubstitutionScheduleData |
scheduleData |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
contains(org.json.JSONArray array,
String string) |
abstract List<String> |
getAllClasses()
Get a list of all available classes.
|
abstract List<String> |
getAllTeachers()
Get a list of all available teachers.
|
protected List<String> |
getClassesFromJson() |
Credential |
getCredential() |
static BaseParser |
getInstance(SubstitutionScheduleData data,
CookieProvider cookieProvider)
Create an appropriate parser for a given school.
|
abstract SubstitutionSchedule |
getSubstitutionSchedule()
Downloads and parses the substitution schedule
|
protected String |
httpGet(String url,
String encoding) |
protected String |
httpGet(String url,
String encoding,
Map<String,String> headers) |
protected String |
httpPost(String url,
String encoding,
List<org.apache.http.NameValuePair> formParams) |
protected String |
httpPost(String url,
String encoding,
List<org.apache.http.NameValuePair> formParams,
Map<String,String> headers) |
protected String |
httpPost(String url,
String encoding,
String body,
org.apache.http.entity.ContentType contentType) |
protected String |
httpPost(String url,
String encoding,
String body,
org.apache.http.entity.ContentType contentType,
Map<String,String> headers) |
protected static String |
recognizeType(String text) |
void |
setCredential(Credential credential) |
public static final String PARAM_CLASS_REGEX
protected SubstitutionScheduleData scheduleData
protected org.apache.http.client.fluent.Executor executor
protected Credential credential
protected org.apache.http.client.CookieStore cookieStore
protected ColorProvider colorProvider
protected CookieProvider cookieProvider
protected org.mozilla.universalchardet.UniversalDetector encodingDetector
public static BaseParser getInstance(SubstitutionScheduleData data, @Nullable CookieProvider cookieProvider)
SubstitutionScheduleData.getApi().data - a SubstitutionScheduleData object containing information about the substitution scheduleBaseParser subclass able to parse the given schedule.public abstract SubstitutionSchedule getSubstitutionSchedule() throws IOException, org.json.JSONException, CredentialInvalidException
getSubstitutionSchedule in interface SubstitutionScheduleParserSubstitutionScheduleIOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidException - the supplied credential (setCredential(Credential) is
not correctpublic abstract List<String> getAllClasses() throws IOException, org.json.JSONException, CredentialInvalidException
IOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidExceptionpublic abstract List<String> getAllTeachers() throws IOException, org.json.JSONException, CredentialInvalidException
null.IOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidExceptionpublic Credential getCredential()
getCredential in interface SubstitutionScheduleParserpublic void setCredential(Credential credential)
setCredential in interface SubstitutionScheduleParserprotected String httpGet(String url, String encoding) throws IOException, CredentialInvalidException
protected String httpGet(String url, String encoding, Map<String,String> headers) throws IOException, CredentialInvalidException
protected String httpPost(String url, String encoding, List<org.apache.http.NameValuePair> formParams) throws IOException, CredentialInvalidException
protected String httpPost(String url, String encoding, List<org.apache.http.NameValuePair> formParams, Map<String,String> headers) throws IOException, CredentialInvalidException
protected String httpPost(String url, String encoding, String body, org.apache.http.entity.ContentType contentType) throws IOException, CredentialInvalidException
protected String httpPost(String url, String encoding, String body, org.apache.http.entity.ContentType contentType, Map<String,String> headers) throws IOException, CredentialInvalidException
protected boolean contains(org.json.JSONArray array,
String string)
throws org.json.JSONException
org.json.JSONException