This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 0df4e0fc089887a8401b5ae32093186b2f59869f Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue Feb 4 11:14:27 2025 -0500 Javadoc --- .../compress/archivers/arj/ArjArchiveEntry.java | 30 +++-- .../archivers/dump/DumpArchiveConstants.java | 57 ++++++++- .../compress/archivers/dump/DumpArchiveEntry.java | 133 ++++++++++++++++++--- .../commons/compress/archivers/sevenz/CLI.java | 3 + .../compress/archivers/sevenz/SevenZMethod.java | 2 +- .../compress/archivers/zip/PKWareExtraHeader.java | 95 ++++++++++++++- .../commons/compress/archivers/zip/Zip64Mode.java | 6 +- .../compress/archivers/zip/ZipArchiveEntry.java | 14 ++- .../commons/compress/archivers/zip/ZipMethod.java | 4 +- .../compress/compressors/gzip/GzipParameters.java | 2 +- .../lz4/FramedLZ4CompressorOutputStream.java | 10 +- .../compressors/pack200/Pack200Strategy.java | 8 +- .../compressors/snappy/FramedSnappyDialect.java | 2 +- 13 files changed, 312 insertions(+), 54 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java index 5c2f79fbb..04230cd8b 100644 --- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java @@ -38,72 +38,78 @@ public class ArjArchiveEntry implements ArchiveEntry { public static class HostOs { /** - * {@value} + * Constant value {@value}. */ public static final int DOS = 0; /** - * {@value} + * Constant value {@value}. */ public static final int PRIMOS = 1; /** - * {@value} + * Constant value {@value}. */ public static final int UNIX = 2; /** - * {@value} + * Constant value {@value}. */ public static final int AMIGA = 3; /** - * {@value} + * Constant value {@value}. */ public static final int MAC_OS = 4; /** - * {@value} + * Constant value {@value}. */ public static final int OS_2 = 5; /** - * {@value} + * Constant value {@value}. */ public static final int APPLE_GS = 6; /** - * {@value} + * Constant value {@value}. */ public static final int ATARI_ST = 7; /** - * {@value} + * Constant value {@value}. */ public static final int NEXT = 8; /** - * {@value} + * Constant value {@value}. */ public static final int VAX_VMS = 9; /** - * {@value} + * Constant value {@value}. */ public static final int WIN95 = 10; /** - * {@value} + * Constant value {@value}. */ public static final int WIN32 = 11; } private final LocalFileHeader localFileHeader; + /** + * Constructs a new instance. + */ public ArjArchiveEntry() { localFileHeader = new LocalFileHeader(); } + /** + * Constructs a new instance. + */ ArjArchiveEntry(final LocalFileHeader localFileHeader) { this.localFileHeader = localFileHeader; } diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java index f1307f146..ad1616493 100644 --- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java +++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveConstants.java @@ -22,11 +22,31 @@ * Various constants associated with dump archives. */ public final class DumpArchiveConstants { + /** - * The type of compression. + * Enumerates compression types. */ public enum COMPRESSION_TYPE { - UNKNOWN(-1), ZLIB(0), BZLIB(1), LZO(2); + + /** + * Compression code is -1. + */ + UNKNOWN(-1), + + /** + * Compression code is 0. + */ + ZLIB(0), + + /** + * Compression code is 1. + */ + BZLIB(1), + + /** + * Compression code is 2. + */ + LZO(2); public static COMPRESSION_TYPE find(final int code) { for (final COMPRESSION_TYPE t : values()) { @@ -46,10 +66,39 @@ public static COMPRESSION_TYPE find(final int code) { } /** - * The type of tape segment. + * Enumerates the types of tape segment. */ public enum SEGMENT_TYPE { - TAPE(1), INODE(2), BITS(3), ADDR(4), END(5), CLRI(6); + + /** + * TAPE with code 1. + */ + TAPE(1), + + /** + * INODE with code 2. + */ + INODE(2), + + /** + * BITS with code 3. + */ + BITS(3), + + /** + * ADDR with code 4. + */ + ADDR(4), + + /** + * END with code 5. + */ + END(5), + + /** + * CLRI with code 6. + */ + CLRI(6); public static SEGMENT_TYPE find(final int code) { for (final SEGMENT_TYPE t : values()) { diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java index 2a1ff174d..9e0d6319c 100644 --- a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java @@ -173,22 +173,71 @@ */ public class DumpArchiveEntry implements ArchiveEntry { + /** + * Enumerates permissions with values. + */ public enum PERMISSION { // Note: The arguments are octal values - // @formatter:off + + /** + * Permission SETUID (octal value 04000). + */ SETUID(04000), + + /** + * Permission SETGUI (octal value 02000). + */ SETGUI(02000), + + /** + * Permission STICKY (octal value 01000). + */ STICKY(01000), + + /** + * Permission USER_READ (octal value 00400). + */ USER_READ(00400), + + /** + * Permission USER_WRITE (octal value 00200). + */ USER_WRITE(00200), + + /** + * Permission USER_EXEC (octal value 00100). + */ USER_EXEC(00100), + + /** + * Permission GROUP_READ (octal value 00040). + */ GROUP_READ(00040), + + /** + * Permission GROUP_WRITE (octal value 00020). + */ GROUP_WRITE(00020), + + /** + * Permission 00020 (octal value 00010). + */ GROUP_EXEC(00010), + + /** + * Permission WORLD_READ (octal value 00004). + */ WORLD_READ(00004), + + /** + * Permission WORLD_WRITE (octal value 00002). + */ WORLD_WRITE(00002), + + /** + * Permission WORLD_EXEC (octal value 00001). + */ WORLD_EXEC(00001); - // @formatter:on public static Set<PERMISSION> find(final int code) { final Set<PERMISSION> set = new HashSet<>(); @@ -253,8 +302,55 @@ void setIno(final int ino) { } } + /** + * Enumerates types. + */ public enum TYPE { - WHITEOUT(14), SOCKET(12), LINK(10), FILE(8), BLKDEV(6), DIRECTORY(4), CHRDEV(2), FIFO(1), UNKNOWN(15); + + /** + * WHITEOUT with code 14. + */ + WHITEOUT(14), + + /** + * SOCKET with code 12. + */ + SOCKET(12), + + /** + * LINK with code 10. + */ + LINK(10), + + /** + * FILE with code 8. + */ + FILE(8), + + /** + * BLKDEV with code 6. + */ + BLKDEV(6), + + /** + * DIRECTORY with code 4. + */ + DIRECTORY(4), + + /** + * CHRDEV with code 2. + */ + CHRDEV(2), + + /** + * CHRDEV with code 1. + */ + FIFO(1), + + /** + * UNKNOWN with code 15. + */ + UNKNOWN(15); public static TYPE find(final int code) { TYPE type = UNKNOWN; @@ -636,16 +732,16 @@ public int hashCode() { } /** - * Is this a block device? + * Tests whether this is a block device. * - * @return whether this is a block device + * @return whether this is a block device. */ public boolean isBlkDev() { return type == TYPE.BLKDEV; } /** - * Is this a character device? + * Tests whether this is a character device. * * @return whether this is a character device */ @@ -654,16 +750,17 @@ public boolean isChrDev() { } /** - * Has this file been deleted? (On valid on incremental dumps.) + * Tests whether this file been deleted. + * For valid on incremental dumps. * - * @return whether the file has been deleted + * @return whether the file has been deleted. */ public boolean isDeleted() { return isDeleted; } /** - * Is this a directory? + * Tests whether this is a directory. * * @return whether this is a directory */ @@ -673,37 +770,37 @@ public boolean isDirectory() { } /** - * Is this a fifo/pipe? + * Tests whether whether this is a fifo/pipe. * - * @return whether this is a fifo + * @return whether this is a fifo/pipe. */ public boolean isFifo() { return type == TYPE.FIFO; } /** - * Is this a regular file? + * Tests whether this is a regular file. * - * @return whether this is a regular file + * @return whether this is a regular file. */ public boolean isFile() { return type == TYPE.FILE; } /** - * Is this a network device? + * Tests whether this is a socket. * - * @return whether this is a socket + * @return whether this is a socket. */ public boolean isSocket() { return type == TYPE.SOCKET; } /** - * Is this a sparse record? + * Tests whether this is a sparse record. * - * @param idx index of the record to check - * @return whether this is a sparse record + * @param idx index of the record to check. + * @return whether this is a sparse record. */ public boolean isSparseRecord(final int idx) { return (header.getCdata(idx) & 0x01) == 0; diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java index 160741393..0f38ec52e 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java @@ -27,6 +27,9 @@ */ public class CLI { + /** + * Enumerates modes. + */ private enum Mode { LIST("Analysing") { private String getContentMethods(final SevenZArchiveEntry entry) { diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java index 531a4eb67..12cd196f3 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZMethod.java @@ -21,7 +21,7 @@ import java.util.Arrays; /** - * The (partially) supported compression/encryption methods used in 7z archives. + * Enumerates the (partially) supported compression/encryption methods used in 7z archives. * <p> * All methods with a {@code _FILTER} suffix are used as preprocessors with the goal of creating a better compression ratio with the compressor that comes next * in the chain of methods. 7z will in general only allow them to be used together with a "real" compression method but Commons Compress doesn't enforce this. diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java index 1da832743..478cb8956 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java @@ -67,12 +67,60 @@ public abstract class PKWareExtraHeader implements ZipExtraField { /** - * Encryption algorithm. + * Enumerates encryption algorithm. * * @since 1.11 */ public enum EncryptionAlgorithm { - DES(0x6601), RC2pre52(0x6602), TripleDES168(0x6603), TripleDES192(0x6609), AES128(0x660E), AES192(0x660F), AES256(0x6610), RC2(0x6702), RC4(0x6801), + + /** + * DES with code 0x6601. + */ + DES(0x6601), + + /** + * RC2pre52 with code 0x6602. + */ + RC2pre52(0x6602), + + /** + * TripleDES168 with code 0x6603. + */ + TripleDES168(0x6603), + + /** + * TripleDES192 with code 0x6609. + */ + TripleDES192(0x6609), + + /** + * AES128 with code 0x660E. + */ + AES128(0x660E), + + /** + * AES192 with code 0x660F. + */ + AES192(0x660F), + + /** + * AES256 with code 0x6610. + */ + AES256(0x6610), + + /** + * RC2 with code 0x6702. + */ + RC2(0x6702), + + /** + * RC4 with code 0x6801. + */ + RC4(0x6801), + + /** + * UNKNOWN with code 0xFFFF. + */ UNKNOWN(0xFFFF); private static final Map<Integer, EncryptionAlgorithm> codeToEnum; @@ -115,12 +163,51 @@ public int getCode() { } /** - * Hash Algorithm + * Enumerates hash Algorithm * * @since 1.11 */ public enum HashAlgorithm { - NONE(0), CRC32(1), MD5(0x8003), SHA1(0x8004), RIPEND160(0x8007), SHA256(0x800C), SHA384(0x800D), SHA512(0x800E); + + /** + * NONE with code 0. + */ + NONE(0), + + /** + * CRC32 with code 1. + */ + CRC32(1), + + /** + * MD5 with code 0x8003. + */ + MD5(0x8003), + + /** + * SHA1 with code 0x8004. + */ + SHA1(0x8004), + + /** + * RIPEND160 with code 0x8007. + */ + RIPEND160(0x8007), + + /** + * SHA256 with code 0x800C. + */ + SHA256(0x800C), + + /** + * SHA384 with code 0x800D. + */ + SHA384(0x800D), + + /** + * SHA512 with code 0x800E. + */ + SHA512(0x800E); private static final Map<Integer, HashAlgorithm> codeToEnum; diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java index 509cf1bc5..ecb58a1be 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java @@ -20,16 +20,18 @@ package org.apache.commons.compress.archivers.zip; /** - * The different modes {@link ZipArchiveOutputStream} can operate in. + * Enumerates the different modes {@link ZipArchiveOutputStream} can operate in. * * @see ZipArchiveOutputStream#setUseZip64 * @since 1.3 */ public enum Zip64Mode { + /** * Use Zip64 extensions for all entries, even if it is clear it is not required. */ Always, + /** * Don't use Zip64 extensions for any entries. * @@ -38,10 +40,12 @@ public enum Zip64Mode { * </p> */ Never, + /** * Use Zip64 extensions for all entries where they are required, don't use them for entries that clearly don't require them. */ AsNeeded, + /** * Always use Zip64 extensions for LFH and central directory as {@link Zip64Mode#Always} did, and at the meantime encode the relative offset of LFH and disk * number start as needed in CFH as {@link Zip64Mode#AsNeeded} did. diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java index 48fe1ddbf..8bcc3d64e 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java @@ -63,16 +63,18 @@ public class ZipArchiveEntry extends ZipEntry implements ArchiveEntry, EntryStreamOffsets { /** - * Indicates how the comment of this entry has been determined. + * Enumerates how the comment of this entry has been determined. * * @since 1.16 */ public enum CommentSource { + /** * The comment has been read from the archive using the encoding of the archive specified when creating the {@link ZipArchiveInputStream} or * {@link ZipFile} (defaults to the platform's default encoding). */ COMMENT, + /** * The comment has been read from an {@link UnicodeCommentExtraField Unicode Extra Field}. */ @@ -80,7 +82,7 @@ public enum CommentSource { } /** - * How to try to parse the extra fields. + * Enumerates how to try to parse the extra fields. * * <p> * Configures the behavior for: @@ -94,6 +96,7 @@ public enum CommentSource { * @since 1.19 */ public enum ExtraFieldParsingMode implements ExtraFieldParsingBehavior { + /** * Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed in * {@link UnrecognizedExtraField}. @@ -112,6 +115,7 @@ public ZipExtraField fill(final ZipExtraField field, final byte[] data, final in return fillAndMakeUnrecognizedOnError(field, data, off, len, local); } }, + /** * Try to parse as many extra fields as possible and wrap unknown extra fields in {@link UnrecognizedExtraField}. * @@ -128,6 +132,7 @@ public ZipExtraField fill(final ZipExtraField field, final byte[] data, final in * </p> */ STRICT_FOR_KNOW_EXTRA_FIELDS(ExtraFieldUtils.UnparseableExtraField.READ), + /** * Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed in * {@link UnrecognizedExtraField}. @@ -142,6 +147,7 @@ public ZipExtraField fill(final ZipExtraField field, final byte[] data, final in return fillAndMakeUnrecognizedOnError(field, data, off, len, local); } }, + /** * Try to parse as many extra fields as possible and wrap unknown extra fields in {@link UnrecognizedExtraField}. * @@ -154,6 +160,7 @@ public ZipExtraField fill(final ZipExtraField field, final byte[] data, final in * </p> */ ONLY_PARSEABLE_STRICT(ExtraFieldUtils.UnparseableExtraField.SKIP), + /** * Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern. */ @@ -204,15 +211,18 @@ public ZipExtraField onUnparseableExtraField(final byte[] data, final int off, f * @since 1.16 */ public enum NameSource { + /** * The name has been read from the archive using the encoding of the archive specified when creating the {@link ZipArchiveInputStream} or * {@link ZipFile} (defaults to the platform's default encoding). */ NAME, + /** * The name has been read from the archive and the archive specified the EFS flag which indicates the name has been encoded as UTF-8. */ NAME_WITH_EFS_FLAG, + /** * The name has been read from an {@link UnicodePathExtraField Unicode Extra Field}. */ diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java index a5b4454d1..4176f6b3e 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipMethod.java @@ -26,9 +26,9 @@ import java.util.zip.ZipEntry; /** - * List of known compression methods + * Enumerates known compression methods. * - * Many of these methods are currently not supported by commons compress + * Some of these methods are currently not supported by commons compress. * * @since 1.5 */ diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java index 516dc8451..cc14035b6 100644 --- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java +++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java @@ -40,7 +40,7 @@ public class GzipParameters { /** - * The OS type. + * Enumerates OS types. * <ul> * <li>0 - FAT filesystem (MS-DOS, OS/2, NT/Win32)</li> * <li>1 - Amiga</li> diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStream.java index 73171b549..d53088dde 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStream.java @@ -39,20 +39,20 @@ public class FramedLZ4CompressorOutputStream extends CompressorOutputStream<OutputStream> { /** - * The block sizes supported by the format. + * Enumerates the block sizes supported by the format. */ public enum BlockSize { - /** Block size of 64K */ + /** Block size of 64K. */ K64(64 * 1024, 4), - /** Block size of 256K */ + /** Block size of 256K. */ K256(256 * 1024, 5), - /** Block size of 1M */ + /** Block size of 1M. */ M1(1024 * 1024, 6), - /** Block size of 4M */ + /** Block size of 4M. */ M4(4096 * 1024, 7); private final int size; diff --git a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Strategy.java b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Strategy.java index 8568e36f3..5b6c4d5d6 100644 --- a/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Strategy.java +++ b/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200Strategy.java @@ -22,19 +22,21 @@ import java.io.IOException; /** - * The different modes the Pack200 streams can use to wrap input and output. + * Enumerates the different modes the Pack200 streams can use to wrap input and output. * * @since 1.3 */ public enum Pack200Strategy { - /** Cache output in memory */ + + /** Cache output in memory. */ IN_MEMORY() { @Override AbstractStreamBridge newStreamBridge() { return new InMemoryCachingStreamBridge(); } }, - /** Cache output in a temporary file */ + + /** Cache output in a temporary file. */ TEMP_FILE() { @Override AbstractStreamBridge newStreamBridge() throws IOException { diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyDialect.java b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyDialect.java index 55a00f8f5..8579ef8f3 100644 --- a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyDialect.java +++ b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyDialect.java @@ -19,7 +19,7 @@ package org.apache.commons.compress.compressors.snappy; /** - * Dialects of the framing format that {@link FramedSnappyCompressorInputStream} can deal with. + * Enumerates dialects of the framing format that {@link FramedSnappyCompressorInputStream} can deal with. * * @since 1.12 */