Class UtilitiesPathParameters

java.lang.Object
com.compomics.software.settings.UtilitiesPathParameters

public class UtilitiesPathParameters extends Object
This class sets the path preferences for the files to read/write.
Author:
Marc Vaudel
  • Field Details

    • configurationFileName

      public static final String configurationFileName
      Default name for the path configuration file.
      See Also:
    • separator

      public static final String separator
      The separator between a path ID and a path.
      See Also:
    • defaultPath

      public static final String defaultPath
      Replacement for the path when not available.
      See Also:
  • Constructor Details

    • UtilitiesPathParameters

      public UtilitiesPathParameters()
      Empty default constructor.
  • Method Details

    • loadPathParametersFromFile

      public static void loadPathParametersFromFile(File inputFile) throws FileNotFoundException, IOException
      Loads the path preferences from a text file.
      Parameters:
      inputFile - the file to load the path preferences from
      Throws:
      FileNotFoundException - if a FileNotFoundException occurs
      IOException - if an IOException occurs
    • loadPathParameterFromLine

      public static void loadPathParameterFromLine(String line) throws FileNotFoundException
      Loads a path to be set from a line.
      Parameters:
      line - the line where to read the path from
      Throws:
      FileNotFoundException - if a FileNotFoundException occurs
    • setPathParameter

      public static void setPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey, String path)
      Sets the path according to the given key and path.
      Parameters:
      utilitiesPathKey - the key of the path
      path - the path to be set
    • getPathParameter

      public static String getPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey)
      Returns the path according to the given key and path.
      Parameters:
      utilitiesPathKey - the key of the path
      Returns:
      the path to be set
    • getPathID

      public static String getPathID(String line)
      Returns the path id line. An empty string if the separator is not found.
      Parameters:
      line - the line of interest
      Returns:
      the id of the path
    • getPath

      public static String getPath(String line)
      Returns the path at the given line. An empty string if the separator or the path is not found.
      Parameters:
      line - the line
      Returns:
      the path after the separator
    • setAllPathsIn

      public static void setAllPathsIn(String path) throws FileNotFoundException
      Sets all the paths inside a given folder.
      Parameters:
      path - the path of the folder where to redirect all paths.
      Throws:
      FileNotFoundException - if a FileNotFoundException occurs
    • writeConfigurationToFile

      public static void writeConfigurationToFile(File file) throws IOException
      Writes all path configurations to the given file.
      Parameters:
      file - the destination file
      Throws:
      IOException - if an IOException occurs
    • writeConfigurationToFile

      public static void writeConfigurationToFile(BufferedWriter bw) throws IOException
      Writes the configuration file using the provided buffered writer.
      Parameters:
      bw - the writer to use for writing
      Throws:
      IOException - if an IOException occurs
    • writePathToFile

      public static void writePathToFile(BufferedWriter bw, UtilitiesPathParameters.UtilitiesPathKey pathKey) throws IOException
      Writes the path of interest using the provided buffered writer.
      Parameters:
      bw - the writer to use for writing
      pathKey - the key of the path of interest
      Throws:
      IOException - if an IOException occurs
    • testPath

      public static boolean testPath(String destinationPath)
      Tests whether it is possible to write in a destination folder.
      Parameters:
      destinationPath - the folder to test
      Returns:
      a boolean indicating whether it is possible to write in the destination folder
    • getErrorKeys

      public static ArrayList<PathKey> getErrorKeys() throws IOException
      Returns a list containing the keys of the paths where the tool is not able to write.
      Returns:
      a list containing the keys of the paths where the tool is not able to write
      Throws:
      IOException - exception thrown whenever an error occurred while loading the path configuration