You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.server.frontend.

Class JarContentsManager

java.lang.Object
com.vaadin.flow.server.frontend.JarContentsManager
public class JarContentsManager extends Object

Shared code for managing contents of jar files.

For internal use only. May be renamed or removed in a future release.

Since:

1.0.

Author:

Vaadin Ltd

  • Constructor Details

    • JarContentsManager

      public JarContentsManager()
  • Method Details

    • containsPath

      public boolean containsPath(File jar, String filePath)

      Checks if a jar file contains a path specified (case sensitive).

      Parameters:

      jar - jar file to look for file in, not null

      filePath - file path relative to jar root, not null

      Returns:

      true if path is contained in the jar, false otherwise

      Throws:

      IllegalArgumentException - if jar file specified is not a file or does not exist

      NullPointerException - if any of the arguments is null

      UncheckedIOException - if IOException occurs during file search, for instance, when jar file specified is not a jar file

    • getFileContents

      public byte[] getFileContents(File jar, String filePath)

      Tries to find a file by its path (case sensitive) in jar file. If found, its contents is returned, null otherwise.

      Parameters:

      jar - jar file to look for file in, not null

      filePath - file path relative to jar root, not null

      Returns:

      an array of bytes, if file was found or null if not found

      Throws:

      IllegalArgumentException - if jar file specified is not a file or does not exist

      NullPointerException - if any of the arguments is null

      UncheckedIOException - if IOException occurs during file retrieval, for instance, when jar file specified is not a jar file

    • findFiles

      public List<String> findFiles(File jar, String baseDirectoryName, String fileName)

      Finds all files (not directories) in the jar with the name specified and in the directory specified.

      Parameters:

      jar - jar file to look for file in, not null

      baseDirectoryName - the directory to search in the jar, not null

      fileName - a string that should required files' paths end with, not null

      Returns:

      list of files from the directory specified with required file names

      Throws:

      IllegalArgumentException - if jar file specified is not a file or does not exist

      NullPointerException - if any of the arguments is null

      UncheckedIOException - if IOException occurs during jar file search

    • copyFilesFromJarTrimmingBasePath

      public Set<String> copyFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathExclusions)

      Copies files from the jar file to the output directory.

      Parameters:

      jar - jar file to look for files in, not null

      jarDirectoryToCopyFrom - a path relative to jar root, only files from this path will be copied, can be null, which is treated as a root of the jar. Files will be copied relative to this path (i.e. only path part after this path is preserved in output directory)

      outputDirectory - the directory to copy files to, not null

      wildcardPathExclusions - wildcard exclusions that are used to check each path against before copying

      Returns:

      names of the files that were either copied or already existed in the output directory

      Throws:

      IllegalArgumentException - if jar file specified is not a file or does not exist or if output directory is not a directory or does not exist

      NullPointerException - if jar file or output directory is null

      UncheckedIOException - if IOException occurs during the operation, for instance, when jar file specified is not a jar file

    • copyIncludedFilesFromJarTrimmingBasePath

      public Set<String> copyIncludedFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathInclusions)

      Copies files matching the inclusion filters from the jar file to the output directory.

      Parameters:

      jar - jar file to look for files in, not null

      jarDirectoryToCopyFrom - a path relative to jar root, only files from this path will be copied, can be null, which is treated as a root of the jar. Files will be copied relative to this path (i.e. only path part after this path is preserved in output directory)

      outputDirectory - the directory to copy files to, not null

      wildcardPathInclusions - wildcard inclusions that are used to check each path against before copying

      Returns:

      names of the files that were either copied or already existed in the output directory

      Throws:

      IllegalArgumentException - if jar file specified is not a file or does not exist or if output directory is not a directory or does not exist

      NullPointerException - if jar file or output directory is null

      UncheckedIOException - if IOException occurs during the operation, for instance, when jar file specified is not a jar file