diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java index ffee661..a16db35 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java @@ -18,15 +18,16 @@ import java.util.List; */ public final class FFMpegHelper { + private static final String PROBE_SPLIT_CHARACTER = "øæåÆØå"; + private FFMpegHelper() { } - private static final String PROBE_SPLIT_CHARACTER = "øæåÆØå"; - /** * Gets streams from a file + * * @param ffprobePath
The path/command to ffprobe.
- * @param fileThe file to probe.
+ * @param fileThe file to probe.
* @returnA list of StreamObjects.
* @throws IOExceptionIf the process can't be readProcess.
*/ @@ -36,8 +37,9 @@ public final class FFMpegHelper { /** * Gets a list of all streams in a file + * * @param ffprobePathThe path/command to ffprobe.
- * @param fileThe file to probe.
+ * @param fileThe file to probe.
* @returnA list of streams.
* @throws IOExceptionIf something goes wrong while probing.
*/ @@ -69,8 +71,9 @@ public final class FFMpegHelper { /** * Takes a list of all streams and parses each stream into one of three objects + * * @param streamsA list of all streams for the current file.
- * @param fileThe file currently being converted.
+ * @param fileThe file currently being converted.
* @returnA list of StreamObjects.
*/ private static ListThe path/command to ffprobe.
- * @param directoryThe directory containing the file.
+ * + * @param ffprobePathThe path/command to ffprobe.
+ * @param directoryThe directory containing the file.
* @param convertingFileThe file to be converted.
* @returnThe extension of the subtitle or empty if no subtitle was found.
*/ @@ -127,8 +131,9 @@ public final class FFMpegHelper { /** * Starts and prints output of a process + * * @param processThe process to run.
- * @param folderThe folder the process should run in.
+ * @param folderThe folder the process should run in.
* @throws IOExceptionIf the process can't be readProcess.
*/ public static void convertProcess(ProcessBuilder process, File folder) throws IOException { @@ -149,6 +154,7 @@ public final class FFMpegHelper { /** * Reads from a process reader + * * @param readerThe reader of a process.
* @returnThe output from the readProcess.
* @throws IOExceptionOn reader failure.
@@ -164,8 +170,9 @@ public final class FFMpegHelper { /** * Creates a list containing all required arguments for converting a video to a web playable video + * * @param executableThe executable to use (ffmpeg/ffprobe).
- * @param fileNameThe name of the file to execute on.
+ * @param fileNameThe name of the file to execute on.
* @returnA base list of ffmpeg commands for converting a video for web
*/ public static ListThe executable to use (ffmpeg/ffprobe).
- * @param fileNameThe name of the file to execute on.
+ * @param fileNameThe name of the file to execute on.
* @returnA base list of ffmpeg commands for converting a file.
*/ public static ListThe list containing the command to run.
- * @param startThe offset before converting.
- * @param lengthThe offset for stopping the conversion.
+ * @param startThe offset before converting.
+ * @param lengthThe offset for stopping the conversion.
*/ public static void addDebugArguments(ListA list of parameters belonging to an video stream.
+ * + * @param streamPartsA list of parameters belonging to an video stream.
* @param relativeIndexThe relative index of the video stream.
* @returnA SubtitleStream object.
* @throws NumberFormatExceptionIf codec index contains a non-numeric value.
@@ -237,7 +247,8 @@ public final class FFMpegHelper { /** * Parses a list of audio stream parameters to an audio stream object - * @param streamPartsA list of parameters belonging to an audio stream.
+ * + * @param streamPartsA list of parameters belonging to an audio stream.
* @param relativeIndexThe relative index of the audio stream.
* @returnA SubtitleStream object.
* @throws NumberFormatExceptionIf codec index contains a non-numeric value.
@@ -266,9 +277,10 @@ public final class FFMpegHelper { /** * Parses a list of subtitle stream parameters to a subtitle stream object - * @param streamPartsA list of parameters belonging to a subtitle stream.
+ * + * @param streamPartsA list of parameters belonging to a subtitle stream.
* @param relativeIndexThe relative index of the subtitle.
- * @param fileThe file currently being converted.
+ * @param fileThe file currently being converted.
* @returnA SubtitleStream object.
* @throws NumberFormatExceptionIf codec index contains a non-numeric value.
*/ diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java index 281c783..0dfaf1c 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java @@ -16,8 +16,9 @@ public final class FileUtil { /** * Adds parentheses with an integer if the output file already exists + * * @param targetPathThe path the file should ideally be saved at.
- * @param extensionThe extension of the target file.
+ * @param extensionThe extension of the target file.
* @returnA filename guaranteed not to collide with other files.
*/ public static String getNonCollidingFilename(String targetPath, String extension) { @@ -32,6 +33,7 @@ public final class FileUtil { /** * Gets filename without extension from File object + * * @param fileA file object.
* @returnA filename.
*/ @@ -41,6 +43,7 @@ public final class FileUtil { /** * Removes the extension from a file name + * * @param fileA filename.
* @returnA filename without its extension.
*/ @@ -50,15 +53,20 @@ public final class FileUtil { /** * Recursively lists all files in a folder - * @param folderThe folder to start from.
+ * + * @param folderThe folder to start from.
* @param maxRecursionsMaximum number of recursions
- * @return A list of files + * @return A list of files */ public static File[] listFilesRecursive(File folder, String[] extensions, int maxRecursions) { - if (maxRecursions == 0) { return null; } + if (maxRecursions == 0) { + return null; + } File[] listOfFiles = folder.listFiles((file) -> file.isFile() && ListUtil.listContains(extensions, (item) -> file.getName().endsWith(item))); - if (listOfFiles == null) { return null; } + if (listOfFiles == null) { + return null; + } if (maxRecursions > 1) { File[] listOfFolders = folder.listFiles((dir, name) -> new File(dir, name).isDirectory()); if (listOfFolders != null) { @@ -94,6 +102,7 @@ public final class FileUtil { /** * Gets a resource as an InputStream + * * @param resourceNameThe name of the resource you want to read.
* @returnAn input stream which can be used to access the resource.
*/ diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java index 8657e3e..638180e 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java @@ -15,9 +15,10 @@ public final class ListUtil { /** * Combines two arrays to one + * * @param listAThe first array.
* @param listBThe second array.
- * @paramThe type of the two lists.
+ * @paramThe type of the two lists.
* @returnA new array containing all elements from the two arrays.
*/ staticThe list to process.
+ * + * @param listThe list to process.
* @param predicateThe predicate to test.
- * @paramThe type of the list.
+ * @paramThe type of the list.
* @returnA new list containing all matching elements.
*/ staticA list of tokens.
+ * + * @param listA list of tokens.
* @param indexThe index of the token containing comma separated entries.
* @returnA string list.
*/ diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java index efe3413..137d9f6 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java @@ -8,14 +8,15 @@ import java.io.OutputStreamWriter; * A class which helps with outputting information */ public final class OutputUtil { - private static boolean debug; private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); + private static boolean debug; private OutputUtil() { } /** * Sets whether to show debug messages + * * @param debugThe debug message to show.
*/ public static void setDebug(boolean debug) { @@ -24,6 +25,7 @@ public final class OutputUtil { /** * Prints something and a newline to the commandline efficiently + * * @param inputThe text to print.
* @throws IOExceptionIf a write is not possible.
*/ @@ -36,6 +38,7 @@ public final class OutputUtil { /** * Prints a string + * * @param inputThe string to print.
* @throws IOExceptionIf the writer fails to write.
*/ @@ -47,6 +50,7 @@ public final class OutputUtil { /** * Prints a newline + * * @throws IOExceptionIf a write is not possible.
*/ public static void println() throws IOException { @@ -56,6 +60,7 @@ public final class OutputUtil { /** * Closes the writer + * * @throws IOExceptionIf the writer cannot be closed.
*/ public static void close() throws IOException { @@ -64,6 +69,7 @@ public final class OutputUtil { /** * Prints a message if debug messages should be shown + * * @param messageThe debug message to show.
* @throws IOExceptionIf a write is not possible.
*/ diff --git a/src/main/java/net/knarcraft/ffmpegconverter/Parser.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java similarity index 78% rename from src/main/java/net/knarcraft/ffmpegconverter/Parser.java rename to src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java index 0061af3..b561cd5 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/Parser.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java @@ -1,32 +1,42 @@ -package net.knarcraft.ffmpegconverter; +package net.knarcraft.ffmpegconverter.utility; + +import net.knarcraft.ffmpegconverter.parser.ConverterArgument; +import net.knarcraft.ffmpegconverter.parser.ConverterArgumentValue; import java.util.ArrayList; import java.util.List; -public class Parser { +/** + * A class to help with command parsing + */ +public final class Parser { + + private Parser() { + } /** * This function parses command inputs into understandable converter instructions + * * @param tokensA list of tokens containing all arguments
*/ private static void parse(ListA string.
* @returnA list of tokens.
*/ @@ -89,6 +100,7 @@ public class Parser { /** * Checks whether a string builder is empty + * * @param builderThe string builder to check.
* @returnTrue if the string builder is non empty.
*/ diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/StringUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/StringUtil.java index da4590b..48e1dd6 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/StringUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/StringUtil.java @@ -10,9 +10,10 @@ final class StringUtil { /** * Finds all substrings between two substrings in a string + * * @param stringThe string containing the substrings.
- * @param startThe substring before the wanted substring.
- * @param endThe substring after the wanted substring.
+ * @param startThe substring before the wanted substring.
+ * @param endThe substring after the wanted substring.
* @returnA list of all occurrences of the substring.
*/ static String[] stringBetween(String string, String start, String end) {