<commit_before>package file;

import files.FileInput;
import misc.Logger;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;

public class ConfigHandler {
    /** The name of the configuration file. */
    private static final String FILENAME_CONFIG = "config.ini";

    public static final String[] FFMPEG_LOG_LEVELS = {"quiet", "panic", "fatal", "error", "warning", "info", "verbose", "debug", "trace"};

    /** The absolute path to ffmpeg/ffmpeg.exe. */
    private String ffmpegPath;
    /** The absolute path to 7zip/7zip.exe or whichever compression program is specified. */
    private String compressionProgramPath;

    /** The path of  both the archived and encoded files. */
    private String encodedFilePath;

    /** The format to encode to. */
    private String encodeFormat = "mkv";
    /** The format to decode to. */
    private String decodeFormat = "7z";

    /** The width, in pixels, of the encoded video. */
    private int encodedVideoWidth = 1280;
    /** The height, in pixels, of the encoded video. */
    private int encodedVideoHeight = 720;
    /** The framerate of the video. Ex ~ 30fps, 60fps, etc... */
    private int encodedFramerate = 30;
    /** The size of each frame of video in bytes. */
    private int frameSize;
    /** The width/height of each encoded macroblock. */
    private int macroBlockDimensions = 8;
    /** The codec to encode/decode the video with. */
    private String encodingLibrary = "libvpx";
    /** The level of information that should be given by ffmpeg while ffmpeg is running. */
    private String ffmpegLogLevel = "info";

    /** Whether or not to ignore all other ffmpeg options and to use the fullyCustomFfmpegEncodingOptions and fullyCustomFfmpegDecodingOptions instead. */
    private boolean useFullyCustomFfmpegOptions = false;
    /** The user-entered command line arguments to use when encoding with ffmpeg. */
    private String fullyCustomFfmpegEncodingOptions = "";
    /** The user-entered command line arguments to use when encoding with ffmpeg. */
    private String fullyCustomFfmpegDecodingOptions = "";

    /** Whether or not to delete the original file after encoding. */
    private boolean deleteOriginalFileWhenEncoding = false;
    /** whether or not to delete the original file after decoding. */
    private boolean deleteOriginalFileWhenDecoding = false;
    /** Whether or not to pack all of the currently selected files into a single archive before encoding. */
    private boolean combineAllFilesIntoSingleArchive = false;
    /** Whether or not to pack every file into it's own individual archive before encoding each file individually. */
    private boolean combineIntoIndividualArchives = false;

    /** Whether or not to show the splash screen on startup. */
    private boolean showSplashScreen = true;
    /** The absolute path to the splash screen to display. */
    private String splashScreenFilePath = "Splash.png";
    /** The amount of time, in milliseconds, to display the splash screen. */
    private int splashScreenDisplayTime = 3000;

    /** The base commands to use when compressing a file before encoding. */
    private String compressionCommands = "a -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on";

    /** @return Whether or not the config file exists. */
    public boolean doesConfigFileExist() {
        return Files.exists(Paths.get(FILENAME_CONFIG));
    }

