Package 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 Summary
Constructors Constructor Description JarContentsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsPath(File jar, String filePath)Checks if a jar file contains a path specified (case sensitive).voidcopyFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathExclusions)Copies files from the jar file to the output directory.voidcopyIncludedFilesFromJarTrimmingBasePath(File jar, String jarDirectoryToCopyFrom, File outputDirectory, String... wildcardPathInclusions)Copies files matching the inclusion filters from the jar file to the output directory.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.byte[]getFileContents(File jar, String filePath)Tries to find a file by its path (case sensitive) in jar file.
-
-
-
Method Detail
-
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, 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
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,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
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, 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 void 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- 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 void 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- 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
-
-