public abstract class BaseParser extends java.lang.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 DebuggingDataHandler |
debuggingDataHandler |
protected org.mozilla.universalchardet.UniversalDetector |
encodingDetector |
protected org.apache.http.client.fluent.Executor |
executor |
static java.lang.String |
PARAM_CLASS_REGEX |
protected SubstitutionScheduleData |
scheduleData |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
contains(org.json.JSONArray array,
java.lang.String string) |
abstract java.util.List<java.lang.String> |
getAllClasses()
Get a list of all available classes.
|
abstract java.util.List<java.lang.String> |
getAllTeachers()
Get a list of all available teachers.
|
protected java.util.List<java.lang.String> |
getClassesFromJson() |
Credential |
getCredential() |
static BaseParser |
getInstance(SubstitutionScheduleData data,
CookieProvider cookieProvider)
Create an appropriate parser for a given school.
|
org.joda.time.LocalDateTime |
getLastChange()
Returns the time when the substitution schedule was last changed.
|
abstract SubstitutionSchedule |
getSubstitutionSchedule()
Downloads and parses the substitution schedule
|
protected java.lang.String |
httpGet(java.lang.String url,
java.lang.String encoding) |
protected java.lang.String |
httpGet(java.lang.String url,
java.lang.String encoding,
java.util.Map<java.lang.String,java.lang.String> headers) |
protected java.lang.String |
httpPost(java.lang.String url,
java.lang.String encoding,
java.util.List<org.apache.http.NameValuePair> formParams) |
protected java.lang.String |
httpPost(java.lang.String url,
java.lang.String encoding,
java.util.List<org.apache.http.NameValuePair> formParams,
java.util.Map<java.lang.String,java.lang.String> headers) |
protected java.lang.String |
httpPost(java.lang.String url,
java.lang.String encoding,
java.lang.String body,
org.apache.http.entity.ContentType contentType) |
protected java.lang.String |
httpPost(java.lang.String url,
java.lang.String encoding,
java.lang.String body,
org.apache.http.entity.ContentType contentType,
java.util.Map<java.lang.String,java.lang.String> headers) |
boolean |
isPersonal()
Some substitution schedule systems allow the user to only see his "own" substitution schedule depending on the
credentials he enters.
|
protected static java.lang.String |
recognizeType(java.lang.String text) |
void |
setCredential(Credential credential) |
void |
setDebuggingDataHandler(DebuggingDataHandler handler) |
public static final java.lang.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
protected DebuggingDataHandler debuggingDataHandler
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 org.joda.time.LocalDateTime getLastChange()
throws java.io.IOException,
org.json.JSONException,
CredentialInvalidException
SubstitutionScheduleParserBaseParser returns null.getLastChange in interface SubstitutionScheduleParserjava.io.IOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidException - the supplied credential (setCredential(Credential) is
not correctprotected static java.lang.String recognizeType(java.lang.String text)
public abstract SubstitutionSchedule getSubstitutionSchedule() throws java.io.IOException, org.json.JSONException, CredentialInvalidException
SubstitutionScheduleParsergetSubstitutionSchedule in interface SubstitutionScheduleParserSubstitutionSchedulejava.io.IOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidException - the supplied credential (setCredential(Credential) is
not correctpublic abstract java.util.List<java.lang.String> getAllClasses()
throws java.io.IOException,
org.json.JSONException,
CredentialInvalidException
java.io.IOException - Connection or parsing errororg.json.JSONException - Error with the JSON configurationCredentialInvalidExceptionpublic abstract java.util.List<java.lang.String> getAllTeachers()
throws java.io.IOException,
org.json.JSONException,
CredentialInvalidException
null.java.io.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 SubstitutionScheduleParserpublic void setDebuggingDataHandler(DebuggingDataHandler handler)
protected java.lang.String httpGet(java.lang.String url,
java.lang.String encoding)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected java.lang.String httpGet(java.lang.String url,
java.lang.String encoding,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected java.lang.String httpPost(java.lang.String url,
java.lang.String encoding,
java.util.List<org.apache.http.NameValuePair> formParams)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected java.lang.String httpPost(java.lang.String url,
java.lang.String encoding,
java.util.List<org.apache.http.NameValuePair> formParams,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected java.lang.String httpPost(java.lang.String url,
java.lang.String encoding,
java.lang.String body,
org.apache.http.entity.ContentType contentType)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected java.lang.String httpPost(java.lang.String url,
java.lang.String encoding,
java.lang.String body,
org.apache.http.entity.ContentType contentType,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException,
CredentialInvalidException
java.io.IOExceptionCredentialInvalidExceptionprotected static boolean contains(org.json.JSONArray array,
java.lang.String string)
throws org.json.JSONException
org.json.JSONException@Nullable
protected java.util.List<java.lang.String> getClassesFromJson()
throws org.json.JSONException
org.json.JSONExceptionpublic boolean isPersonal()
SubstitutionScheduleParsertrue.isPersonal in interface SubstitutionScheduleParser