Added JavaDoc to JsonProcessing class. Issue #39

This commit is contained in:
law39 2020-05-01 13:21:32 +01:00
parent b0a3b95d70
commit e95a8a9159

View file

@ -1,4 +1,10 @@
package uk.ac.aber.cs221.group20.json; package uk.ac.aber.cs221.group20.json;
/**
* @(#) JsonProcessing.java 0,1 2020/04/27
* <p>
* Copyright (c) 2020 Aberystwyth University.
* All rights reserved.
*/
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -10,8 +16,30 @@ import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
/**
* A class that handles the import and export of Json-formatted files, following the schema set out in SE.QA.CSRS DC3
*
* @author Brad Corbett [brc9]
* @author Henry Dugmore [hjd3]
* @author Kain Bryan-Jones [kab74]
* @author Luke Wybar [law39]
* @author Marcin Jakob [maj83]
* @author Oscar Pocock [osp1]
* @author Tom Perry [top1]
* @author Waylen Watts [ncw]
* @version 0.1 Initial development.
* @see DictionaryEntry
*/
public class JsonProcessing { public class JsonProcessing {
/**
* Method to read in a Json file formatted in the schema set out in SE.QA.CSRS DC3
* <p>
* @param file Pass in a File object referencing the Json file wish to be read in.
* @return A LinkedList containing all the valid DictionaryEntry objects stored in the Json File
* @see DictionaryEntry
*/
public LinkedList<DictionaryEntry> readInJson(File file) { public LinkedList<DictionaryEntry> readInJson(File file) {
LinkedList<DictionaryEntry> returnVal = new LinkedList<>(); LinkedList<DictionaryEntry> returnVal = new LinkedList<>();
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
@ -25,6 +53,12 @@ public class JsonProcessing {
return returnVal; return returnVal;
} }
/**
* Method to write out a Json file formatted in the schema set out in SE.QA.CSRS DC3
* <p>
* @param directoryAndFile pass in a String containing a fully qualified path name and file name, where the Json file should be output
* @param words pass in a LinkedList of DictionaryEntry objects which should be output in the Json file
*/
public void writeOutJson(String directoryAndFile, LinkedList<DictionaryEntry> words) { public void writeOutJson(String directoryAndFile, LinkedList<DictionaryEntry> words) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String JsonString = ""; String JsonString = "";