    /**
     * Reads in each line from the configuration file and attempts to parse
     * the specified parameters of the program.
     *
     * If a line cannot be parsed, then a warning is logged.
     */
    public void loadConfigSettings() {
        calculateFrameSize();

        try {
            List<String> lines = FileInput.readEntireFile(Paths.get(FILENAME_CONFIG), true);
            Iterator<String> it = lines.iterator();


            while(it.hasNext()) {
                String currentLine = it.next();

                if(currentLine.contains("ffmpegPath ")) {
                    ffmpegPath = currentLine.replace("ffmpegPath ", "");
                }

                if(currentLine.contains("compressionProgramPath ")) {
                    compressionProgramPath = currentLine.replace("compressionProgramPath ", "");
                }

                if(currentLine.contains("encodeFormat ")) {
                    encodeFormat = currentLine.replace("encodeFormat ", "");
                }

                if(currentLine.contains("decodeFormat ")) {
                    decodeFormat = currentLine.replace("decodeFormat ", "");
                }

                if(currentLine.contains("encodedVideoWidth ")) {
                    encodedVideoWidth = Integer.valueOf(currentLine.replace("encodedVideoWidth ", ""));
                }

                if(currentLine.contains("encodedVideoHeight ")) {
                    encodedVideoHeight = Integer.valueOf(currentLine.replace("encodedVideoHeight ", ""));
                }

                if(currentLine.contains("encodedFramerate ")) {
                    encodedFramerate = Integer.valueOf(currentLine.replace("encodedFramerate ", ""));
                }<commit_msg>Added documentation to one of the class variables.<commit_after>package file;

import files.FileInput;
import misc.Logger;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class ConfigHandler {
    /** The name of the configuration file. */
    private static final String FILENAME_CONFIG = "config.ini";

    /** The logging levels supported by FFMPEG as of 2015/Nov/1. */
    public static final String[] FFMPEG_LOG_LEVELS = {"quiet", "panic", "fatal", "error", "warning", "info", "verbose", "debug", "trace"};

    /** The absolute path to ffmpeg/ffmpeg.exe. */
    private String ffmpegPath;
    /** The absolute path to 7zip/7zip.exe or whichever compression program is specified. */
    private String compressionProgramPath;

    /** The path of  both the archived and encoded files. */
    private String encodedFilePath;

    /** The format to encode to. */
    private String encodeFormat = "mkv";
    /** The format to decode to. */
    private String decodeFormat = "7z";

    /** The width, in pixels, of the encoded video. */
    private int encodedVideoWidth = 1280;
    /** The height, in pixels, of the encoded video. */
    private int encodedVideoHeight = 720;
    /** The framerate of the video. Ex ~ 30fps, 60fps, etc... */
    private int encodedFramerate = 30;
    /** The size of each frame of video in bytes. */
    private int frameSize;
    /** The width/height of each encoded macroblock. */
    private int macroBlockDimensions = 8;
    /** The codec to encode/decode the video with. */
    private String encodingLibrary = "libvpx";
    /** The level of information that should be given by ffmpeg while ffmpeg is running. */
    private String ffmpegLogLevel = "info";

    /** Whether or not to ignore all other ffmpeg options and to use the fullyCustomFfmpegEncodingOptions and fullyCustomFfmpegDecodingOptions instead. */
    private boolean useFullyCustomFfmpegOptions = false;
    /** The user-entered command line arguments to use when encoding with ffmpeg. */
    private String fullyCustomFfmpegEncodingOptions = "";
    /** The user-entered command line arguments to use when encoding with ffmpeg. */
    private String fullyCustomFfmpegDecodingOptions = "";

    /** Whether or not to delete the original file after encoding. */
    private boolean deleteOriginalFileWhenEncoding = false;
    /** whether or not to delete the original file after decoding. */
    private boolean deleteOriginalFileWhenDecoding = false;
    /** Whether or not to pack all of the currently selected files into a single archive before encoding. */
    private boolean combineAllFilesIntoSingleArchive = false;
    /** Whether or not to pack every file into it's own individual archive before encoding each file individually. */
    private boolean combineIntoIndividualArchives = false;

    /** Whether or not to show the splash screen on startup. */
    private boolean showSplashScreen = true;
    /** The absolute path to the splash screen to display. */
    private String splashScreenFilePath = "Splash.png";
    /** The amount of time, in milliseconds, to display the splash screen. */
    private int splashScreenDisplayTime = 3000;

    /** The base commands to use when compressing a file before encoding. */
    private String compressionCommands = "a -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on";

    /** @return Whether or not the config file exists. */
    public boolean doesConfigFileExist() {
        return Files.exists(Paths.get(FILENAME_CONFIG));
    }

    /**
     * Reads in each line from the configuration file and attempts to parse
     * the specified parameters of the program.
     *
     * If a line cannot be parsed, then a warning is logged.
     */
    public void loadConfigSettings() {
        calculateFrameSize();

        try {
            List<String> lines = FileInput.readEntireFile(Paths.get(FILENAME_CONFIG), true);


            for(String currentLine : lines) {
                if(currentLine.contains("ffmpegPath ")) {
                    ffmpegPath = currentLine.replace("ffmpegPath ", "");
                }

                if(currentLine.contains("compressionProgramPath ")) {
                    compressionProgramPath = currentLine.replace("compressionProgramPath ", "");
                }

                if(currentLine.contains("encodeFormat ")) {
                    encodeFormat = currentLine.replace("encodeFormat ", "");
                }

                if(currentLine.contains("decodeFormat ")) {
                    decodeFormat = currentLine.replace("decodeFormat ", "");
                }

                if(currentLine.contains("encodedVideoWidth ")) {
                    encodedVideoWidth = Integer.valueOf(currentLine.replace("encodedVideoWidth ", ""));
                }

                if(currentLine.contains("encodedVideoHeight ")) {
                    encodedVideoHeight = Integer.valueOf(currentLine.replace("encodedVideoHeight ", ""));
                }

                if(currentLine.contains("encodedFramerate ")) {
                    encodedFramerate = Integer.valueOf(currentLine.replace("encodedFramerate ", ""));
                }
{'fraction_non_alphanumeric': 0.09672328970574584, 'fraction_numerical': 0.005847953216374269, 'mean_word_length': 2.754006968641115, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2749203', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2663, 'n_words': 922}