Class FileHelper
java.lang.Object
org.palladiosimulator.commons.eclipseutils.FileHelper
Helper class for coping with files, especially residing within plug-ins.
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
Gets a file object of the given path represented as String.static File[]
Gets all files from a given folder.static File[]
Gets all files from a given folder, filtered by the given file extension.static File[]
Gets all files from a given folder.static File[]
Gets all files from a given folder, filtered by the given file extension.static File
getPluginJarFile
(String pluginID) Returns the JAR file corresponding to the given plug-in ID from the current Eclipse platform.static String
getPluginJarFileName
(String pluginID) Returns the name of the JAR file corresponding to the given plug-in ID from the current Eclipse platform.static URI[]
Gets all URIs to files of a given folder, filtered by the given file extension.static File
packageToPluginJar
(File directory, File targetJarFile) Packages the class files within a given directory into a JAR file.
-
Method Details
-
getFile
Gets a file object of the given path represented as String. Works even if the file comes from a plug-in packaged in a jar file.- Parameters:
path
- The path to load. Can use URIs starting with "platform:/", e.g., pointing to files within plug-ins ("platform:/plugin").- Returns:
- The file object to be returned.
-
getFiles
Gets all files from a given folder.- Parameters:
folder
- File object pointing to the folder to load.- Returns:
- Array of files within the given folder.
-
getFiles
Gets all files from a given folder, filtered by the given file extension.- Parameters:
folder
- File object pointing to the folder to load.fileExtension
- Filter for files; only files with the given extension are returned.- Returns:
- Array of files within the given folder and with the given file extension.
-
getFiles
Gets all files from a given folder.- Parameters:
folder
- String-representation pointing to the folder to load.- Returns:
- Array of files within the given folder.
-
getFiles
Gets all files from a given folder, filtered by the given file extension.- Parameters:
folder
- String-representation pointing to the folder to load.fileExtension
- Filter for files; only files with the given extension are returned.- Returns:
- Array of files within the given folder and with the given file extension.
-
getURIs
Gets all URIs to files of a given folder, filtered by the given file extension.- Parameters:
folder
- String-representation pointing to the folder to load.fileExtension
- Filter for files; only files with the given extension are returned.- Returns:
- Array of files within the given folder and with the given file extension.
-
getPluginJarFile
Returns the JAR file corresponding to the given plug-in ID from the current Eclipse platform. In case the referenced plug-in is available as directory rather than as JAR file, a file-handle to this directory is returned.- Parameters:
pluginID
- Plug-in ID for of the Jar file to be loaded- Returns:
- the plug-in's Jar file
-
getPluginJarFileName
Returns the name of the JAR file corresponding to the given plug-in ID from the current Eclipse platform.- Parameters:
pluginID
- Plug-in ID for of the Jar file to be loaded- Returns:
- the plug-in's Jar file
-
packageToPluginJar
Packages the class files within a given directory into a JAR file. The folder structure is maintained.- Parameters:
directory
- the directory to be packaged.- Returns:
- a JAR file handle
-