ppkarwasz commented on code in PR #706:
URL: https://github.com/apache/commons-compress/pull/706#discussion_r2352056430
##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java:
##########
@@ -77,6 +77,112 @@
*/
public class ZipArchiveInputStream extends ArchiveInputStream<ZipArchiveEntry>
implements InputStreamStatistics {
+ /**
+ * Abstract builder for derived classes of {@link ZipArchiveInputStream}.
+ *
+ * @param <T> The type of the {@link ZipArchiveInputStream}.
+ * @param <B> The type of the builder itself.
+ * @since 1.29.0
+ */
+ public abstract static class AbstractBuilder<T extends
ZipArchiveInputStream, B extends AbstractBuilder<T, B>>
+ extends ArchiveInputStream.Builder<T, B> {
+ private boolean useUnicodeExtraFields = true;
+ private boolean allowStoredEntriesWithDataDescriptor;
+ private boolean skipSplitSig;
+
+ protected AbstractBuilder() {
+ setCharset(StandardCharsets.UTF_8);
+ }
+
+ /**
+ * Controls whether to use InfoZIP Unicode Extra Fields (if present)
to set the file names.
+ *
+ * <p>This feature is enabled by default.</p>
+ *
+ * @param useUnicodeExtraFields If {@code true} Unicode Extra Fields
should be used.
+ * @return this
+ */
+ public B setUseUnicodeExtraFields(final boolean useUnicodeExtraFields)
{
+ this.useUnicodeExtraFields = useUnicodeExtraFields;
+ return asThis();
+ }
+
+ protected boolean isUseUnicodeExtraFields() {
+ return useUnicodeExtraFields;
+ }
+
+ /**
+ * Controls whether the stream attempts to read STORED entries that
use a data descriptor.
+ *
+ * <p>If set to {@code true}, the stream will not stop reading an
entry at the
+ * declared compressed size. Instead, it will continue until a data
descriptor
+ * is encountered (by detecting the Data Descriptor Signature). This
may cause
+ * issues in certain cases, such as JARs embedded in WAR files.</p>
+ *
+ * <p>See <a
href="https://issues.apache.org/jira/browse/COMPRESS-555">COMPRESS-555</a>
+ * for details.</p>
+ *
+ * <p>This feature is disabled by default.</p>
+ *
+ * @param allowStoredEntriesWithDataDescriptor {@code true} to read
STORED entries with data descriptors,
+ * {@code false} to stop
at the compressed size.
+ * @return this
+ */
+
+ public B setAllowStoredEntriesWithDataDescriptor(final boolean
allowStoredEntriesWithDataDescriptor) {
+ this.allowStoredEntriesWithDataDescriptor =
allowStoredEntriesWithDataDescriptor;
+ return asThis();
+ }
+
+ protected boolean isAllowStoredEntriesWithDataDescriptor() {
+ return allowStoredEntriesWithDataDescriptor;
+ }
+
+ /**
+ * Configures whether the stream should skip the ZIP split signature
+ * ({@code 08074B50}) at the beginning of the input.
+ *
+ * <p>Disabled by default.</p>
+ *
+ * @param skipSplitSig {@code true} to skip the ZIP split signature,
{@code false} otherwise
+ * @return this
+ */
+ public B setSkipSplitSig(final boolean skipSplitSig) {
+ this.skipSplitSig = skipSplitSig;
+ return asThis();
+ }
+
+ protected boolean isSkipSplitSig() {
Review Comment:
I fixed the Javadoc in
https://github.com/apache/commons-compress/pull/706/commits/8cf58ad7cb397857b5fc9d5fd172af692e1ce7c4
and renamed the method (and all associated private fields) to
`isSkipSplitSignature` in
https://github.com/apache/commons-compress/pull/706/commits/bb742953c40f2efb8306a8c98dc6747edb9c7b84
I left the precise Javadoc on the builder setters, since those are `public`
and will be used by users. These getters were introduced to be reused by
implementors of derived classes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]