Package com.compomics.software.settings
Class UtilitiesPathParameters
java.lang.Object
com.compomics.software.settings.UtilitiesPathParameters
This class sets the path preferences for the files to read/write.
- Author:
- Marc Vaudel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum of the paths which can be set in utilities. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a list containing the keys of the paths where the tool is not able to write.static StringReturns the path at the given line.static StringReturns the path id line.static StringgetPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey) Returns the path according to the given key and path.static voidLoads a path to be set from a line.static voidloadPathParametersFromFile(File inputFile) Loads the path preferences from a text file.static voidsetAllPathsIn(String path) Sets all the paths inside a given folder.static voidsetPathParameter(UtilitiesPathParameters.UtilitiesPathKey utilitiesPathKey, String path) Sets the path according to the given key and path.static booleanTests whether it is possible to write in a destination folder.static voidWrites the configuration file using the provided buffered writer.static voidwriteConfigurationToFile(File file) Writes all path configurations to the given file.static voidWrites the path of interest using the provided buffered writer.
-
Field Details
-
configurationFileName
Default name for the path configuration file.- See Also:
-
separator
The separator between a path ID and a path.- See Also:
-
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 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 IOException Writes 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
-