From 7a258da03342cccc4b112688de2c1fdd67a468ee Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Mon, 16 Oct 2023 12:57:45 +0200 Subject: [PATCH] improve documentation --- .../reporting/reportobject/ReportObjectFactory.java | 4 +++- .../jplag/reporting/reportobject/writer/FileWriter.java | 8 ++++++++ .../jplag/reporting/reportobject/writer/JsonWriter.java | 9 +++------ .../jplag/reporting/reportobject/writer/TextWriter.java | 3 +++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java index 5a5983fb7..1be304a3b 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/ReportObjectFactory.java @@ -51,6 +51,8 @@ public class ReportObjectFactory { public static final String OVERVIEW_FILE_NAME = "overview.json"; public static final String README_FILE_NAME = "README.txt"; + public static final String README_CONTENT = "To view the results go to https://jplag.github.io/JPlag/ and drag the generated zip file onto the page."; + public static final String SUBMISSIONS_FOLDER = "files"; public static final String SUBMISSION_FILE_INDEX_FILE_NAME = "submissionFileIndex.json"; public static final Version REPORT_VIEWER_VERSION = JPlag.JPLAG_VERSION; @@ -203,7 +205,7 @@ private void writeOverview(JPlagResult result, String path) { } private void writeReadMeFile(String path) { - new TextWriter().writeFile("Test content", path, README_FILE_NAME); + new TextWriter().writeFile(README_CONTENT, path, README_FILE_NAME); } private void writeSubmissionIndexFile(JPlagResult result, String path) { diff --git a/core/src/main/java/de/jplag/reporting/reportobject/writer/FileWriter.java b/core/src/main/java/de/jplag/reporting/reportobject/writer/FileWriter.java index 84f6ce1cc..ec8888a49 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/writer/FileWriter.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/writer/FileWriter.java @@ -1,8 +1,16 @@ package de.jplag.reporting.reportobject.writer; /** + * Responsible for writing a specific file type to the disk. * @param Object that the FileWriter writes. */ public interface FileWriter { + + /** + * Saves the provided object to the provided path under the provided name + * @param fileContent The object to save + * @param folderPath The path to save the object to + * @param fileName The name to save the object under + */ void writeFile(T fileContent, String folderPath, String fileName); } diff --git a/core/src/main/java/de/jplag/reporting/reportobject/writer/JsonWriter.java b/core/src/main/java/de/jplag/reporting/reportobject/writer/JsonWriter.java index 817b068f0..165742652 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/writer/JsonWriter.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/writer/JsonWriter.java @@ -8,17 +8,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; +/** + * Writes an object with {@link com.fasterxml.jackson.annotation.JsonProperty}s to the disk. + */ public class JsonWriter implements FileWriter { private static final Logger logger = LoggerFactory.getLogger(JsonWriter.class); private static final ObjectMapper objectMapper = new ObjectMapper(); - /** - * Saves the provided object to the provided path under the provided name - * @param fileToSave The object to save - * @param folderPath The path to save the object to - * @param fileName The name to save the object under - */ @Override public void writeFile(Object fileToSave, String folderPath, String fileName) { try { diff --git a/core/src/main/java/de/jplag/reporting/reportobject/writer/TextWriter.java b/core/src/main/java/de/jplag/reporting/reportobject/writer/TextWriter.java index 4f168b311..ebf6d7dca 100644 --- a/core/src/main/java/de/jplag/reporting/reportobject/writer/TextWriter.java +++ b/core/src/main/java/de/jplag/reporting/reportobject/writer/TextWriter.java @@ -7,6 +7,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Writes plain text to a file. + */ public class TextWriter implements FileWriter { private static final Logger logger = LoggerFactory.getLogger(TextWriter.class);