001package csheets.ext.database.core; 002 003import java.io.File; 004import java.io.FileNotFoundException; 005import java.util.ArrayList; 006import java.util.Scanner; 007 008/** 009 * Reads a cvs file containing relevant information about the database 010 * technology 011 * @author João Carreira 012 */ 013public class DBCsvReader 014{ 015 private ArrayList<Database> dbList; 016 /* path to settings file */ 017 private final String filePath = "src-resources/csheets/ext/database/settings.csv"; 018 /* csv file */ 019 File f = new File(filePath); 020 021 022 /** 023 * constructor 024 */ 025 public DBCsvReader() 026 { 027 } 028 029 /** 030 * returns a list of supported databases 031 * @return ArrayList of type Database with supported databases 032 */ 033 public ArrayList<Database> getDBList() throws FileNotFoundException 034 { 035 updateDBList(); 036 return dbList; 037 } 038 039 /** 040 * updates the list of the current supported databases into the arraylist 041 * @throws FileNotFoundException 042 */ 043 public void updateDBList() throws FileNotFoundException 044 { 045 Scanner fin = new Scanner(f); 046 dbList = new ArrayList<Database>(); 047 while(fin.hasNextLine()) 048 { 049 String temp = fin.nextLine(); 050 String []temp2 = temp.split(";"); 051 dbList.add(new Database(temp2[0], temp2[1])); 052 } 053 } 054 055}