Parse overtime goals
This commit is contained in:
@@ -13,6 +13,8 @@ public abstract class BaseMatch {
|
||||
protected String teamNameGuest = null;
|
||||
protected Integer goalsHome = null;
|
||||
protected Integer goalsGuest = null;
|
||||
protected Integer goalsOvertimeHome = null;
|
||||
protected Integer goalsOvertimeGuest = null;
|
||||
protected Integer matchday = null;
|
||||
protected String matchDatetime = null;
|
||||
|
||||
@@ -40,6 +42,14 @@ public abstract class BaseMatch {
|
||||
return this.goalsGuest;
|
||||
}
|
||||
|
||||
public Integer getGoalsOvertimeHome() {
|
||||
return this.goalsOvertimeHome;
|
||||
}
|
||||
|
||||
public Integer getGoalsOvertimeGuest() {
|
||||
return this.goalsOvertimeGuest;
|
||||
}
|
||||
|
||||
public String getTeamNameHome() {
|
||||
return this.teamNameHome;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class APIFootballConnector {
|
||||
return stringToJSONObject(content);
|
||||
}
|
||||
|
||||
private JSONObject stringToJSONObject(String rawData) {
|
||||
public static JSONObject stringToJSONObject(String rawData) {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject data = null;
|
||||
|
||||
@@ -30,6 +30,7 @@ public class APIFootballMatch extends BaseMatch {
|
||||
throw new Exception("Did not find matchday for league '" + this.leagueId + "': '" + json.get("round").toString() + "'");
|
||||
}
|
||||
this.matchDatetime = (String) json.get("event_date");
|
||||
this.parseResult(json);
|
||||
}
|
||||
|
||||
public int getAPIFootBallMatchID() {
|
||||
@@ -74,4 +75,16 @@ public class APIFootballMatch extends BaseMatch {
|
||||
public Boolean getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
private void parseResult(JSONObject json) {
|
||||
String resultFulltime = ((JSONObject) json.get("score")).get("fulltime").toString();
|
||||
this.goalsHome = Integer.parseInt(resultFulltime.substring(0, 1));
|
||||
this.goalsGuest = Integer.parseInt(resultFulltime.substring(2, 3));
|
||||
|
||||
Object resultExtratime = ((JSONObject) json.get("score")).get("extratime");
|
||||
if(resultExtratime != null) {
|
||||
this.goalsOvertimeHome = this.goalsHome + Integer.parseInt(resultExtratime.toString().substring(0, 1));
|
||||
this.goalsOvertimeGuest = this.goalsGuest + Integer.parseInt(resultExtratime.toString().substring(2, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ public class TLWMatch extends BaseMatch{
|
||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsOvertimeHome = apiFootballMatch.getGoalsOvertimeHome();
|
||||
this.goalsOvertimeGuest = apiFootballMatch.getGoalsOvertimeGuest();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
||||
this.groupId = this.getGroupFromMatchdayString(apiFootballMatch.getRound());
|
||||
@@ -248,6 +252,22 @@ public class TLWMatch extends BaseMatch{
|
||||
return string != null ? "'"+string+"'" : "''";
|
||||
}
|
||||
|
||||
public void setGoalsHome(int goals) {
|
||||
this.goalsHome = goals;
|
||||
}
|
||||
|
||||
public void setGoalsGuest(int goals) {
|
||||
this.goalsGuest = goals;
|
||||
}
|
||||
|
||||
public void setGoalsOvertimeHome(int goals) {
|
||||
this.goalsOvertimeHome = goals;
|
||||
}
|
||||
|
||||
public void setGoalsOvertimeGuest(int goals) {
|
||||
this.goalsOvertimeGuest = goals;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user