Untitled
unknown
plain_text
3 years ago
4.3 kB
6
Indexable
private static List<Delivery> getDeliveriesData() throws IOException {
List<Delivery> deliveries = new ArrayList<>();
FileReader deliveryFile = new FileReader("/home/omprakash/Documents/javaprojects/deliveries.csv");
BufferedReader reader = new BufferedReader(deliveryFile);
String delivieriesInput ="";
int count = 0;
while((delivieriesInput = reader.readLine()) != null) {
if(count++ == 0) { continue; }
String[] deliveriesInputData = delivieriesInput.split(",");
Delivery delivery = new Delivery();
delivery.setMatchId(deliveriesInputData[DELIVERY_MATCHID]);
delivery.setInnings(deliveriesInputData[DELIVERY_INNINGS]);
delivery.setBattingTeam(deliveriesInputData[DELIVERY_BATTINGTEAM]);
delivery.setBowlingTeam(deliveriesInputData[DELIVERY_BOWLINGTEAM]);
delivery.setOver(deliveriesInputData[DELIVERY_OVER]);
delivery.setBall(deliveriesInputData[DELIVERY_BALL]);
delivery.setBatsman(deliveriesInputData[DELIVERY_BATSMAN]);
delivery.setNonStriker(deliveriesInputData[DELIVERY_NONSTRIKER]);
delivery.setBowler(deliveriesInputData[DELIVERY_BOWLER]);
delivery.setIsSuperOver(deliveriesInputData[DELIVERY_ISSUPEROVER]);
delivery.setWideRuns(deliveriesInputData[DELIVERY_WIDERUNS]);
delivery.setByeRuns(deliveriesInputData[DELIVERY_BYERUNS]);
delivery.setLegByeRuns(deliveriesInputData[DELIVERY_LEGRUNS]);
delivery.setNoBallRuns(deliveriesInputData[DELIVERY_NOBALLRUNS]);
delivery.setPenaltyRuns(deliveriesInputData[DELIVERY_PENALTYRUNS]);
delivery.setBatsmanRuns(deliveriesInputData[DELIVERY_BATSMANRUNS]);
delivery.setExtraRuns(deliveriesInputData[DELIVERY_EXTRARUNS]);
delivery.setTotalRuns(deliveriesInputData[DELIVERY_TOTALRUNS]);
if(deliveriesInputData.length > 18) {
delivery.setPlayerDismissed(deliveriesInputData[DELIVERY_PLAYERDISIMISAL]);
}
if(deliveriesInputData.length > 19) {
delivery.setDismissalKind(deliveriesInputData[DELIVERY_DISSIMISALKIND]);
}
if(deliveriesInputData.length > 20) {
delivery.setFielder(deliveriesInputData[DELIVERY_FIELDER]);
}
deliveries.add(delivery);
}
return deliveries;
}
private static List<Match> getMatchesData() throws IOException {
List<Match> matches = new ArrayList<>();
FileReader matchFile = new FileReader("/home/omprakash/Documents/javaprojects/matches.csv");
BufferedReader reader = new BufferedReader(matchFile);
String matchesInput = "";
int count = 0;
while((matchesInput = reader.readLine()) != null) {
String[] matchesInputData = matchesInput.split(",");
if(count++ == 0) { continue; }
Match match = new Match();
match.setId(matchesInputData[MATCH_ID]);
match.setSeason(matchesInputData[MATCH_SEASON]);
match.setCity(matchesInputData[MATCH_CITY]);
match.setDate(matchesInputData[MATCH_TOSSWINNER]);
match.setTeam1(matchesInputData[MATCH_TEAM1]);
match.setTeam2(matchesInputData[MATCH_TEAM2]);
match.setPlayerOfTheMatch(matchesInputData[MATCH_PLAYEROFTHEMATCH]);
match.setTossDecision(matchesInputData[MATCH_TOSSDECISION]);
match.setDlApplied(matchesInputData[MATCH_DLAPPLIED]);
match.setResult(matchesInputData[MATCH_RESULT]);
match.setTossWinner(matchesInputData[MATCH_TOSSWINNER]);
match.setWinByRuns(matchesInputData[MATCH_WINBYRUNS]);
match.setWinner(matchesInputData[MATCH_WINNER]);
match.setWinByWickets(matchesInputData[MATCH_WINBYWICKETS]);
match.setVenue(matchesInputData[MATCH_VENUE]);
if(matchesInputData.length > 15) {
match.setUmpire1(matchesInputData[MATCH_UMPIRE1]);
}
if(matchesInputData.length > 16) {
match.setUmpire2(matchesInputData[MATCH_UMPIRE2]);
}
matches.add(match);
}
return matches;
}Editor is loading...