Package com.vaadin.flow.server.frontend
Class JarContentsManager
java.lang.Object
com.vaadin.flow.server.frontend.JarContentsManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsPath(File jar, String filePath) Checks if a jar file contains a path specified (case sensitive).copyFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathExclusions) Copies files from the jar file to the output directory.copyIncludedFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathInclusions) Copies files matching the inclusion filters from the jar file to the output directory.Finds all files (not directories) in the jar with the name specified and in the directory specified.byte[]getFileContents(File jar, String filePath) Tries to find a file by its path (case sensitive) in jar file.
-
Constructor Details
-
JarContentsManager
public JarContentsManager()
-
-
Method Details
-
containsPath
Checks if a jar file contains a path specified (case sensitive).- Parameters:
jar- jar file to look for file in, notnullfilePath- file path relative to jar root, notnull- Returns:
trueif path is contained in the jar,falseotherwise- Throws:
IllegalArgumentException- if jar file specified is not a file or does not existNullPointerException- if any of the arguments is nullUncheckedIOException- ifIOExceptionoccurs during file search, for instance, when jar file specified is not a jar file
-
getFileContents
Tries to find a file by its path (case sensitive) in jar file. If found, its contents is returned,nullotherwise.- Parameters:
jar- jar file to look for file in, notnullfilePath- file path relative to jar root, notnull- Returns:
- an array of bytes, if file was found or
nullif not found - Throws:
IllegalArgumentException- if jar file specified is not a file or does not existNullPointerException- if any of the arguments is nullUncheckedIOException- ifIOExceptionoccurs during file retrieval, for instance, when jar file specified is not a jar file
-
findFiles
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, notnullbaseDirectoryName- the directory to search in the jar, notnullfileName- a string that should required files' paths end with, notnull- 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 existNullPointerException- if any of the arguments is nullUncheckedIOException- ifIOExceptionoccurs 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, notnulljarDirectoryToCopyFrom- a path relative to jar root, only files from this path will be copied, can benull, 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, notnullwildcardPathExclusions- 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 existNullPointerException- if jar file or output directory isnullUncheckedIOException- ifIOExceptionoccurs 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, notnulljarDirectoryToCopyFrom- a path relative to jar root, only files from this path will be copied, can benull, 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, notnullwildcardPathInclusions- 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 existNullPointerException- if jar file or output directory isnullUncheckedIOException- ifIOExceptionoccurs during the operation, for instance, when jar file specified is not a jar file
-