Package org.codehaus.plexus.archiver
Class AbstractUnArchiver
- java.lang.Object
-
- org.codehaus.plexus.archiver.AbstractUnArchiver
-
- All Implemented Interfaces:
FinalizerEnabled
,UnArchiver
- Direct Known Subclasses:
AbstractZipUnArchiver
,BZip2UnArchiver
,GZipUnArchiver
,SnappyUnArchiver
,TarUnArchiver
,XZUnArchiver
,ZstdUnArchiver
public abstract class AbstractUnArchiver extends Object implements UnArchiver, FinalizerEnabled
- Author:
- Emmanuel Venisse
-
-
Constructor Summary
Constructors Constructor Description AbstractUnArchiver()
AbstractUnArchiver(File sourceFile)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addArchiveFinalizer(ArchiveFinalizer finalizer)
protected abstract void
execute()
protected abstract void
execute(String path, File outputDirectory)
void
extract()
Extract the archive.void
extract(String path, File outputDirectory)
Take a path into the archive and extract it to the specified directory.protected void
extractFile(File srcF, File dir, InputStream compressedInputStream, String entryName, Date entryDate, boolean isDirectory, Integer mode, String symlinkDestination, org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)
File
getDestDirectory()
File
getDestFile()
org.codehaus.plexus.components.io.filemappers.FileMapper[]
getFileMappers()
Get chain of components which rewrite the target path of each unpacked file.org.codehaus.plexus.components.io.fileselectors.FileSelector[]
getFileSelectors()
Returns a set ofFileSelector
instances, which may be used to select the files to extract from the archive.protected org.slf4j.Logger
getLogger()
File
getSourceFile()
boolean
isIgnorePermissions()
boolean
isOverwrite()
Gets a flag indicating destination files are always overwritten.protected boolean
isSelected(String fileName, org.codehaus.plexus.components.io.resources.PlexusIoResource fileInfo)
boolean
isUseJvmChmod()
void
setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers)
void
setDestDirectory(File destDirectory)
void
setDestFile(File destFile)
void
setFileMappers(org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)
Sets chain of components to be used for rewriting target path of each unpacked file.void
setFileSelectors(org.codehaus.plexus.components.io.fileselectors.FileSelector[] fileSelectors)
Sets a set ofFileSelector
instances, which may be used to select the files to extract from the archive.void
setIgnorePermissions(boolean ignorePermissions)
void
setOverwrite(boolean b)
Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?void
setSourceFile(File sourceFile)
void
setUseJvmChmod(boolean useJvmChmod)
jvm chmod won't set group level permissions !protected boolean
shouldExtractEntry(File targetDirectory, File targetFileName, String entryName, Date entryDate)
protected void
validate()
protected void
validate(String path, File outputDirectory)
-
-
-
Constructor Detail
-
AbstractUnArchiver
public AbstractUnArchiver()
-
AbstractUnArchiver
public AbstractUnArchiver(File sourceFile)
-
-
Method Detail
-
getLogger
protected org.slf4j.Logger getLogger()
-
getDestDirectory
public File getDestDirectory()
- Specified by:
getDestDirectory
in interfaceUnArchiver
-
setDestDirectory
public void setDestDirectory(File destDirectory)
- Specified by:
setDestDirectory
in interfaceUnArchiver
-
getDestFile
public File getDestFile()
- Specified by:
getDestFile
in interfaceUnArchiver
-
setDestFile
public void setDestFile(File destFile)
- Specified by:
setDestFile
in interfaceUnArchiver
-
getSourceFile
public File getSourceFile()
- Specified by:
getSourceFile
in interfaceUnArchiver
-
setSourceFile
public void setSourceFile(File sourceFile)
- Specified by:
setSourceFile
in interfaceUnArchiver
-
isOverwrite
public boolean isOverwrite()
Description copied from interface:UnArchiver
Gets a flag indicating destination files are always overwritten.- Specified by:
isOverwrite
in interfaceUnArchiver
- Returns:
true
, if destination files are overwritten, even if they are newer than the corresponding entry in the archive.
-
setOverwrite
public void setOverwrite(boolean b)
Description copied from interface:UnArchiver
Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?- Specified by:
setOverwrite
in interfaceUnArchiver
-
getFileMappers
public org.codehaus.plexus.components.io.filemappers.FileMapper[] getFileMappers()
Description copied from interface:UnArchiver
Get chain of components which rewrite the target path of each unpacked file.- Specified by:
getFileMappers
in interfaceUnArchiver
- Returns:
FileMapper
s to be used for rewriting each target path, ornull
if no rewriting shall happen.
-
setFileMappers
public void setFileMappers(org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)
Description copied from interface:UnArchiver
Sets chain of components to be used for rewriting target path of each unpacked file.- Specified by:
setFileMappers
in interfaceUnArchiver
- Parameters:
fileMappers
-FileMapper
to be used for rewriting each target path, ornull
if no rewriting shall happen.
-
extract
public final void extract() throws ArchiverException
Description copied from interface:UnArchiver
Extract the archive.- Specified by:
extract
in interfaceUnArchiver
- Throws:
ArchiverException
-
extract
public final void extract(String path, File outputDirectory) throws ArchiverException
Description copied from interface:UnArchiver
Take a path into the archive and extract it to the specified directory.- Specified by:
extract
in interfaceUnArchiver
- Parameters:
path
- Path inside the archive to be extracted.outputDirectory
- Directory to extract to.- Throws:
ArchiverException
-
addArchiveFinalizer
public void addArchiveFinalizer(ArchiveFinalizer finalizer)
- Specified by:
addArchiveFinalizer
in interfaceFinalizerEnabled
-
setArchiveFinalizers
public void setArchiveFinalizers(List<ArchiveFinalizer> archiveFinalizers)
- Specified by:
setArchiveFinalizers
in interfaceFinalizerEnabled
-
validate
protected void validate() throws ArchiverException
- Throws:
ArchiverException
-
setFileSelectors
public void setFileSelectors(org.codehaus.plexus.components.io.fileselectors.FileSelector[] fileSelectors)
Description copied from interface:UnArchiver
Sets a set ofFileSelector
instances, which may be used to select the files to extract from the archive. If file selectors are present, then a file is only extracted, if it is confirmed by all file selectors.- Specified by:
setFileSelectors
in interfaceUnArchiver
-
getFileSelectors
public org.codehaus.plexus.components.io.fileselectors.FileSelector[] getFileSelectors()
Description copied from interface:UnArchiver
Returns a set ofFileSelector
instances, which may be used to select the files to extract from the archive. If file selectors are present, then a file is only extracted, if it is confirmed by all file selectors.- Specified by:
getFileSelectors
in interfaceUnArchiver
-
isSelected
protected boolean isSelected(String fileName, org.codehaus.plexus.components.io.resources.PlexusIoResource fileInfo) throws ArchiverException
- Throws:
ArchiverException
-
execute
protected abstract void execute() throws ArchiverException
- Throws:
ArchiverException
-
execute
protected abstract void execute(String path, File outputDirectory) throws ArchiverException
- Throws:
ArchiverException
-
isUseJvmChmod
public boolean isUseJvmChmod()
- Specified by:
isUseJvmChmod
in interfaceUnArchiver
- Returns:
- Since:
- 1.1
-
setUseJvmChmod
public void setUseJvmChmod(boolean useJvmChmod)
jvm chmod won't set group level permissions !- Specified by:
setUseJvmChmod
in interfaceUnArchiver
- Since:
- 1.1
-
isIgnorePermissions
public boolean isIgnorePermissions()
- Specified by:
isIgnorePermissions
in interfaceUnArchiver
- Since:
- 1.1
-
setIgnorePermissions
public void setIgnorePermissions(boolean ignorePermissions)
- Specified by:
setIgnorePermissions
in interfaceUnArchiver
- Since:
- 1.1
-
extractFile
protected void extractFile(File srcF, File dir, InputStream compressedInputStream, String entryName, Date entryDate, boolean isDirectory, Integer mode, String symlinkDestination, org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers) throws IOException, ArchiverException
- Throws:
IOException
ArchiverException
-
shouldExtractEntry
protected boolean shouldExtractEntry(File targetDirectory, File targetFileName, String entryName, Date entryDate) throws IOException
- Throws:
IOException
-
-