Package net.lingala.zip4j.model
Class ZipParameters
- java.lang.Object
-
- net.lingala.zip4j.model.ZipParameters
-
public class ZipParameters extends java.lang.Object
Encapsulates the parameters that that control how Zip4J encodes data
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ZipParameters.SymbolicLinkAction
Indicates the action to take when a symbolic link is added to the ZIP file
-
Field Summary
Fields Modifier and Type Field Description private AesKeyStrength
aesKeyStrength
private AesVersion
aesVersion
private CompressionLevel
compressionLevel
private CompressionMethod
compressionMethod
private java.lang.String
defaultFolderPath
private boolean
encryptFiles
private EncryptionMethod
encryptionMethod
private long
entryCRC
private long
entrySize
private ExcludeFileFilter
excludeFileFilter
private java.lang.String
fileComment
private java.lang.String
fileNameInZip
private boolean
includeRootFolder
private long
lastModifiedFileTime
private boolean
overrideExistingFilesInZip
private boolean
readHiddenFiles
private boolean
readHiddenFolders
private java.lang.String
rootFolderNameInZip
private ZipParameters.SymbolicLinkAction
symbolicLinkAction
private boolean
unixMode
private boolean
writeExtendedLocalFileHeader
-
Constructor Summary
Constructors Constructor Description ZipParameters()
Create a ZipParameters instance with default values; CompressionMethod.DEFLATE, CompressionLevel.NORMAL, EncryptionMethod.NONE, AesKeyStrength.KEY_STRENGTH_256, AesVerson.Two, SymbolicLinkAction.INCLUDE_LINKED_FILE_ONLY, readHiddenFiles is true, readHiddenFolders is true, includeRootInFolder is true, writeExtendedLocalFileHeader is true, overrideExistingFilesInZip is trueZipParameters(ZipParameters zipParameters)
Create a clone of given ZipParameters instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AesKeyStrength
getAesKeyStrength()
Get the key strength of the AES encryption keyAesVersion
getAesVersion()
Get the AES format version used for encryptionCompressionLevel
getCompressionLevel()
Get the compression level used to compress filesCompressionMethod
getCompressionMethod()
Get the compression method specified in this ZipParametersjava.lang.String
getDefaultFolderPath()
EncryptionMethod
getEncryptionMethod()
Get the encryption method used to encrypt fileslong
getEntryCRC()
long
getEntrySize()
ExcludeFileFilter
getExcludeFileFilter()
Returns the file exclusion filter that is currently being used when adding files/folders to zip filejava.lang.String
getFileComment()
Get the file commentjava.lang.String
getFileNameInZip()
long
getLastModifiedFileTime()
Get the last modified time to be used for files written to the ZIPjava.lang.String
getRootFolderNameInZip()
ZipParameters.SymbolicLinkAction
getSymbolicLinkAction()
Get the behavior when adding a symbolic linkboolean
isEncryptFiles()
Test if files files are to be encryptedboolean
isIncludeRootFolder()
Test if the parent folder of the added files will be included in the ZIPboolean
isOverrideExistingFilesInZip()
boolean
isReadHiddenFiles()
Test if hidden files will be included during folder recursionboolean
isReadHiddenFolders()
Test if hidden folders will be included during folder recursionboolean
isUnixMode()
Returns true if zip4j is using unix mode as default.boolean
isWriteExtendedLocalFileHeader()
void
setAesKeyStrength(AesKeyStrength aesKeyStrength)
Set the key strength of the AES encryption keyvoid
setAesVersion(AesVersion aesVersion)
Set the AES format version to use for encryptionvoid
setCompressionLevel(CompressionLevel compressionLevel)
Set the compression level used to compress filesvoid
setCompressionMethod(CompressionMethod compressionMethod)
Set the ZIP compression methodvoid
setDefaultFolderPath(java.lang.String defaultFolderPath)
void
setEncryptFiles(boolean encryptFiles)
Set the flag indicating that files are to be encryptedvoid
setEncryptionMethod(EncryptionMethod encryptionMethod)
Set the encryption method used to encrypt filesvoid
setEntryCRC(long entryCRC)
void
setEntrySize(long entrySize)
void
setExcludeFileFilter(ExcludeFileFilter excludeFileFilter)
Set a filter to exclude any files from the list of files being added to zip.void
setFileComment(java.lang.String fileComment)
Set the file commentvoid
setFileNameInZip(java.lang.String fileNameInZip)
Set the filename that will be used to include a file into the ZIP file to a different name that given by the source filename added to the ZIP file.void
setIncludeRootFolder(boolean includeRootFolder)
Set the flag to indicate if the parent folder of added files will be included in the ZIPvoid
setLastModifiedFileTime(long lastModifiedFileTime)
Set the last modified time recorded in the ZIP file for the added files.void
setOverrideExistingFilesInZip(boolean overrideExistingFilesInZip)
Set the behavior if a file is added that already exists in the ZIP.void
setReadHiddenFiles(boolean readHiddenFiles)
Indicate if hidden files will be included during folder recursionvoid
setReadHiddenFolders(boolean readHiddenFolders)
Indicate if hidden folders will be included during folder recursionvoid
setRootFolderNameInZip(java.lang.String rootFolderNameInZip)
Set the folder name that will be prepended to the filename in the ZIP.void
setSymbolicLinkAction(ZipParameters.SymbolicLinkAction symbolicLinkAction)
Set the behavior when adding a symbolic linkvoid
setUnixMode(boolean unixMode)
When set to true, zip4j uses unix mode as default when generating file headers.void
setWriteExtendedLocalFileHeader(boolean writeExtendedLocalFileHeader)
-
-
-
Field Detail
-
compressionMethod
private CompressionMethod compressionMethod
-
compressionLevel
private CompressionLevel compressionLevel
-
encryptFiles
private boolean encryptFiles
-
encryptionMethod
private EncryptionMethod encryptionMethod
-
readHiddenFiles
private boolean readHiddenFiles
-
readHiddenFolders
private boolean readHiddenFolders
-
aesKeyStrength
private AesKeyStrength aesKeyStrength
-
aesVersion
private AesVersion aesVersion
-
includeRootFolder
private boolean includeRootFolder
-
entryCRC
private long entryCRC
-
defaultFolderPath
private java.lang.String defaultFolderPath
-
fileNameInZip
private java.lang.String fileNameInZip
-
lastModifiedFileTime
private long lastModifiedFileTime
-
entrySize
private long entrySize
-
writeExtendedLocalFileHeader
private boolean writeExtendedLocalFileHeader
-
overrideExistingFilesInZip
private boolean overrideExistingFilesInZip
-
rootFolderNameInZip
private java.lang.String rootFolderNameInZip
-
fileComment
private java.lang.String fileComment
-
symbolicLinkAction
private ZipParameters.SymbolicLinkAction symbolicLinkAction
-
excludeFileFilter
private ExcludeFileFilter excludeFileFilter
-
unixMode
private boolean unixMode
-
-
Constructor Detail
-
ZipParameters
public ZipParameters()
Create a ZipParameters instance with default values; CompressionMethod.DEFLATE, CompressionLevel.NORMAL, EncryptionMethod.NONE, AesKeyStrength.KEY_STRENGTH_256, AesVerson.Two, SymbolicLinkAction.INCLUDE_LINKED_FILE_ONLY, readHiddenFiles is true, readHiddenFolders is true, includeRootInFolder is true, writeExtendedLocalFileHeader is true, overrideExistingFilesInZip is true
-
ZipParameters
public ZipParameters(ZipParameters zipParameters)
Create a clone of given ZipParameters instance- Parameters:
zipParameters
- the ZipParameters instance to clone
-
-
Method Detail
-
getCompressionMethod
public CompressionMethod getCompressionMethod()
Get the compression method specified in this ZipParameters- Returns:
- the ZIP compression method
-
setCompressionMethod
public void setCompressionMethod(CompressionMethod compressionMethod)
Set the ZIP compression method- Parameters:
compressionMethod
- the ZIP compression method
-
isEncryptFiles
public boolean isEncryptFiles()
Test if files files are to be encrypted- Returns:
- true if files are to be encrypted
-
setEncryptFiles
public void setEncryptFiles(boolean encryptFiles)
Set the flag indicating that files are to be encrypted- Parameters:
encryptFiles
- if true, files will be encrypted
-
getEncryptionMethod
public EncryptionMethod getEncryptionMethod()
Get the encryption method used to encrypt files- Returns:
- the encryption method
-
setEncryptionMethod
public void setEncryptionMethod(EncryptionMethod encryptionMethod)
Set the encryption method used to encrypt files- Parameters:
encryptionMethod
- the encryption method to be used
-
getCompressionLevel
public CompressionLevel getCompressionLevel()
Get the compression level used to compress files- Returns:
- the compression level used to compress files
-
setCompressionLevel
public void setCompressionLevel(CompressionLevel compressionLevel)
Set the compression level used to compress files- Parameters:
compressionLevel
- the compression level used to compress files
-
isReadHiddenFiles
public boolean isReadHiddenFiles()
Test if hidden files will be included during folder recursion- Returns:
- true if hidden files will be included when adding folders to the zip
-
setReadHiddenFiles
public void setReadHiddenFiles(boolean readHiddenFiles)
Indicate if hidden files will be included during folder recursion- Parameters:
readHiddenFiles
- if true, hidden files will be included when adding folders to the zip
-
isReadHiddenFolders
public boolean isReadHiddenFolders()
Test if hidden folders will be included during folder recursion- Returns:
- true if hidden folders will be included when adding folders to the zip
-
setReadHiddenFolders
public void setReadHiddenFolders(boolean readHiddenFolders)
Indicate if hidden folders will be included during folder recursion- Parameters:
readHiddenFolders
- if true, hidden folders will be included when added folders to the zip
-
getAesKeyStrength
public AesKeyStrength getAesKeyStrength()
Get the key strength of the AES encryption key- Returns:
- the key strength of the AES encryption key
-
setAesKeyStrength
public void setAesKeyStrength(AesKeyStrength aesKeyStrength)
Set the key strength of the AES encryption key- Parameters:
aesKeyStrength
- the key strength of the AES encryption key
-
getAesVersion
public AesVersion getAesVersion()
Get the AES format version used for encryption- Returns:
- the AES format version used for encryption
-
setAesVersion
public void setAesVersion(AesVersion aesVersion)
Set the AES format version to use for encryption- Parameters:
aesVersion
- the AES format version to use
-
isIncludeRootFolder
public boolean isIncludeRootFolder()
Test if the parent folder of the added files will be included in the ZIP- Returns:
- true if the parent folder of the added files will be included into the zip
-
setIncludeRootFolder
public void setIncludeRootFolder(boolean includeRootFolder)
Set the flag to indicate if the parent folder of added files will be included in the ZIP- Parameters:
includeRootFolder
- if true, the parent folder of added files will be included in the ZIP
-
getEntryCRC
public long getEntryCRC()
-
setEntryCRC
public void setEntryCRC(long entryCRC)
-
getDefaultFolderPath
public java.lang.String getDefaultFolderPath()
-
setDefaultFolderPath
public void setDefaultFolderPath(java.lang.String defaultFolderPath)
-
getFileNameInZip
public java.lang.String getFileNameInZip()
-
setFileNameInZip
public void setFileNameInZip(java.lang.String fileNameInZip)
Set the filename that will be used to include a file into the ZIP file to a different name that given by the source filename added to the ZIP file. The filenameInZip must adhere to the ZIP filename specification, including the use of forward slash '/' as the directory separator, and it must also be a relative file. If the filenameInZip given is not null and not empty, the value specified by setRootFolderNameInZip() will be ignored.- Parameters:
fileNameInZip
- the filename to set in the ZIP. Use null or an empty String to set the default behavior
-
getLastModifiedFileTime
public long getLastModifiedFileTime()
Get the last modified time to be used for files written to the ZIP- Returns:
- the last modified time in milliseconds since the epoch
-
setLastModifiedFileTime
public void setLastModifiedFileTime(long lastModifiedFileTime)
Set the last modified time recorded in the ZIP file for the added files. If less than 0, the last modified time is cleared and the current time is used- Parameters:
lastModifiedFileTime
- the last modified time in milliseconds since the epoch
-
getEntrySize
public long getEntrySize()
-
setEntrySize
public void setEntrySize(long entrySize)
-
isWriteExtendedLocalFileHeader
public boolean isWriteExtendedLocalFileHeader()
-
setWriteExtendedLocalFileHeader
public void setWriteExtendedLocalFileHeader(boolean writeExtendedLocalFileHeader)
-
isOverrideExistingFilesInZip
public boolean isOverrideExistingFilesInZip()
-
setOverrideExistingFilesInZip
public void setOverrideExistingFilesInZip(boolean overrideExistingFilesInZip)
Set the behavior if a file is added that already exists in the ZIP.- Parameters:
overrideExistingFilesInZip
- if true, remove the existing file in the ZIP; if false do not add the new file
-
getRootFolderNameInZip
public java.lang.String getRootFolderNameInZip()
-
setRootFolderNameInZip
public void setRootFolderNameInZip(java.lang.String rootFolderNameInZip)
Set the folder name that will be prepended to the filename in the ZIP. This value is ignored if setFileNameInZip() is specified with a non-null, non-empty string.- Parameters:
rootFolderNameInZip
- the name of the folder to be prepended to the filename in the ZIP archive
-
getFileComment
public java.lang.String getFileComment()
Get the file comment- Returns:
- the file comment
-
setFileComment
public void setFileComment(java.lang.String fileComment)
Set the file comment- Parameters:
fileComment
- the file comment
-
getSymbolicLinkAction
public ZipParameters.SymbolicLinkAction getSymbolicLinkAction()
Get the behavior when adding a symbolic link- Returns:
- the behavior when adding a symbolic link
-
setSymbolicLinkAction
public void setSymbolicLinkAction(ZipParameters.SymbolicLinkAction symbolicLinkAction)
Set the behavior when adding a symbolic link- Parameters:
symbolicLinkAction
- the behavior when adding a symbolic link
-
getExcludeFileFilter
public ExcludeFileFilter getExcludeFileFilter()
Returns the file exclusion filter that is currently being used when adding files/folders to zip file- Returns:
- ExcludeFileFilter
-
setExcludeFileFilter
public void setExcludeFileFilter(ExcludeFileFilter excludeFileFilter)
Set a filter to exclude any files from the list of files being added to zip. Mostly used when adding a folder to a zip, and if certain files have to be excluded from adding to the zip file.
-
isUnixMode
public boolean isUnixMode()
Returns true if zip4j is using unix mode as default. Returns False otherwise.- Returns:
- true if zip4j is using unix mode as default, false otherwise
-
setUnixMode
public void setUnixMode(boolean unixMode)
When set to true, zip4j uses unix mode as default when generating file headers.- Parameters:
unixMode
-
-
-