Author: bodewig Date: Thu Mar 7 16:24:37 2013 New Revision: 1453945 URL: http://svn.apache.org/r1453945 Log: COMPRESS-200 support decompressConcatenated in CompressorStreamFactory
Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java Modified: commons/proper/compress/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1453945&r1=1453944&r2=1453945&view=diff ============================================================================== --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Thu Mar 7 16:24:37 2013 @@ -168,6 +168,11 @@ The <action> type attribute can be add,u CompressorStreamFactory can now be used without XZ for Java being available. </action> + <action type="add" date="2013-03-07" issue="COMPRESS-220"> + CompressorStreamFactory has an option to create + decompressing streams that decompress the full input for + formats that support multiple concatenated streams. + </action> </release> <release version="1.4.1" date="2012-05-23" description="Release 1.4.1"> Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=1453945&r1=1453944&r2=1453945&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java Thu Mar 7 16:24:37 2013 @@ -83,6 +83,25 @@ public class CompressorStreamFactory { */ public static final String XZ = "xz"; + private boolean decompressConcatenated = false; + + /** + * Whether to decompress the full input or only the first stream + * in formats supporting multiple concatenated input streams. + * + * <p>This setting applies to the gzip, bzip2 and xz formats only.</p> + * + * @param decompressConcatenated + * if true, decompress until the end of the + * input; if false, stop after the first + * stream and leave the input position to point + * to the next byte after the stream + * @since Commons Compress 1.5 + */ + public void setDecompressConcatenated(boolean decompressConcatenated) { + this.decompressConcatenated = decompressConcatenated; + } + /** * Create an compressor input stream from an input stream, autodetecting * the compressor type from the first few bytes of the stream. The InputStream @@ -111,16 +130,16 @@ public class CompressorStreamFactory { in.reset(); if (BZip2CompressorInputStream.matches(signature, signatureLength)) { - return new BZip2CompressorInputStream(in); + return new BZip2CompressorInputStream(in, decompressConcatenated); } if (GzipCompressorInputStream.matches(signature, signatureLength)) { - return new GzipCompressorInputStream(in); + return new GzipCompressorInputStream(in, decompressConcatenated); } if (XZUtils.isXZCompressionAvailable() && XZCompressorInputStream.matches(signature, signatureLength)) { - return new XZCompressorInputStream(in); + return new XZCompressorInputStream(in, decompressConcatenated); } if (Pack200CompressorInputStream.matches(signature, signatureLength)) {