You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/02/05 13:46:33 UTC
[commons-compress] branch master updated: Javadoc and camel case
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
The following commit(s) were added to refs/heads/master by this push:
new 3c515109 Javadoc and camel case
3c515109 is described below
commit 3c515109246f3bd7c45acdf233b88b5dbac43a04
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Feb 5 08:46:28 2023 -0500
Javadoc and camel case
---
.../compress/archivers/ArchiveStreamFactory.java | 4 +-
.../compress/archivers/sevenz/SevenZFile.java | 2 +-
.../archivers/zip/AbstractUnicodeExtraField.java | 2 +-
.../commons/compress/archivers/zip/BinaryTree.java | 1 +
.../commons/compress/archivers/zip/BitStream.java | 2 +
.../archivers/zip/ExplodingInputStream.java | 2 +-
.../archivers/zip/ResourceAlignmentExtraField.java | 2 +-
.../zip/UnsupportedZipFeatureException.java | 2 +-
.../commons/compress/archivers/zip/X000A_NTFS.java | 2 +-
.../archivers/zip/X5455_ExtendedTimestamp.java | 2 +-
.../archivers/zip/ZipArchiveEntryRequest.java | 15 +++----
.../archivers/zip/ZipArchiveInputStream.java | 2 +-
.../commons/compress/archivers/zip/ZipFile.java | 46 +++++++++++-----------
.../archivers/zip/ZipSplitOutputStream.java | 15 ++++---
14 files changed, 54 insertions(+), 45 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
index 059dbd7f..22f9b088 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
@@ -578,7 +578,7 @@ public class ArchiveStreamFactory implements ArchiveStreamProvider {
}
/**
- * Returns the encoding to use for arj, jar, zip, dump, cpio and tar
+ * Gets the encoding to use for arj, jar, ZIP, dump, cpio and tar
* files, or null for the archiver default.
*
* @return entry encoding, or null for the archiver default
@@ -599,7 +599,7 @@ public class ArchiveStreamFactory implements ArchiveStreamProvider {
}
/**
- * Sets the encoding to use for arj, jar, zip, dump, cpio and tar files. Use null for the archiver default.
+ * Sets the encoding to use for arj, jar, ZIP, dump, cpio and tar files. Use null for the archiver default.
*
* @param entryEncoding the entry encoding, null uses the archiver default.
* @since 1.5
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index f7e51b93..b1b19c7e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -825,7 +825,7 @@ public class SevenZFile implements Closeable {
*
* @param entry the entry to get the stream for.
* @return a stream to read the entry from.
- * @throws IOException if unable to create an input stream from the zipentry
+ * @throws IOException if unable to create an input stream from the entry
* @since 1.20
*/
public InputStream getInputStream(final SevenZArchiveEntry entry) throws IOException {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
index 824c1abf..8a63f5a7 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
@@ -41,7 +41,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
* encoding of the original ZIP entry.
*
* @param text The file name or comment.
- * @param bytes The encoded of the file name or comment in the zip
+ * @param bytes The encoded of the file name or comment in the ZIP
* file.
*/
protected AbstractUnicodeExtraField(final String text, final byte[] bytes) {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java b/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
index 00400ca8..f4644c6b 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/BinaryTree.java
@@ -178,6 +178,7 @@ class BinaryTree {
*
* @param stream
* @return the value decoded, or -1 if the end of the stream is reached
+ * @throws IOException on error.
*/
public int read(final BitStream stream) throws IOException {
int currentIndex = 0;
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/BitStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/BitStream.java
index e826a515..8d8700e3 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/BitStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/BitStream.java
@@ -41,6 +41,7 @@ class BitStream extends BitInputStream {
* Returns the next bit.
*
* @return The next bit (0 or 1) or -1 if the end of the stream has been reached
+ * @throws IOException on error.
*/
int nextBit() throws IOException {
return (int) readBits(1);
@@ -51,6 +52,7 @@ class BitStream extends BitInputStream {
*
* @param n the number of bits read (up to 8)
* @return The value formed by the n bits, or -1 if the end of the stream has been reached
+ * @throws IOException on error.
*/
long nextBits(final int n) throws IOException {
if (n < 0 || n > 8) {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
index 94f23baf..31728b71 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExplodingInputStream.java
@@ -101,7 +101,7 @@ class ExplodingInputStream extends InputStream implements InputStreamStatistics
/**
* Fill the sliding dictionary with more data.
- * @throws IOException
+ * @throws IOException on error.
*/
private void fillBuffer() throws IOException {
init();
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
index c2a233c1..7bb3e092 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
@@ -29,7 +29,7 @@ import java.util.zip.ZipException;
* when reading a padding field.</p>
*
* <p>This enables Commons Compress to create "aligned" archives
- * similar to Android's zipalign command line tool.</p>
+ * similar to Android's {@code zipalign} command line tool.</p>
*
* @since 1.14
* @see "https://developer.android.com/studio/command-line/zipalign.html"
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java
index ef1e5dab..72aac159 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java
@@ -22,7 +22,7 @@ import java.io.Serializable;
import java.util.zip.ZipException;
/**
- * Exception thrown when attempting to read or write data for a zip
+ * Exception thrown when attempting to read or write data for a ZIP
* entry that uses ZIP features not supported by this library.
* @since 1.1
*/
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
index 54274f77..c38f64d8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
@@ -191,7 +191,7 @@ public class X000A_NTFS implements ZipExtraField {
}
/**
- * Gets the create time as a java.util.Date of this zip
+ * Gets the create time as a java.util.Date of this ZIP
* entry, or null if no such timestamp exists in the ZIP entry.
*
* @return create time as java.util.Date or null.
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
index 693805d4..def84e35 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
@@ -32,7 +32,7 @@ import org.apache.commons.compress.utils.TimeUtils;
* for ZIP entries. Each ZIP entry can include up to three timestamps
* (modify, access, create*). The timestamps are stored as 32 bit signed
* integers representing seconds since UNIX epoch (Jan 1st, 1970, UTC).
- * This field improves on zip's default timestamp granularity, since it
+ * This field improves on ZIP's default timestamp granularity, since it
* allows one to store additional timestamps, and, in addition, the timestamps
* are stored using per-second granularity (zip's default behavior can only store
* timestamps to the nearest <em>even</em> second).
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
index 7133480e..ebb88ca6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
@@ -27,8 +27,9 @@ import org.apache.commons.compress.parallel.InputStreamSupplier;
* @since 1.10
*/
public class ZipArchiveEntryRequest {
+
/**
- * Create a ZipArchiveEntryRequest
+ * Creates a ZipArchiveEntryRequest
* @param zipArchiveEntry The entry to use
* @param payloadSupplier The payload that will be added to the ZIP entry.
* @return The newly created request
@@ -36,10 +37,10 @@ public class ZipArchiveEntryRequest {
public static ZipArchiveEntryRequest createZipArchiveEntryRequest(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier payloadSupplier) {
return new ZipArchiveEntryRequest(zipArchiveEntry, payloadSupplier);
}
- /*
- The zipArchiveEntry is not thread safe, and cannot be safely accessed by the getters of this class.
- It is safely accessible during the construction part of this class and also after the
- thread pools have been shut down.
+
+ /**
+ * The ZIPArchiveEntry is not thread safe, and cannot be safely accessed by the getters of this class. It is safely accessible during the construction part
+ * of this class and also after the thread pools have been shut down.
*/
private final ZipArchiveEntry zipArchiveEntry;
private final InputStreamSupplier payloadSupplier;
@@ -55,7 +56,7 @@ public class ZipArchiveEntryRequest {
}
/**
- * The compression method to use
+ * Gets the compression method to use
* @return The compression method to use
*/
public int getMethod(){
@@ -63,7 +64,7 @@ public class ZipArchiveEntryRequest {
}
/**
- * The payload that will be added to this ZIP entry
+ * Gets the payload that will be added to this ZIP entry
* @return The input stream.
*/
public InputStream getPayloadStream() {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 6d788e61..6f34d61f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -281,7 +281,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
/**
* Checks if the signature matches what is expected for a ZIP file.
- * Does not currently handle self-extracting zips which may have arbitrary
+ * Does not currently handle self-extracting ZIPs which may have arbitrary
* leading content.
*
* @param signature the bytes to check
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 86fc3599..9ce792f2 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -212,14 +212,14 @@ public class ZipFile implements Closeable {
/* offset of start of central */
/* directory with respect to */
/* the starting disk number */ + ZipConstants.WORD
- /* zipfile comment length */ + ZipConstants.SHORT;
+ /* ZIP file comment length */ + ZipConstants.SHORT;
/**
* Maximum length of the "End of central directory record" with a
* file comment.
*/
private static final int MAX_EOCD_SIZE = MIN_EOCD_SIZE
- /* maximum length of zipfile comment */ + ZipConstants.ZIP64_MAGIC_SHORT;
+ /* maximum length of ZIP file comment */ + ZipConstants.ZIP64_MAGIC_SHORT;
/**
* Offset of the field that holds the location of the length of
@@ -345,24 +345,24 @@ public class ZipFile implements Closeable {
/* uncompressed size */ + (long) ZipConstants.WORD;
/**
- * close a zipfile quietly; throw no io fault, do nothing
- * on a null parameter
- * @param zipfile file to close, can be null
+ * Closes a ZIP file quietly; throwing no IOException, dooes nothing
+ * on null input.
+ * @param zipFile file to close, can be null
*/
- public static void closeQuietly(final ZipFile zipfile) {
- IOUtils.closeQuietly(zipfile);
+ public static void closeQuietly(final ZipFile zipFile) {
+ IOUtils.closeQuietly(zipFile);
}
+
/**
* List of entries in the order they appear inside the central
* directory.
*/
- private final List<ZipArchiveEntry> entries =
- new LinkedList<>();
+ private final List<ZipArchiveEntry> entries = new LinkedList<>();
+
/**
* Maps String to list of ZipArchiveEntrys, name -> actual entries.
*/
- private final Map<String, LinkedList<ZipArchiveEntry>> nameMap =
- new HashMap<>(HASH_SIZE);
+ private final Map<String, LinkedList<ZipArchiveEntry>> nameMap = new HashMap<>(HASH_SIZE);
/**
* The encoding to use for file names and the file comment.
@@ -758,7 +758,7 @@ public class ZipFile implements Closeable {
}
/**
- * Transfer selected entries from this zipfile to a given #ZipArchiveOutputStream.
+ * Transfer selected entries from this ZIP file to a given #ZipArchiveOutputStream.
* Compression and all other attributes will be as in this file.
* <p>This method transfers entries based on the central directory of the ZIP file.</p>
*
@@ -802,7 +802,7 @@ public class ZipFile implements Closeable {
}
/**
- * Ensures that the close method of this zipfile is called when
+ * Ensures that the close method of this ZIP file is called when
* there are no more references to it.
* @see #close()
*/
@@ -941,32 +941,32 @@ public class ZipFile implements Closeable {
/**
* Gets an InputStream for reading the contents of the given entry.
*
- * @param ze the entry to get the stream for.
+ * @param zipEntry the entry to get the stream for.
* @return a stream to read the entry from. The returned stream
* implements {@link InputStreamStatistics}.
- * @throws IOException if unable to create an input stream from the zipentry
+ * @throws IOException if unable to create an input stream from the zipEntry.
*/
- public InputStream getInputStream(final ZipArchiveEntry ze)
+ public InputStream getInputStream(final ZipArchiveEntry zipEntry)
throws IOException {
- if (!(ze instanceof Entry)) {
+ if (!(zipEntry instanceof Entry)) {
return null;
}
// cast validity is checked just above
- ZipUtil.checkRequestedFeatures(ze);
+ ZipUtil.checkRequestedFeatures(zipEntry);
// doesn't get closed if the method is not supported - which
// should never happen because of the checkRequestedFeatures
// call above
- final InputStream is = new BufferedInputStream(getRawInputStream(ze)); //NOSONAR
- switch (ZipMethod.getMethodByCode(ze.getMethod())) {
+ final InputStream is = new BufferedInputStream(getRawInputStream(zipEntry)); //NOSONAR
+ switch (ZipMethod.getMethodByCode(zipEntry.getMethod())) {
case STORED:
return new StoredStatisticsStream(is);
case UNSHRINKING:
return new UnshrinkingInputStream(is);
case IMPLODING:
try {
- return new ExplodingInputStream(ze.getGeneralPurposeBit().getSlidingDictionarySize(),
- ze.getGeneralPurposeBit().getNumberOfShannonFanoTrees(), is);
+ return new ExplodingInputStream(zipEntry.getGeneralPurposeBit().getSlidingDictionarySize(),
+ zipEntry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(), is);
} catch (final IllegalArgumentException ex) {
throw new IOException("bad IMPLODE data", ex);
}
@@ -1006,7 +1006,7 @@ public class ZipFile implements Closeable {
case WAVPACK:
case XZ:
default:
- throw new UnsupportedZipFeatureException(ZipMethod.getMethodByCode(ze.getMethod()), ze);
+ throw new UnsupportedZipFeatureException(ZipMethod.getMethodByCode(zipEntry.getMethod()), zipEntry);
}
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
index 62b80704..6c4ae75b 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
@@ -33,6 +33,7 @@ import org.apache.commons.compress.utils.FileNameUtils;
* @since 1.20
*/
class ZipSplitOutputStream extends OutputStream {
+
/**
* 8.5.1 Capacities for split archives are as follows:
* <p>
@@ -53,27 +54,31 @@ class ZipSplitOutputStream extends OutputStream {
private final byte[] singleByte = new byte[1];
/**
- * Create a split zip. If the ZIP file is smaller than the split size,
- * then there will only be one split zip, and its suffix is .zip,
+ * Creates a split ZIP. If the ZIP file is smaller than the split size,
+ * then there will only be one split ZIP, and its suffix is .zip,
* otherwise the split segments should be like .z01, .z02, ... .z(N-1), .zip
* @param zipFile the ZIP file to write to
* @param splitSize the split size
+ * @throws IllegalArgumentException if arguments are illegal: Zip split segment size should between 64K and 4,294,967,295.
+ * @throws IOException if an I/O error occurs
*/
public ZipSplitOutputStream(final File zipFile, final long splitSize) throws IllegalArgumentException, IOException {
this(zipFile.toPath(), splitSize);
}
/**
- * Create a split zip. If the ZIP file is smaller than the split size,
- * then there will only be one split zip, and its suffix is .zip,
+ * Creates a split ZIP. If the ZIP file is smaller than the split size,
+ * then there will only be one split ZIP, and its suffix is .zip,
* otherwise the split segments should be like .z01, .z02, ... .z(N-1), .zip
* @param zipFile the path to ZIP file to write to
* @param splitSize the split size
+ * @throws IllegalArgumentException if arguments are illegal: Zip split segment size should between 64K and 4,294,967,295.
+ * @throws IOException if an I/O error occurs
* @since 1.22
*/
public ZipSplitOutputStream(final Path zipFile, final long splitSize) throws IllegalArgumentException, IOException {
if (splitSize < ZIP_SEGMENT_MIN_SIZE || splitSize > ZIP_SEGMENT_MAX_SIZE) {
- throw new IllegalArgumentException("zip split segment size should between 64K and 4,294,967,295");
+ throw new IllegalArgumentException("Zip split segment size should between 64K and 4,294,967,295");
}
this.zipFile = zipFile;
this.splitSize = splitSize;