Class ZipOptions.Builder
java.lang.Object
cloud.opencode.base.io.compress.ZipOptions.Builder
- Enclosing class:
ZipOptions
Fluent builder for
ZipOptions.
ZipOptions 的流式 Builder。
The 5 anti-bomb cap setters (maxCompressionRatio / maxTotalSize /
maxEntryCount / maxNestingDepth / maxSingleEntrySize) mutate a
builder-local copy of BombProtection; callers who prefer to compose the preset
upfront can use bombProtection(BombProtection) directly.
5 个反炸弹上限 setter 修改 builder 本地的 BombProtection 副本;偏好整体设置预设时
可直接使用 bombProtection(BombProtection)。
- Since:
- JDK 25, opencode-base-io V1.0.4
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionaddExcludePattern(String pattern) Appends a single exclude glob pattern.bombProtection(BombProtection protection) Replaces the anti-bomb preset wholesale.build()Builds an immutableZipOptions, assembling the 5 anti-bomb caps into a freshBombProtection.compressionLevel(int level) Sets the compression level in the[0, 9]range.Sets the filename encoding, e.g.encryption(EncryptionMethod encryption) Sets the encryption method.excludePatterns(List<String> patterns) Replaces the entire exclude-pattern list with the supplied glob patterns.includeRootDir(boolean include) Includes the root directory name as a prefix in entry names when compressing a directory tree.maxCompressionRatio(long maxCompressionRatio) Sets the max ratio of decompressed:compressed bytes.maxEntryCount(int maxEntryCount) Sets the max number of entries permitted in a single archive.maxNestingDepth(int maxNestingDepth) Sets the max nested-ZIP depth (detected by.zipsuffix; payload not magic-byte sniffed).maxSingleEntrySize(long maxSingleEntrySize) Sets the max decompressed bytes for any single entry.maxTotalSize(long maxTotalSize) Sets the max total decompressed bytes across all entries.overwrite(OverwritePolicy policy) Sets the overwrite policy applied during extraction.Sets the encryption password, ornullto disable.zip64(boolean zip64) Enables or disables ZIP64 extensions for archives larger than 4 GiB or with more than 65535 entries.
-
Method Details
-
compressionLevel
Sets the compression level in the[0, 9]range. 设置压缩级别(0..9)。- Parameters:
level- compression level | 压缩级别- Returns:
- this builder | 当前 builder
-
password
Sets the encryption password, ornullto disable. 设置加密口令,null表示不加密。- Parameters:
password- password ornull| 口令或null- Returns:
- this builder | 当前 builder
-
encryption
Sets the encryption method. Note:ZipUtilrejects any non-EncryptionMethod.NONEvalue because base does not bundle an AES engine. 设置加密方式。注意:base 不内置 AES 引擎,ZipUtil会拒绝任何非EncryptionMethod.NONE值。- Parameters:
encryption- encryption method | 加密方式- Returns:
- this builder | 当前 builder
-
zip64
Enables or disables ZIP64 extensions for archives larger than 4 GiB or with more than 65535 entries. 启用或关闭 ZIP64 扩展,用于大于 4 GiB 或多于 65535 条目的归档。- Parameters:
zip64- enable ZIP64 | 是否启用 ZIP64- Returns:
- this builder | 当前 builder
-
encoding
Sets the filename encoding, e.g."UTF-8"or"GBK". 设置文件名编码,如"UTF-8"或"GBK"。- Parameters:
encoding- charset name | 字符集名- Returns:
- this builder | 当前 builder
-
includeRootDir
Includes the root directory name as a prefix in entry names when compressing a directory tree. Defaultfalseproduces flat entries. 压缩目录树时,是否在条目名中保留根目录前缀。默认false产出扁平条目。- Parameters:
include- include root directory | 是否包含根目录- Returns:
- this builder | 当前 builder
-
overwrite
Sets the overwrite policy applied during extraction. SeeOverwritePolicyfor theOVERWRITE / SKIP / FAILsemantics. 设置解压覆盖策略,详见OverwritePolicy(OVERWRITE / SKIP / FAIL)。- Parameters:
policy- overwrite policy | 覆盖策略- Returns:
- this builder | 当前 builder
-
excludePatterns
Replaces the entire exclude-pattern list with the supplied glob patterns. Passingnullclears the list. 用给定 glob 模式整体替换排除列表,传null清空。- Parameters:
patterns- glob patterns | glob 模式- Returns:
- this builder | 当前 builder
-
addExcludePattern
Appends a single exclude glob pattern. 追加单个排除 glob 模式。- Parameters:
pattern- glob pattern | glob 模式- Returns:
- this builder | 当前 builder
-
bombProtection
Replaces the anti-bomb preset wholesale. Useful for propagating a centrally-definedBombProtectionthrough configuration without setting individual caps. 整体替换反炸弹预设,便于通过配置注入中心化定义的BombProtection而无需逐项设置。- Parameters:
protection- bomb protection preset (null falls back toBombProtection.defaults()) | 反炸弹预设(null回退到BombProtection.defaults())- Returns:
- this builder | 当前 builder
-
maxCompressionRatio
Sets the max ratio of decompressed:compressed bytes. Routes into the builder-localBombProtection. 设置最大解压:压缩字节比,写入 builder 本地的BombProtection。- Parameters:
maxCompressionRatio- threshold | 阈值- Returns:
- this builder | 当前 builder
-
maxTotalSize
Sets the max total decompressed bytes across all entries. 设置所有条目累计的最大解压字节。- Parameters:
maxTotalSize- threshold | 阈值- Returns:
- this builder | 当前 builder
-
maxEntryCount
Sets the max number of entries permitted in a single archive. 设置单个归档允许的最大条目数。- Parameters:
maxEntryCount- threshold | 阈值- Returns:
- this builder | 当前 builder
-
maxNestingDepth
Sets the max nested-ZIP depth (detected by.zipsuffix; payload not magic-byte sniffed). 设置嵌套 ZIP 最大深度(按.zip后缀识别,不做魔数嗅探)。- Parameters:
maxNestingDepth- threshold | 阈值- Returns:
- this builder | 当前 builder
-
maxSingleEntrySize
Sets the max decompressed bytes for any single entry. 设置单条目解压字节上限。- Parameters:
maxSingleEntrySize- threshold | 阈值- Returns:
- this builder | 当前 builder
-
build
Builds an immutableZipOptions, assembling the 5 anti-bomb caps into a freshBombProtection. 构建不可变ZipOptions,把 5 个反炸弹上限装配为新的BombProtection。- Returns:
- new
ZipOptions| 新ZipOptions
-