Skip to content
Permalink
Browse files
Add SevenZArchiveEntry.setContentMethods(SevenZMethodConfiguration...).
  • Loading branch information
garydgregory committed May 5, 2022
1 parent cd0eb9c commit 1be1abb9523da66d6e537de64215eae14c0b64ea
Showing 3 changed files with 32 additions and 10 deletions.
@@ -122,6 +122,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="COMPRESS-612" type="add" dev="ggregory" due-to="Andre Brait, Gary Gregory">
Improve TAR support for file times #254.
</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">
Add SevenZArchiveEntry.setContentMethods(SevenZMethodConfiguration...).
</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">
Bump mockito-core from 3.11.1 to 4.5.1 #209, #224, #231, #235, #243, #253, #286.
@@ -17,6 +17,7 @@
*/
package org.apache.commons.compress.archivers.sevenz;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
@@ -470,6 +471,24 @@ public void setContentMethods(final Iterable<? extends SevenZMethodConfiguration
}
}

/**
* Sets the (compression) methods to use for entry's content - the
* default is LZMA2.
*
* <p>Currently only {@link SevenZMethod#COPY}, {@link
* SevenZMethod#LZMA2}, {@link SevenZMethod#BZIP2} and {@link
* SevenZMethod#DEFLATE} are supported when writing archives.</p>
*
* <p>The methods will be consulted in iteration order to create
* the final output.</p>
*
* @param methods the methods to use for the content
* @since 1.22
*/
public void setContentMethods(SevenZMethodConfiguration... methods) {
setContentMethods(Arrays.asList(methods));
}

/**
* Gets the (compression) methods to use for entry's content - the
* default is LZMA2.
@@ -35,9 +35,9 @@ public void methodConfigurationMattersInEquals() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
final SevenZArchiveEntry z3 = new SevenZArchiveEntry();
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 1)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2)));
z3.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2)));
z1.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 1));
z2.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2));
z3.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 2));
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
assertEquals(z3, z2);
@@ -48,8 +48,8 @@ public void methodConfigurationMattersInEquals() {
public void methodOrderMattersInEquals() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2), new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
z1.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.LZMA2), new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER));
z2.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2));
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}
@@ -58,7 +58,7 @@ public void methodOrderMattersInEquals() {
public void noMethodsIsDifferentFromSomeMethods() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.COPY)));
z2.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.COPY));
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}
@@ -67,8 +67,8 @@ public void noMethodsIsDifferentFromSomeMethods() {
public void oneMethodsIsDifferentFromTwoMethods() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.COPY)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
z1.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.COPY));
z2.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2));
assertNotEquals(z1, z2);
assertNotEquals(z2, z1);
}
@@ -77,8 +77,8 @@ public void oneMethodsIsDifferentFromTwoMethods() {
public void sameMethodsYieldEqualEntries() {
final SevenZArchiveEntry z1 = new SevenZArchiveEntry();
final SevenZArchiveEntry z2 = new SevenZArchiveEntry();
z1.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
z2.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
z1.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2));
z2.setContentMethods(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER), new SevenZMethodConfiguration(SevenZMethod.LZMA2));
assertEquals(z1, z2);
assertEquals(z2, z1);
}

0 comments on commit 1be1abb

Please sign in to comment.