Class RegisterController

java.lang.Object
no.ntnu.idatt1002.spendwise.data.RegisterController

public class RegisterController extends Object
Loader class containing methods for writing and reading data from a JSON file, which holds all the data of the register.
  • Constructor Details

    • RegisterController

      public RegisterController()
  • Method Details

    • readData

      Reads data from a JSON file and returns a Register object.
      Parameters:
      url - The URL of the JSON file.
      Returns:
      A Register object, with all the data from the JSON file loaded.
      Throws:
      IOException - If the file read fails.
      URISyntaxException - If the URL is invalid.
      ConformityException - If the data in the JSON file is invalid.
      DuplicateNameException - If the data in the JSON file is invalid.
    • writeData

      public static org.json.JSONObject writeData(Register register) throws IOException
      Writes data from a Register object to a JSON object. It does not actually write to a file, but serializes and returns a JSON object that can be written to a file.
      Parameters:
      register - The register to write data from.
      Returns:
      A JSON object containing all the data from the register.
      Throws:
      IOException - If the file write fails.