Package net.lingala.zip4j.model
Class ZipParameters
- java.lang.Object
-
- net.lingala.zip4j.model.ZipParameters
-
public class ZipParameters extends java.lang.ObjectEncapsulates the parameters that that control how Zip4J encodes data
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZipParameters.SymbolicLinkActionIndicates the action to take when a symbolic link is added to the ZIP file
-
Field Summary
Fields Modifier and Type Field Description private AesKeyStrengthaesKeyStrengthprivate AesVersionaesVersionprivate CompressionLevelcompressionLevelprivate CompressionMethodcompressionMethodprivate java.lang.StringdefaultFolderPathprivate booleanencryptFilesprivate EncryptionMethodencryptionMethodprivate longentryCRCprivate longentrySizeprivate ExcludeFileFilterexcludeFileFilterprivate java.lang.StringfileCommentprivate java.lang.StringfileNameInZipprivate booleanincludeRootFolderprivate longlastModifiedFileTimeprivate booleanoverrideExistingFilesInZipprivate booleanreadHiddenFilesprivate booleanreadHiddenFoldersprivate java.lang.StringrootFolderNameInZipprivate ZipParameters.SymbolicLinkActionsymbolicLinkActionprivate booleanunixModeprivate booleanwriteExtendedLocalFileHeader
-
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 AesKeyStrengthgetAesKeyStrength()Get the key strength of the AES encryption keyAesVersiongetAesVersion()Get the AES format version used for encryptionCompressionLevelgetCompressionLevel()Get the compression level used to compress filesCompressionMethodgetCompressionMethod()Get the compression method specified in this ZipParametersjava.lang.StringgetDefaultFolderPath()EncryptionMethodgetEncryptionMethod()Get the encryption method used to encrypt fileslonggetEntryCRC()longgetEntrySize()ExcludeFileFiltergetExcludeFileFilter()Returns the file exclusion filter that is currently being used when adding files/folders to zip filejava.lang.StringgetFileComment()Get the file commentjava.lang.StringgetFileNameInZip()longgetLastModifiedFileTime()Get the last modified time to be used for files written to the ZIPjava.lang.StringgetRootFolderNameInZip()ZipParameters.SymbolicLinkActiongetSymbolicLinkAction()Get the behavior when adding a symbolic linkbooleanisEncryptFiles()Test if files files are to be encryptedbooleanisIncludeRootFolder()Test if the parent folder of the added files will be included in the ZIPbooleanisOverrideExistingFilesInZip()booleanisReadHiddenFiles()Test if hidden files will be included during folder recursionbooleanisReadHiddenFolders()Test if hidden folders will be included during folder recursionbooleanisUnixMode()Returns true if zip4j is using unix mode as default.booleanisWriteExtendedLocalFileHeader()voidsetAesKeyStrength(AesKeyStrength aesKeyStrength)Set the key strength of the AES encryption keyvoidsetAesVersion(AesVersion aesVersion)Set the AES format version to use for encryptionvoidsetCompressionLevel(CompressionLevel compressionLevel)Set the compression level used to compress filesvoidsetCompressionMethod(CompressionMethod compressionMethod)Set the ZIP compression methodvoidsetDefaultFolderPath(java.lang.String defaultFolderPath)voidsetEncryptFiles(boolean encryptFiles)Set the flag indicating that files are to be encryptedvoidsetEncryptionMethod(EncryptionMethod encryptionMethod)Set the encryption method used to encrypt filesvoidsetEntryCRC(long entryCRC)voidsetEntrySize(long entrySize)voidsetExcludeFileFilter(ExcludeFileFilter excludeFileFilter)Set a filter to exclude any files from the list of files being added to zip.voidsetFileComment(java.lang.String fileComment)Set the file commentvoidsetFileNameInZip(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.voidsetIncludeRootFolder(boolean includeRootFolder)Set the flag to indicate if the parent folder of added files will be included in the ZIPvoidsetLastModifiedFileTime(long lastModifiedFileTime)Set the last modified time recorded in the ZIP file for the added files.voidsetOverrideExistingFilesInZip(boolean overrideExistingFilesInZip)Set the behavior if a file is added that already exists in the ZIP.voidsetReadHiddenFiles(boolean readHiddenFiles)Indicate if hidden files will be included during folder recursionvoidsetReadHiddenFolders(boolean readHiddenFolders)Indicate if hidden folders will be included during folder recursionvoidsetRootFolderNameInZip(java.lang.String rootFolderNameInZip)Set the folder name that will be prepended to the filename in the ZIP.voidsetSymbolicLinkAction(ZipParameters.SymbolicLinkAction symbolicLinkAction)Set the behavior when adding a symbolic linkvoidsetUnixMode(boolean unixMode)When set to true, zip4j uses unix mode as default when generating file headers.voidsetWriteExtendedLocalFileHeader(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-
-
-