Class CSVParser

Object
CSVParser

public class CSVParser extends Object
This class parses CSV files.
  • Field Details

    • path

      private String path
      The file directory path which the CSV files are expected to be in.
  • Constructor Details

    • CSVParser

      CSVParser(String path)
      Use this constructor if you would like to parse CSV files in a non-default directory.
      Parameters:
      path - Direct path to directory that stores the CSV files relevant to this BTO application.
    • CSVParser

      CSVParser()
      Use this constructor to parse CSVs as expected in default CSV file directory. Before compiling the project, place the CSV files in the sc2002.FCS1.grp2.files folder. After compilation, these files will be in the bin directory, files folder, along with the built class files. This constructor will automatically parse files based on this directory.
  • Method Details

    • parse

      private <Decodable extends CSVDecodable> ArrayList<Decodable> parse(String path, Class<Decodable> type)
      Generic method to parse various class types that extends CSVDecodable
      Type Parameters:
      Decodable - Only CSVDecodable types can be parsed/decoded to.
      Parameters:
      path - The path of the file.
      type - The expected type which the file should be decoded to.
      Returns:
      the parsed/decoded content.
    • parseLine

      private ArrayList<CSVCell> parseLine(String line)
      Parse each line, with special handling for CSV cells with list values.
      Parameters:
      line - A CSV line.
      Returns:
      a list of cells, of that line.
    • parseApplicants

      ArrayList<Applicant> parseApplicants()
    • parseManagers

      ArrayList<HDBManager> parseManagers()
    • parseOfficer

      ArrayList<HDBOfficer> parseOfficer()
    • parseProjects

      ArrayList<BTOProject> parseProjects()
    • parseEnquiries

      ArrayList<Enquiry> parseEnquiries()
    • parseApplications

      ArrayList<Application> parseApplications()
    • retrieveAllUsers

      ArrayList<User> retrieveAllUsers()
      Parse all users, regardless of user type.
      Returns:
      all user objects.