Class FileHelper

java.lang.Object
org.palladiosimulator.commons.eclipseutils.FileHelper

public final class FileHelper extends Object
Helper class for coping with files, especially residing within plug-ins.
  • Method Details

    • getFile

      public static File getFile(String path)
      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

      public static File[] getFiles(File folder)
      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

      public static File[] getFiles(File folder, String fileExtension)
      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

      public static File[] getFiles(String path)
      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

      public static File[] getFiles(String path, String fileExtension)
      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

      public static URI[] getURIs(String path, String fileExtension)
      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

      public static File getPluginJarFile(String pluginID)
      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

      public static String getPluginJarFileName(String pluginID)
      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

      public static File packageToPluginJar(File directory, File targetJarFile)
      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