Package jetbrains.buildServer.zip
Class DiskBasedCenZipFactory
- java.lang.Object
-
- jetbrains.buildServer.zip.BigFileZipFactory
-
- jetbrains.buildServer.zip.DiskBasedCenZipFactory
-
- All Implemented Interfaces:
ZipFactory
public final class DiskBasedCenZipFactory extends BigFileZipFactory
Overrides
ZipFactory.createZipArchive(String)
to return a customZipWriter
which conserves memory by storing the metadata of its ZIP entries (needed to write CEN, the ZIP central directory) in a temporary file.- Since:
- 2017.2.4, 2018.1
- Author:
- Andrey Shcheglov <mailto:andrey.shcheglov@jetbrains.com>
- See Also:
MemoryConservativeZipFactory
-
-
Field Summary
-
Fields inherited from class jetbrains.buildServer.zip.BigFileZipFactory
COMMONS_COMPRESS, CONSERVATIVE, DISK_BASED
-
-
Constructor Summary
Constructors Constructor Description DiskBasedCenZipFactory(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new ZIP factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZipWriter
createZipArchive(String name)
Creates a zip archive.boolean
isFileExist(String name)
Checks whether the file exists.protected ZipWriter
makeNewZipWriter(File file)
ZipReader
openZipArchive(String name)
Opens an existent zip archive to read.void
rename(String sourceName, String targetName)
Renames or moves the file.void
setLevel(int level)
Sets the compression level for entries which areZipEntry.DEFLATED
.String
toString()
-
Methods inherited from class jetbrains.buildServer.zip.BigFileZipFactory
makeNewZipReader, newInstance, newSharedInstance
-
-
-
-
Constructor Detail
-
DiskBasedCenZipFactory
public DiskBasedCenZipFactory(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new ZIP factory.
- Parameters:
autoCreateDirectories
- whether directories parent to the target ZIP file should be automatically created (only affectsZipFactory.createZipArchive(String)
behaviour).rewriteExistingFiles
- whether the target ZIP file should be silently overwritten if it exists (only affectsZipFactory.createZipArchive(String)
behaviour).
-
-
Method Detail
-
makeNewZipWriter
@NotNull protected ZipWriter makeNewZipWriter(@NotNull File file) throws IOException
- Overrides:
makeNewZipWriter
in classBigFileZipFactory
- Throws:
IOException
- See Also:
BigFileZipFactory.makeNewZipWriter(File)
-
createZipArchive
@NotNull public final ZipWriter createZipArchive(@NotNull String name) throws IOException
Creates a zip archive.- Specified by:
createZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip writer.
- Throws:
IOException
- See Also:
ZipFactory.createZipArchive(String)
-
openZipArchive
public ZipReader openZipArchive(String name) throws IOException, IllegalStateException
Description copied from interface:ZipFactory
Opens an existent zip archive to read.- Specified by:
openZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip reader.
- Throws:
IOException
IllegalStateException
-
isFileExist
public boolean isFileExist(String name)
Description copied from interface:ZipFactory
Checks whether the file exists.- Specified by:
isFileExist
in interfaceZipFactory
- Parameters:
name
- file path and name.- Returns:
- exists.
-
rename
public void rename(String sourceName, String targetName) throws IOException
Description copied from interface:ZipFactory
Renames or moves the file.- Specified by:
rename
in interfaceZipFactory
- Parameters:
sourceName
- an existent file path and name to rename.targetName
- new path and name.- Throws:
IOException
- when couldn't rename.
-
setLevel
public final void setLevel(int level)
Sets the compression level for entries which are
ZipEntry.DEFLATED
. The default setting isDeflater.DEFAULT_COMPRESSION
.This method only affects
ZipFactory.createZipArchive(String)
behaviour.- Specified by:
setLevel
in interfaceZipFactory
- Parameters:
level
- the compression level (0-9).- See Also:
ZipFactory.setLevel(int)
-
toString
public final String toString()
- Overrides:
toString
in classObject
- Since:
- 2017.2.4, 2018.1
- See Also:
Object.toString()
-
-