com.vaadin.flow.server.frontend.
Class 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 TypeMethodDescriptionboolean
containsPath
(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, notnull
filePath
- file path relative to jar root, notnull
Returns:
true
if path is contained in the jar,false
otherwiseThrows:
IllegalArgumentException
- if jar file specified is not a file or does not existNullPointerException
- if any of the arguments is nullUncheckedIOException
- ifIOException
occurs 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,
null
otherwise.Parameters:
jar
- jar file to look for file in, notnull
filePath
- file path relative to jar root, notnull
Returns:
an array of bytes, if file was found or
null
if not foundThrows:
IllegalArgumentException
- if jar file specified is not a file or does not existNullPointerException
- if any of the arguments is nullUncheckedIOException
- ifIOException
occurs 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, notnull
baseDirectoryName
- the directory to search in the jar, notnull
fileName
- 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
- ifIOException
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, notnull
jarDirectoryToCopyFrom
- 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, notnull
wildcardPathExclusions
- wildcard exclusions that are used to check each path against before copyingReturns:
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 isnull
UncheckedIOException
- ifIOException
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, notnull
jarDirectoryToCopyFrom
- 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, notnull
wildcardPathInclusions
- wildcard inclusions that are used to check each path against before copyingReturns:
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 isnull
UncheckedIOException
- ifIOException
occurs during the operation, for instance, when jar file specified is not a jar file
-