Package no.ntnu.idatt1002.spendwise.data
Class RegisterController
java.lang.Object
no.ntnu.idatt1002.spendwise.data.RegisterController
Loader class containing methods for writing and reading data from a JSON file,
which holds all the data of the register.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
RegisterController
public RegisterController()
-
-
Method Details
-
readData
public static Register readData(URL url) throws IOException, URISyntaxException, ConformityException, DuplicateNameException 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
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.
-