Package com.compomics.software.settings
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UtilitiesPathParameters.UtilitiesPathKey
Enum of the paths which can be set in utilities. -
Field Summary
Fields Modifier and Type Field Description static String
configurationFileName
Default name for the path configuration file.static String
defaultPath
Replacement for the path when not available.static String
separator
The separator between a path ID and a path. -
Constructor Summary
Constructors Constructor Description UtilitiesPathParameters()
Empty default constructor. -
Method Summary
Modifier and Type Method Description static ArrayList<PathKey>
getErrorKeys()
Returns a list containing the keys of the paths where the tool is not able to write.static String
getPath(String line)
Returns the path at the given line.static String
getPathID(String line)
Returns the path id line.static String
getPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey)
Returns the path according to the given key and path.static void
loadPathParameterFromLine(String line)
Loads a path to be set from a line.static void
loadPathParametersFromFile(File inputFile)
Loads the path preferences from a text file.static void
setAllPathsIn(String path)
Sets all the paths inside a given folder.static void
setPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey, String path)
Sets the path according to the given key and path.static boolean
testPath(String destinationPath)
Tests whether it is possible to write in a destination folder.static void
writeConfigurationToFile(BufferedWriter bw)
Writes the configuration file using the provided buffered writer.static void
writeConfigurationToFile(File file)
Writes all path configurations to the given file.static void
writePathToFile(BufferedWriter bw, UtilitiesPathParameters.UtilitiesPathKey pathKey)
Writes the path of interest using the provided buffered writer.
-
Field Details
-
configurationFileName
Default name for the path configuration file.- See Also:
- Constant Field Values
-
separator
The separator between a path ID and a path.- See Also:
- Constant Field Values
-
defaultPath
Replacement for the path when not available.- See Also:
- Constant Field Values
-
-
Constructor Details
-
UtilitiesPathParameters
public UtilitiesPathParameters()Empty default constructor.
-
-
Method Details
-
loadPathParametersFromFile
public static void loadPathParametersFromFile(File inputFile) throws FileNotFoundException, IOExceptionLoads the path preferences from a text file.- Parameters:
inputFile
- the file to load the path preferences from- Throws:
FileNotFoundException
- if a FileNotFoundException occursIOException
- if an IOException occurs
-
loadPathParameterFromLine
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 pathpath
- the path to be set
-
getPathParameter
Returns the path according to the given key and path.- Parameters:
utilitiesPathKey
- the key of the path- Returns:
- the path to be set
-
getPathID
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
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
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
Writes all path configurations to the given file.- Parameters:
file
- the destination file- Throws:
IOException
- if an IOException occurs
-
writeConfigurationToFile
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 IOExceptionWrites the path of interest using the provided buffered writer.- Parameters:
bw
- the writer to use for writingpathKey
- the key of the path of interest- Throws:
IOException
- if an IOException occurs
-
testPath
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
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
-